Skip to content

Commit

Permalink
[7.1.0] Remove unnecessary test assertions to fix flakiness. (#21354)
Browse files Browse the repository at this point in the history
After
df07d27,
the tree artifact contents are traversed in nondeterministic order.
These test cases only care whether the exception was propagated.

PiperOrigin-RevId: 606983523
Change-Id: I62441b5a0ae48d202947684f87f8928a63b9d070
  • Loading branch information
tjgq authored Feb 14, 2024
1 parent a7a89fe commit ffd0a27
Showing 1 changed file with 2 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -476,20 +476,10 @@ public void visitTree_throwsOnSymlinkPointingOutsideTree() throws Exception {
Path treeDir = scratch.dir("tree");
scratch.file("outside");
scratch.resolve("tree/link").createSymbolicLink(PathFragment.create("../outside"));
List<Pair<PathFragment, Dirent.Type>> children = new ArrayList<>();

Exception e =
assertThrows(
IOException.class,
() ->
TreeArtifactValue.visitTree(
treeDir,
(child, type) -> {
synchronized (children) {
children.add(Pair.of(child, type));
}
}));
assertThat(children).containsExactly(Pair.of(PathFragment.create(""), Dirent.Type.DIRECTORY));
IOException.class, () -> TreeArtifactValue.visitTree(treeDir, (child, type) -> {}));
assertThat(e).hasMessageThat().contains("/tree/link pointing to ../outside");
}

Expand All @@ -498,23 +488,10 @@ public void visitTree_throwsOnSymlinkTraversingOutsideThenBackInsideTree() throw
Path treeDir = scratch.dir("tree");
scratch.file("tree/file");
scratch.resolve("tree/link").createSymbolicLink(PathFragment.create("../tree/file"));
List<Pair<PathFragment, Dirent.Type>> children = new ArrayList<>();

Exception e =
assertThrows(
IOException.class,
() ->
TreeArtifactValue.visitTree(
treeDir,
(child, type) -> {
synchronized (children) {
children.add(Pair.of(child, type));
}
}));
assertThat(children)
.containsExactly(
Pair.of(PathFragment.create(""), Dirent.Type.DIRECTORY),
Pair.of(PathFragment.create("file"), Dirent.Type.FILE));
IOException.class, () -> TreeArtifactValue.visitTree(treeDir, (child, type) -> {}));
assertThat(e).hasMessageThat().contains("/tree/link pointing to ../tree/file");
}

Expand Down

0 comments on commit ffd0a27

Please sign in to comment.