diff options
author | Klaus Aehlig <aehlig@google.com> | 2018-03-21 06:31:54 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-03-21 06:33:04 -0700 |
commit | 1762772f482e6bdeb937b830dca9ba71f8f5edf7 (patch) | |
tree | 9e435a4e1f5d44a53d93ec663fd4db9a3ebc404f /src | |
parent | 12d00dce295b7f308f580b39c2b3a7bc080ad921 (diff) |
Add a test, verifying that paths within the same repo can be hard-coded
To simplify the transition for existing repositories, we keep the property
that paths to true source files in your own repository may be hard-coded.
Add a test verifying that we keep this property.
Also add a test checking that this property is true, if the same repository
is built as a remote repository. But disable this test, as this property
does not hold yet; we plan to make it true with a change of the execroot
layout.
Change-Id: I0fb961f8ddb8feb98a6309533fc82f2acd9afd0d
PiperOrigin-RevId: 189898773
Diffstat (limited to 'src')
-rwxr-xr-x | src/test/shell/bazel/external_path_test.sh | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/test/shell/bazel/external_path_test.sh b/src/test/shell/bazel/external_path_test.sh index 1d314cef86..214ee34467 100755 --- a/src/test/shell/bazel/external_path_test.sh +++ b/src/test/shell/bazel/external_path_test.sh @@ -262,6 +262,67 @@ EOF || fail "Expected output 'Hello World'" } +repo_with_local_path_reference() { + # create, in the current working directory, a pacakge called + # withpath, that contains rule depending on hard-code path relative + # to the repository root. + mkdir -p withpath + cat > withpath/BUILD <<'EOF' +genrule( + name = "it", + srcs = ["double.sh", "data.txt"], + outs = ["it.txt"], + cmd = "sh $(location double.sh) > $@", + visibility = ["//visibility:public"], +) +EOF + cat > withpath/double.sh <<'EOF' +#!/bin/sh +cat withpath/data.txt withpath/data.txt +EOF + cat > withpath/data.txt <<'EOF' +Hello world +EOF +} + +test_fixed_path_local() { + # Verify that hard-coded path relative to the repository root can + # be used in internal targets. + WRKDIR=$(mktemp -d "${TEST_TMPDIR}/testXXXXXX") + cd "${WRKDIR}" + + mkdir main + cd main + touch WORKSPACE + repo_with_local_path_reference + + bazel build //withpath:it || fail "Expected success" +} + +# TODO(aehlig): enable, once our execroot change is far enough +# to make this (desirbale) property true. +DISABLED_test_fixed_path_remote() { + WRKDIR=$(mktemp -d "${TEST_TMPDIR}/testXXXXXX") + cd "${WRKDIR}" + + mkdir remote + (cd remote && repo_with_local_path_reference) + tar cvf remote.tar remote + rm -rf remote + + mkdir main + cd main + cat > WORKSPACE <<EOF +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +http_archive( + name="remote", + strip_prefix="remote", + urls=["file://${WRKDIR}/remote.tar"], +) +EOF + + bazel build @remote//withpath:it || fail "Expected success" +} repo_with_local_implicit_dependencies() { # create, in the current working directory, a package called rule # that has an implicit dependency on a target in the same repository; |