1919import com .google .common .base .Joiner ;
2020import com .google .common .base .Preconditions ;
2121import com .google .common .collect .ImmutableMap ;
22+ import com .google .devtools .build .lib .runtime .CommandLinePathFactory .CommandLinePathFactoryException ;
2223import com .google .devtools .build .lib .vfs .DigestHashFunction ;
2324import com .google .devtools .build .lib .vfs .FileSystem ;
2425import com .google .devtools .build .lib .vfs .Path ;
@@ -99,6 +100,9 @@ public void createWithNamedRoot() throws Exception {
99100 .isEqualTo (filesystem .getPath ("/path/to/output/base/foo" ));
100101 assertThat (factory .create (ImmutableMap .of (), "%output_base%/foo/bar" ))
101102 .isEqualTo (filesystem .getPath ("/path/to/output/base/foo/bar" ));
103+
104+ assertThat (factory .create (ImmutableMap .of (), "%workspace%//foo//bar" ))
105+ .isEqualTo (filesystem .getPath ("/path/to/workspace/foo/bar" ));
102106 }
103107
104108 @ Test
@@ -108,9 +112,11 @@ public void pathLeakingOutsideOfRoot() {
108112 filesystem , ImmutableMap .of ("a" , filesystem .getPath ("/path/to/a" )));
109113
110114 assertThrows (
111- IllegalArgumentException .class , () -> factory .create (ImmutableMap .of (), "%a%/../foo" ));
115+ CommandLinePathFactoryException .class ,
116+ () -> factory .create (ImmutableMap .of (), "%a%/../foo" ));
112117 assertThrows (
113- IllegalArgumentException .class , () -> factory .create (ImmutableMap .of (), "%a%/b/../.." ));
118+ CommandLinePathFactoryException .class ,
119+ () -> factory .create (ImmutableMap .of (), "%a%/b/../.." ));
114120 }
115121
116122 @ Test
@@ -120,29 +126,21 @@ public void unknownRoot() {
120126 filesystem , ImmutableMap .of ("a" , filesystem .getPath ("/path/to/a" )));
121127
122128 assertThrows (
123- IllegalArgumentException .class , () -> factory .create (ImmutableMap .of (), "%workspace%/foo" ));
129+ CommandLinePathFactoryException .class ,
130+ () -> factory .create (ImmutableMap .of (), "%workspace%/foo" ));
124131 assertThrows (
125- IllegalArgumentException .class ,
132+ CommandLinePathFactoryException .class ,
126133 () -> factory .create (ImmutableMap .of (), "%output_base%/foo" ));
127134 }
128135
129- @ Test
130- public void rootWithDoubleSlash () {
131- CommandLinePathFactory factory =
132- new CommandLinePathFactory (
133- filesystem , ImmutableMap .of ("a" , filesystem .getPath ("/path/to/a" )));
134-
135- assertThrows (
136- IllegalArgumentException .class , () -> factory .create (ImmutableMap .of (), "%a%//foo" ));
137- }
138-
139136 @ Test
140137 public void relativePathWithMultipleSegments () {
141138 CommandLinePathFactory factory = new CommandLinePathFactory (filesystem , ImmutableMap .of ());
142139
143- assertThrows (IllegalArgumentException .class , () -> factory .create (ImmutableMap .of (), "a/b" ));
144140 assertThrows (
145- IllegalArgumentException .class , () -> factory .create (ImmutableMap .of (), "a/b/c/d" ));
141+ CommandLinePathFactoryException .class , () -> factory .create (ImmutableMap .of (), "a/b" ));
142+ assertThrows (
143+ CommandLinePathFactoryException .class , () -> factory .create (ImmutableMap .of (), "a/b/c/d" ));
146144 }
147145
148146 @ Test
0 commit comments