Skip to content

Commit

Permalink
Accept tildes in --override_module
Browse files Browse the repository at this point in the history
This is useful for adding this in your global ~/.bazelrc file for easy
rules debugging.

See also bazelbuild#15417
  • Loading branch information
keith committed Jan 13, 2023
1 parent 3136d9c commit f76eae6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,12 @@ public ModuleOverride convert(String input) throws OptionsParsingException {
OptionsUtils.AbsolutePathFragmentConverter absolutePathFragmentConverter =
new OptionsUtils.AbsolutePathFragmentConverter();
try {
var unused = absolutePathFragmentConverter.convert(pieces[1]);
var path = absolutePathFragmentConverter.convert(pieces[1]);
return ModuleOverride.create(pieces[0], path.toString());
} catch (OptionsParsingException e) {
throw new OptionsParsingException(
"Module override directory must be an absolute path", input, e);
}
return ModuleOverride.create(pieces[0], pieces[1]);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ public void testOverridePathWithTilde() throws Exception {
assertThat(actual.path()).isEqualTo(PathFragment.create(USER_HOME.value() + "/bar"));
}

@Test
public void testModuleOverridePathWithTilde() throws Exception {
RepositoryOverride actual = converter.convert("foo=~/bar");
assertThat(actual.repositoryName()).isEqualTo(RepositoryName.createUnvalidated("foo"));
assertThat(actual.path()).isEqualTo(PathFragment.create(USER_HOME.value() + "/bar"));
}

@Test
public void testInvalidOverride() throws Exception {
expectedException.expect(OptionsParsingException.class);
Expand Down

0 comments on commit f76eae6

Please sign in to comment.