Skip to content

Commit

Permalink
[test] Fix race in EditTest.DiagsAfterReopen
Browse files Browse the repository at this point in the history
We weren't accounting for the possibility that the AST would build
faster than we could return editorOpen. While that is very unlikely, we
hit a CI failure at least once.

rdar://52211324
  • Loading branch information
benlangmuir committed Jun 26, 2019
1 parent 114f473 commit e5e4d80
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions unittests/SourceKit/SwiftLang/EditingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,27 @@ void EditTest::doubleOpenWithDelay(std::chrono::microseconds delay,

DiagConsumer Consumer;
open(DocName, Contents, Args, Consumer);
ASSERT_EQ(0u, Consumer.Diags.size());
ASSERT_LE(Consumer.Diags.size(), 1u);
if (Consumer.Diags.size() > 0) {
EXPECT_EQ(SemaDiagStage, Consumer.DiagStage);
Consumer.Diags.clear();
Consumer.DiagStage = UIdent();
}

// Open again without closing; this reinitializes the semantic info on the doc
if (delay > std::chrono::microseconds(0))
std::this_thread::sleep_for(delay);
if (closeDoc)
close(DocName);
reset(Consumer);

open(DocName, Contents, Args, Consumer);
ASSERT_EQ(0u, Consumer.Diags.size());
ASSERT_LE(Consumer.Diags.size(), 1u);
if (Consumer.Diags.size() > 0) {
EXPECT_EQ(SemaDiagStage, Consumer.DiagStage);
Consumer.Diags.clear();
Consumer.DiagStage = UIdent();
}

// Wait for the document update from the second time we open the document. We
// may or may not get a notification from the first time it was opened, but
Expand Down

0 comments on commit e5e4d80

Please sign in to comment.