Fix bash test scripts to work on Windows. by dbaarda · Pull Request #224 · librsync/librsync
added 3 commits
August 9, 2021 22:41The arguments given to `find_path()` and `find_library()` either matched the default values, were redundant, or were better fixed by setting `CMAKE_PREFIX_PATH` to point at the popt install location in the cmake cmdline. The POPT_ROOT_DIR location hint has also been removed, but note that cmake 3.12 adds support for using `<PackageName>_ROOT` as the first location hint by default.
In CMakeLists.txt, explicity execute scripts with bash on WIN32 platforms (it
doesn't understand `#!/bin/sh`). Execute test scripts with the full rdiff path
expanded from `$<TARGET_FILE:rdiff>` as the first argument instead of
`${CMAKE_CURRENT_BINARY_DIR}`.
Update tests/testcommon.sh to set `RDIFF` instead of `bindir` from $1, and use
`${RDIFF}` as the rdiff binary in all tests.
Change rdiff_bad_option.sh to use testcommon.sh and use $RDIFF to execute the
rdiff binary. Make it use the testcommon.sh created tmpdir and use set -x to
trace only the interesting cmds instead of the whole script.
The $<TARGET_FILE:rdiff> is always the full path of the generated binary,
including the .exe extension on Windows. The ${CMAKE_CURRENT_BINARY_DIR} is
usually the directory where the generated binary is, but multi-configuration
generators (Visual Studio, Ninja) add a per-build-type directory (Release,
Debug, etc) and put them in there.
This means ${CMAKE_CURRENT_BINARY_DIR} doesn't give you an easy way to find
the binary, and doesn't tell you if it has a .exe extension. Passing in the
full binary path solves all these problems. Fortunately the tests only need
the rdiff binary.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters