Skip to content

Commit

Permalink
Provide a reasonable warning message when a directory artifact crosse…
Browse files Browse the repository at this point in the history
…s a package boundary.

We probably shouldn't cross package boundaries when collecting these entries in the first place, but we might as well put lipstick on this pig.

Closes bazelbuild#12527

PiperOrigin-RevId: 346344693
  • Loading branch information
janakdr authored and Copybara-Service committed Dec 8, 2020
1 parent 6a3f3fb commit 4d9a79b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,14 @@ private static SkyValue createSourceValue(Artifact artifact, Environment env)
//
// In the future, we need to make this result the source of truth for the files available to
// the action so that we at least have consistency.
TraversalRequest request = TraversalRequest.create(
DirectTraversalRoot.forRootedPath(path),
/*isRootGenerated=*/ false,
PackageBoundaryMode.CROSS,
/*strictOutputFiles=*/ true,
/*skipTestingForSubpackage=*/ true,
/*errorInfo=*/ null);
TraversalRequest request =
TraversalRequest.create(
DirectTraversalRoot.forRootedPath(path),
/*isRootGenerated=*/ false,
PackageBoundaryMode.CROSS,
/*strictOutputFiles=*/ true,
/*skipTestingForSubpackage=*/ true,
/*errorInfo=*/ "Directory artifact " + artifact.prettyPrint());
RecursiveFilesystemTraversalValue value;
try {
value =
Expand Down
9 changes: 9 additions & 0 deletions src/test/shell/integration/execution_phase_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -384,4 +384,13 @@ function test_resource_flags_syntax() {
|| fail "Empty build failed"
}

function test_track_directory_crossing_package() {
mkdir -p foo/dir/subdir
touch foo/dir/subdir/BUILD
echo "filegroup(name = 'foo', srcs = ['dir'])" > foo/BUILD
bazel --host_jvm_args=-DBAZEL_TRACK_SOURCE_DIRECTORIES=1 build //foo \
>& "$TEST_log" || fail "Expected success"
expect_log "WARNING: Directory artifact foo/dir crosses package boundary into"
}

run_suite "Integration tests of ${PRODUCT_NAME} using the execution phase."

0 comments on commit 4d9a79b

Please sign in to comment.