@@ -175,22 +175,6 @@ public void testFilterListForObscuringSymlinksNoObscurers() {
175
175
assertNoEvents ();
176
176
}
177
177
178
- private void checkConflictWarning () {
179
- assertContainsEvent ("overwrote runfile" );
180
- assertWithMessage ("ConflictChecker.put should have warned once" )
181
- .that (eventCollector .count ())
182
- .isEqualTo (1 );
183
- assertThat (Iterables .getOnlyElement (eventCollector ).getKind ()).isEqualTo (EventKind .WARNING );
184
- }
185
-
186
- private void checkConflictError () {
187
- assertContainsEvent ("overwrote runfile" );
188
- assertWithMessage ("ConflictChecker.put should have errored once" )
189
- .that (eventCollector .count ())
190
- .isEqualTo (1 );
191
- assertThat (Iterables .getOnlyElement (eventCollector ).getKind ()).isEqualTo (EventKind .ERROR );
192
- }
193
-
194
178
private static final class SimpleActionLookupKey implements ActionLookupKey {
195
179
private final String name ;
196
180
@@ -217,7 +201,7 @@ public BuildConfigurationKey getConfigurationKey() {
217
201
}
218
202
219
203
@ Test
220
- public void testPutDerivedArtifactWithDifferentOwnerDoesNotConflict () throws Exception {
204
+ public void testPutDerivedArtifactWithDifferentOwner () throws Exception {
221
205
ArtifactRoot root =
222
206
ArtifactRoot .asDerivedRoot (scratch .dir ("/workspace" ), RootType .Output , "out" );
223
207
PathFragment path = PathFragment .create ("src/foo.cc" );
@@ -230,36 +214,13 @@ public void testPutDerivedArtifactWithDifferentOwnerDoesNotConflict() throws Exc
230
214
Map <PathFragment , Artifact > map = new LinkedHashMap <>();
231
215
232
216
Runfiles .ConflictChecker checker = eventConflictChecker (Runfiles .ConflictPolicy .WARN );
233
- checker .put (map , path , artifact1 , ConflictType . OTHER );
217
+ checker .put (map , path , artifact1 );
234
218
assertThat (map .entrySet ()).containsExactly (Maps .immutableEntry (path , artifact1 ));
235
- checker .put (map , path , artifact2 , ConflictType . OTHER );
219
+ checker .put (map , path , artifact2 );
236
220
assertThat (map .entrySet ()).containsExactly (Maps .immutableEntry (path , artifact2 ));
237
221
assertNoEvents ();
238
222
}
239
223
240
- @ Test
241
- public void testPutDerivedArtifactWithDifferentPathConflicts () throws Exception {
242
- ArtifactRoot root =
243
- ArtifactRoot .asDerivedRoot (scratch .dir ("/workspace" ), RootType .Output , "out" );
244
- PathFragment path = PathFragment .create ("src/foo.cc" );
245
- PathFragment path2 = PathFragment .create ("src/bar.cc" );
246
-
247
- SimpleActionLookupKey owner1 = new SimpleActionLookupKey ("//owner1" );
248
- SimpleActionLookupKey owner2 = new SimpleActionLookupKey ("//owner2" );
249
- Artifact artifact1 = DerivedArtifact .create (root , root .getExecPath ().getRelative (path ), owner1 );
250
- Artifact artifact2 =
251
- DerivedArtifact .create (root , root .getExecPath ().getRelative (path2 ), owner2 );
252
-
253
- Map <PathFragment , Artifact > map = new LinkedHashMap <>();
254
-
255
- Runfiles .ConflictChecker checker = eventConflictChecker (Runfiles .ConflictPolicy .WARN );
256
- checker .put (map , path , artifact1 , ConflictType .OTHER );
257
- assertThat (map .entrySet ()).containsExactly (Maps .immutableEntry (path , artifact1 ));
258
- checker .put (map , path , artifact2 , ConflictType .OTHER );
259
- assertThat (map .entrySet ()).containsExactly (Maps .immutableEntry (path , artifact2 ));
260
- checkConflictWarning ();
261
- }
262
-
263
224
private BiConsumer <ConflictType , String > eventConflictReceiver (EventKind eventKind ) {
264
225
return (conflictType , message ) -> reporter .handle (Event .of (eventKind , message ));
265
226
}
@@ -277,127 +238,6 @@ private Runfiles.ConflictChecker eventConflictChecker(Runfiles.ConflictPolicy co
277
238
}
278
239
;
279
240
280
- @ Test
281
- public void testPutCatchesConflict () {
282
- ArtifactRoot root = ArtifactRoot .asSourceRoot (Root .fromPath (scratch .resolve ("/workspace" )));
283
- PathFragment pathA = PathFragment .create ("a" );
284
- Artifact artifactB = ActionsTestUtil .createArtifact (root , "b" );
285
- Artifact artifactC = ActionsTestUtil .createArtifact (root , "c" );
286
- Map <PathFragment , Artifact > map = new LinkedHashMap <>();
287
-
288
- Runfiles .ConflictChecker checker = eventConflictChecker (Runfiles .ConflictPolicy .WARN );
289
- checker .put (map , pathA , artifactB , ConflictType .OTHER );
290
- assertThat (map .entrySet ()).containsExactly (Maps .immutableEntry (pathA , artifactB ));
291
- checker .put (map , pathA , artifactC , ConflictType .OTHER );
292
- assertThat (map .entrySet ()).containsExactly (Maps .immutableEntry (pathA , artifactC ));
293
- checkConflictWarning ();
294
- }
295
-
296
- @ Test
297
- public void testPutReportsError () {
298
- ArtifactRoot root = ArtifactRoot .asSourceRoot (Root .fromPath (scratch .resolve ("/workspace" )));
299
- PathFragment pathA = PathFragment .create ("a" );
300
- Artifact artifactB = ActionsTestUtil .createArtifact (root , "b" );
301
- Artifact artifactC = ActionsTestUtil .createArtifact (root , "c" );
302
- Map <PathFragment , Artifact > map = new LinkedHashMap <>();
303
-
304
- // Same as above but with ERROR not WARNING
305
- Runfiles .ConflictChecker checker = eventConflictChecker (Runfiles .ConflictPolicy .ERROR );
306
- checker .put (map , pathA , artifactB , ConflictType .OTHER );
307
- reporter .removeHandler (failFastHandler ); // So it doesn't throw AssertionError
308
- checker .put (map , pathA , artifactC , ConflictType .OTHER );
309
- assertThat (map .entrySet ()).containsExactly (Maps .immutableEntry (pathA , artifactC ));
310
- checkConflictError ();
311
- }
312
-
313
- @ Test
314
- public void testPutCatchesConflictBetweenNullAndNotNull () {
315
- ArtifactRoot root = ArtifactRoot .asSourceRoot (Root .fromPath (scratch .resolve ("/workspace" )));
316
- PathFragment pathA = PathFragment .create ("a" );
317
- Artifact artifactB = ActionsTestUtil .createArtifact (root , "b" );
318
- Map <PathFragment , Artifact > map = new LinkedHashMap <>();
319
-
320
- Runfiles .ConflictChecker checker = eventConflictChecker (Runfiles .ConflictPolicy .WARN );
321
- checker .put (map , pathA , null , ConflictType .OTHER );
322
- checker .put (map , pathA , artifactB , ConflictType .OTHER );
323
- assertThat (map .entrySet ()).containsExactly (Maps .immutableEntry (pathA , artifactB ));
324
- checkConflictWarning ();
325
- }
326
-
327
- @ Test
328
- public void testPutCatchesConflictBetweenNotNullAndNull () {
329
- ArtifactRoot root = ArtifactRoot .asSourceRoot (Root .fromPath (scratch .resolve ("/workspace" )));
330
- PathFragment pathA = PathFragment .create ("a" );
331
- Artifact artifactB = ActionsTestUtil .createArtifact (root , "b" );
332
- Map <PathFragment , Artifact > map = new LinkedHashMap <>();
333
-
334
- // Same as above but opposite order
335
- Runfiles .ConflictChecker checker = eventConflictChecker (Runfiles .ConflictPolicy .WARN );
336
- checker .put (map , pathA , artifactB , ConflictType .OTHER );
337
- checker .put (map , pathA , null , ConflictType .OTHER );
338
- assertThat (map .entrySet ()).containsExactly (Maps .immutableEntry (pathA , null ));
339
- checkConflictWarning ();
340
- }
341
-
342
- @ Test
343
- public void testPutIgnoresConflict () {
344
- ArtifactRoot root = ArtifactRoot .asSourceRoot (Root .fromPath (scratch .resolve ("/workspace" )));
345
- PathFragment pathA = PathFragment .create ("a" );
346
- Artifact artifactB = ActionsTestUtil .createArtifact (root , "b" );
347
- Artifact artifactC = ActionsTestUtil .createArtifact (root , "c" );
348
- Map <PathFragment , Artifact > map = new LinkedHashMap <>();
349
-
350
- Runfiles .ConflictChecker checker = eventConflictChecker (Runfiles .ConflictPolicy .IGNORE );
351
- checker .put (map , pathA , artifactB , ConflictType .OTHER );
352
- checker .put (map , pathA , artifactC , ConflictType .OTHER );
353
- assertThat (map .entrySet ()).containsExactly (Maps .immutableEntry (pathA , artifactC ));
354
- assertNoEvents ();
355
- }
356
-
357
- @ Test
358
- public void testPutIgnoresConflictWithIgnorePolicy () {
359
- ArtifactRoot root = ArtifactRoot .asSourceRoot (Root .fromPath (scratch .resolve ("/workspace" )));
360
- PathFragment pathA = PathFragment .create ("a" );
361
- Artifact artifactB = ActionsTestUtil .createArtifact (root , "b" );
362
- Artifact artifactC = ActionsTestUtil .createArtifact (root , "c" );
363
- Map <PathFragment , Artifact > map = new LinkedHashMap <>();
364
-
365
- Runfiles .ConflictChecker checker = eventConflictChecker (Runfiles .ConflictPolicy .IGNORE );
366
- checker .put (map , pathA , artifactB , ConflictType .OTHER );
367
- checker .put (map , pathA , artifactC , ConflictType .OTHER );
368
- assertThat (map .entrySet ()).containsExactly (Maps .immutableEntry (pathA , artifactC ));
369
- assertNoEvents ();
370
- }
371
-
372
- @ Test
373
- public void testPutIgnoresSameArtifact () {
374
- ArtifactRoot root = ArtifactRoot .asSourceRoot (Root .fromPath (scratch .resolve ("/workspace" )));
375
- PathFragment pathA = PathFragment .create ("a" );
376
- Artifact artifactB = ActionsTestUtil .createArtifact (root , "b" );
377
- Artifact artifactB2 = ActionsTestUtil .createArtifact (root , "b" );
378
- assertThat (artifactB2 ).isEqualTo (artifactB );
379
- Map <PathFragment , Artifact > map = new LinkedHashMap <>();
380
-
381
- Runfiles .ConflictChecker checker = eventConflictChecker (Runfiles .ConflictPolicy .WARN );
382
- checker .put (map , pathA , artifactB , ConflictType .OTHER );
383
- checker .put (map , pathA , artifactB2 , ConflictType .OTHER );
384
- assertThat (map .entrySet ()).containsExactly (Maps .immutableEntry (pathA , artifactB2 ));
385
- assertNoEvents ();
386
- }
387
-
388
- @ Test
389
- public void testPutIgnoresNullAndNull () {
390
- PathFragment pathA = PathFragment .create ("a" );
391
- Map <PathFragment , Artifact > map = new LinkedHashMap <>();
392
-
393
- Runfiles .ConflictChecker checker = eventConflictChecker (Runfiles .ConflictPolicy .WARN );
394
- checker .put (map , pathA , null , ConflictType .OTHER );
395
- // Add it again
396
- checker .put (map , pathA , null , ConflictType .OTHER );
397
- assertThat (map .entrySet ()).containsExactly (Maps .immutableEntry (pathA , null ));
398
- assertNoEvents ();
399
- }
400
-
401
241
@ Test
402
242
public void testPutNoConflicts () {
403
243
ArtifactRoot root = ArtifactRoot .asSourceRoot (Root .fromPath (scratch .resolve ("/workspace" )));
@@ -409,11 +249,11 @@ public void testPutNoConflicts() {
409
249
Map <PathFragment , Artifact > map = new LinkedHashMap <>();
410
250
411
251
Runfiles .ConflictChecker checker = eventConflictChecker (Runfiles .ConflictPolicy .WARN );
412
- checker .put (map , pathA , artifactA , ConflictType . OTHER );
252
+ checker .put (map , pathA , artifactA );
413
253
// Add different artifact under different path
414
- checker .put (map , pathB , artifactB , ConflictType . OTHER );
254
+ checker .put (map , pathB , artifactB );
415
255
// Add artifact again under different path
416
- checker .put (map , pathC , artifactA , ConflictType . OTHER );
256
+ checker .put (map , pathC , artifactA );
417
257
assertThat (map .entrySet ())
418
258
.containsExactly (
419
259
Maps .immutableEntry (pathA , artifactA ),
@@ -495,31 +335,6 @@ public void testRunfileAdded() {
495
335
assertNoEvents ();
496
336
}
497
337
498
- // TODO(kchodorow): remove this once the default workspace name is always set.
499
- @ Test
500
- public void testConflictWithExternal () {
501
- ArtifactRoot root = ArtifactRoot .asSourceRoot (Root .fromPath (scratch .resolve ("/workspace" )));
502
- PathFragment pathB = PathFragment .create ("repo/b" );
503
- PathFragment externalLegacyPath = LabelConstants .EXTERNAL_PATH_PREFIX .getRelative (pathB );
504
- PathFragment externalRunfilesPathB =
505
- LabelConstants .EXTERNAL_RUNFILES_PATH_PREFIX .getRelative (pathB );
506
- Artifact artifactB = ActionsTestUtil .createArtifactWithRootRelativePath (root , pathB );
507
- Artifact artifactExternalB =
508
- ActionsTestUtil .createArtifactWithRootRelativePath (root , externalLegacyPath );
509
-
510
- Runfiles .ManifestBuilder builder = new Runfiles .ManifestBuilder (
511
- PathFragment .EMPTY_FRAGMENT , false );
512
-
513
- Map <PathFragment , Artifact > inputManifest =
514
- ImmutableMap .of (pathB , artifactB , externalRunfilesPathB , artifactExternalB );
515
- Runfiles .ConflictChecker checker = eventConflictChecker (Runfiles .ConflictPolicy .WARN );
516
- builder .addUnderWorkspace (inputManifest , checker );
517
-
518
- assertThat (builder .build ().entrySet ()).containsExactly (
519
- Maps .immutableEntry (PathFragment .create ("repo/b" ), artifactExternalB ));
520
- checkConflictWarning ();
521
- }
522
-
523
338
@ Test
524
339
public void testMergeWithSymlinks () throws Exception {
525
340
ArtifactRoot root = ArtifactRoot .asSourceRoot (Root .fromPath (scratch .resolve ("/workspace" )));
0 commit comments