2022-12-03 07:23:57 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -o errexit -o nounset -o pipefail
|
|
|
|
|
2023-11-15 23:07:03 +00:00
|
|
|
BZLMOD_FLAG="${BZLMOD_FLAG:-}"
|
|
|
|
|
2022-12-03 07:23:57 +00:00
|
|
|
function run_test {
|
2023-11-15 23:07:03 +00:00
|
|
|
bazel run $BZLMOD_FLAG //lib/tests/write_source_files:write_subdir
|
2022-12-03 07:23:57 +00:00
|
|
|
local expected_out="lib/tests/write_source_files/subdir_test/a/b/c/test.txt"
|
|
|
|
if [ ! -e "$expected_out" ]; then
|
|
|
|
echo "ERROR: expected $expected_out to exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -x "$expected_out" ]; then
|
|
|
|
echo "ERROR: expected $expected_out to not be executable"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-11-15 23:07:03 +00:00
|
|
|
bazel run $BZLMOD_FLAG //lib/tests/write_source_files:write_subdir_executable
|
2022-12-03 07:23:57 +00:00
|
|
|
local expected_out="lib/tests/write_source_files/subdir_executable_test/a/b/c/test.txt"
|
|
|
|
if [ ! -e "$expected_out" ]; then
|
|
|
|
echo "ERROR: expected $expected_out to exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ ! -x "$expected_out" ]; then
|
|
|
|
echo "ERROR: expected $expected_out to be executable"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Run twice to make sure we can have permission to overwrite the outputs of a previous run
|
2022-12-03 18:52:52 +00:00
|
|
|
rm -Rf lib/tests/write_source_files/subdir_test
|
|
|
|
rm -Rf lib/tests/write_source_files/subdir_executable_test
|
2022-12-03 07:23:57 +00:00
|
|
|
run_test
|
|
|
|
run_test
|
|
|
|
echo "All tests passed"
|