Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept tildes in --override_module #17218

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -17,6 +17,8 @@
import static com.google.common.base.StandardSystemProperty.USER_HOME;
import static com.google.common.truth.Truth.assertThat;

import com.google.devtools.build.lib.bazel.repository.RepositoryOptions.ModuleOverride;
import com.google.devtools.build.lib.bazel.repository.RepositoryOptions.ModuleOverrideConverter;
import com.google.devtools.build.lib.bazel.repository.RepositoryOptions.RepositoryOverride;
import com.google.devtools.build.lib.bazel.repository.RepositoryOptions.RepositoryOverrideConverter;
import com.google.devtools.build.lib.cmdline.RepositoryName;
Expand Down Expand Up @@ -60,6 +62,14 @@ public void testOverridePathWithTilde() throws Exception {
assertThat(actual.path()).isEqualTo(PathFragment.create(USER_HOME.value() + "/bar"));
}

@Test
public void testModuleOverridePathWithTilde() throws Exception {
var converter = new ModuleOverrideConverter();
ModuleOverride actual = converter.convert("foo=~/bar");
assertThat(PathFragment.create(actual.path()))
.isEqualTo(PathFragment.create(USER_HOME.value() + "/bar"));
}

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