19
19
import com .google .common .base .Joiner ;
20
20
import com .google .common .base .Preconditions ;
21
21
import com .google .common .collect .ImmutableMap ;
22
+ import com .google .devtools .build .lib .runtime .CommandLinePathFactory .CommandLinePathFactoryException ;
22
23
import com .google .devtools .build .lib .vfs .DigestHashFunction ;
23
24
import com .google .devtools .build .lib .vfs .FileSystem ;
24
25
import com .google .devtools .build .lib .vfs .Path ;
@@ -99,6 +100,9 @@ public void createWithNamedRoot() throws Exception {
99
100
.isEqualTo (filesystem .getPath ("/path/to/output/base/foo" ));
100
101
assertThat (factory .create (ImmutableMap .of (), "%output_base%/foo/bar" ))
101
102
.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" ));
102
106
}
103
107
104
108
@ Test
@@ -108,9 +112,11 @@ public void pathLeakingOutsideOfRoot() {
108
112
filesystem , ImmutableMap .of ("a" , filesystem .getPath ("/path/to/a" )));
109
113
110
114
assertThrows (
111
- IllegalArgumentException .class , () -> factory .create (ImmutableMap .of (), "%a%/../foo" ));
115
+ CommandLinePathFactoryException .class ,
116
+ () -> factory .create (ImmutableMap .of (), "%a%/../foo" ));
112
117
assertThrows (
113
- IllegalArgumentException .class , () -> factory .create (ImmutableMap .of (), "%a%/b/../.." ));
118
+ CommandLinePathFactoryException .class ,
119
+ () -> factory .create (ImmutableMap .of (), "%a%/b/../.." ));
114
120
}
115
121
116
122
@ Test
@@ -120,29 +126,21 @@ public void unknownRoot() {
120
126
filesystem , ImmutableMap .of ("a" , filesystem .getPath ("/path/to/a" )));
121
127
122
128
assertThrows (
123
- IllegalArgumentException .class , () -> factory .create (ImmutableMap .of (), "%workspace%/foo" ));
129
+ CommandLinePathFactoryException .class ,
130
+ () -> factory .create (ImmutableMap .of (), "%workspace%/foo" ));
124
131
assertThrows (
125
- IllegalArgumentException .class ,
132
+ CommandLinePathFactoryException .class ,
126
133
() -> factory .create (ImmutableMap .of (), "%output_base%/foo" ));
127
134
}
128
135
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
-
139
136
@ Test
140
137
public void relativePathWithMultipleSegments () {
141
138
CommandLinePathFactory factory = new CommandLinePathFactory (filesystem , ImmutableMap .of ());
142
139
143
- assertThrows (IllegalArgumentException .class , () -> factory .create (ImmutableMap .of (), "a/b" ));
144
140
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" ));
146
144
}
147
145
148
146
@ Test
0 commit comments