diff options
author | Robbert van Ginkel <robbert@vanginkels.com> | 2020-04-14 10:04:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-14 19:04:34 +0200 |
commit | feb52960ebd8797421b599194ad6ac7da3fc7600 (patch) | |
tree | f534f0b128397a948a2ff073ab580a571b911c56 /tests | |
parent | 9935e0f820692f5f38e3b00c64ccbbff30cebe11 (diff) | |
download | bazel-skylib-feb52960ebd8797421b599194ad6ac7da3fc7600.tar.gz |
Fix diff_test when filepath includes external (#241)
Resolves https://github.com/bazelbuild/bazel-skylib/issues/240.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/diff_test/diff_test_tests.sh | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/tests/diff_test/diff_test_tests.sh b/tests/diff_test/diff_test_tests.sh index 1cab39b..ed894c2 100755 --- a/tests/diff_test/diff_test_tests.sh +++ b/tests/diff_test/diff_test_tests.sh @@ -50,10 +50,12 @@ function import_diff_test() { function assert_simple_diff_test() { local -r flag="$1" local -r ws="${TEST_TMPDIR}/$2" + local -r subdir="$3" import_diff_test "$ws" touch "$ws/WORKSPACE" - cat >"$ws/BUILD" <<'eof' + mkdir -p "$ws/$subdir" + cat >"$ws/${subdir}BUILD" <<'eof' load("//rules:diff_test.bzl", "diff_test") diff_test( @@ -68,17 +70,17 @@ diff_test( file2 = "b.txt", ) eof - echo foo > "$ws/a.txt" - echo bar > "$ws/b.txt" + echo foo > "$ws/$subdir/a.txt" + echo bar > "$ws/$subdir/b.txt" (cd "$ws" && \ - bazel test "$flag" //:same --test_output=errors 1>"$TEST_log" 2>&1 \ + bazel test "$flag" "//${subdir%/}:same" --test_output=errors 1>"$TEST_log" 2>&1 \ || fail "expected success") (cd "$ws" && \ - bazel test "$flag" //:different --test_output=errors 1>"$TEST_log" 2>&1 \ + bazel test "$flag" "//${subdir%/}:different" --test_output=errors 1>"$TEST_log" 2>&1 \ && fail "expected failure" || true) - expect_log 'FAIL: files "a.txt" and "b.txt" differ' + expect_log "FAIL: files \"${subdir}a.txt\" and \"${subdir}b.txt\" differ" } function assert_from_ext_repo() { @@ -187,11 +189,19 @@ eof } function test_simple_diff_test_with_legacy_external_runfiles() { - assert_simple_diff_test "--legacy_external_runfiles" "${FUNCNAME[0]}" + assert_simple_diff_test "--legacy_external_runfiles" "${FUNCNAME[0]}" "" } function test_simple_diff_test_without_legacy_external_runfiles() { - assert_simple_diff_test "--nolegacy_external_runfiles" "${FUNCNAME[0]}" + assert_simple_diff_test "--nolegacy_external_runfiles" "${FUNCNAME[0]}" "" +} + +function test_directory_named_external_with_legacy_external_runfiles() { + assert_simple_diff_test "--legacy_external_runfiles" "${FUNCNAME[0]}" "path/to/direcotry/external/in/name/" +} + +function test_directory_named_external_without_legacy_external_runfiles() { + assert_simple_diff_test "--nolegacy_external_runfiles" "${FUNCNAME[0]}" "path/to/direcotry/external/in/name/" } function test_from_ext_repo_with_legacy_external_runfiles() { |