diff options
author | David Ostrovsky <david@ostrovsky.org> | 2018-03-20 08:23:10 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-03-20 08:24:33 -0700 |
commit | f87a656610413ffbc4ef44cb89081c9a111b4827 (patch) | |
tree | 72dc9b5e172eb25b11df9993dd25b1d28843ec96 /src/test/java/com/google/devtools/build/lib/util | |
parent | 3c5373c50c7c492842f8a468906eda2c0bc90787 (diff) |
Allow path options to use user specific paths
Fixes #2054.
Allow users to be able to specify user specific paths. With this option
we can now commit bazel configuration file and force local action cache
activation per default:
$ cat tools/bazel.rc
build --experimental_local_disk_cache_path=~/.gerrit/bazel-cache/cas
build --experimental_local_disk_cache
build --experimental_strict_action_env
Test Plan:
$ bazel test //src/test/java/com/google/devtools/build/lib:util_test
Closes #4852.
PiperOrigin-RevId: 189744599
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/util')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/util/OptionsUtilsTest.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/util/OptionsUtilsTest.java b/src/test/java/com/google/devtools/build/lib/util/OptionsUtilsTest.java index ddf8dadda9..2d7d2f75f9 100644 --- a/src/test/java/com/google/devtools/build/lib/util/OptionsUtilsTest.java +++ b/src/test/java/com/google/devtools/build/lib/util/OptionsUtilsTest.java @@ -17,6 +17,7 @@ import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.fail; import com.google.common.collect.Lists; +import com.google.devtools.build.lib.util.OptionsUtils.PathFragmentConverter; import com.google.devtools.build.lib.util.OptionsUtils.PathFragmentListConverter; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.common.options.Option; @@ -166,6 +167,10 @@ public class OptionsUtilsTest { return new PathFragmentListConverter().convert(input); } + private PathFragment convertOne(String input) throws Exception { + return new PathFragmentConverter().convert(input); + } + @Test public void emptyStringYieldsEmptyList() throws Exception { assertThat(convert("")).isEqualTo(list()); @@ -183,13 +188,24 @@ public class OptionsUtilsTest { @Test public void multiplePaths() throws Exception { - assertThat(convert("foo:/bar/baz:.:/tmp/bang")) + assertThat(convert("~/foo:foo:/bar/baz:.:/tmp/bang")) .containsExactly( - fragment("foo"), fragment("/bar/baz"), fragment("."), fragment("/tmp/bang")) + fragment(System.getProperty("user.home") + "/foo"), + fragment("foo"), + fragment("/bar/baz"), + fragment("."), + fragment("/tmp/bang")) .inOrder(); } @Test + public void singlePath() throws Exception { + assertThat(convertOne("foo")).isEqualTo(fragment("foo")); + assertThat(convertOne("foo/bar/baz")).isEqualTo(fragment("foo/bar/baz")); + assertThat(convertOne("~/foo")).isEqualTo(fragment(System.getProperty("user.home") + "/foo")); + } + + @Test public void valueisUnmodifiable() throws Exception { try { new PathFragmentListConverter().convert("value").add(PathFragment.create("other")); |