Skip to content

Commit

Permalink
Add test for repository overrides, conflicting with managed directori…
Browse files Browse the repository at this point in the history
…es being added when Bazel server is already started.

PiperOrigin-RevId: 246790372
  • Loading branch information
Googler authored and copybara-github committed May 6, 2019
1 parent 61c7ffa commit 898d7b6
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,37 @@ public void testRepositoryOverrideWithManagedDirectories() throws Exception {
+ " have managed directories: @generated_node_modules");
}

@Test
public void testRepositoryOverrideChangeToConflictWithManagedDirectories() throws Exception {
generateProject();
buildExpectRepositoryRuleCalled();
checkProjectFiles();

Path override = context().getTmpDir().resolve("override");
PathUtils.writeFile(override.resolve(WORKSPACE));
// Just define some similar target.
PathUtils.writeFile(
override.resolve("BUILD"),
"genrule(",
" name = \"example-module\",",
" srcs = [],",
" cmd = \"touch $(location package.json)\",",
" outs = [\"package.json\"],",
" visibility = ['//visibility:public'],",
")");

// Now the overrides change.
BuilderRunner bazel =
bazel().withFlags("--override_repository=generated_node_modules=" + override.toString());
ProcessResult result = bazel.shouldFail().build("@generated_node_modules//:example-module");
assertThat(result.errString())
.contains(
"ERROR: Overriding repositories is not allowed"
+ " for the repositories with managed directories."
+ "\nThe following overridden external repositories"
+ " have managed directories: @generated_node_modules");
}

private void generateProject() throws IOException {
for (String fileName : FILES) {
String text = ResourceFileLoader.loadResource(ManagedDirectoriesBlackBoxTest.class, fileName);
Expand Down

0 comments on commit 898d7b6

Please sign in to comment.