Skip to content

Commit

Permalink
Merge pull request swiftlang#25806 from benlangmuir/editor-test-race
Browse files Browse the repository at this point in the history
[test] Fix race in EditTest.DiagsAfterReopen
  • Loading branch information
benlangmuir authored Jun 27, 2019
2 parents 565f1b3 + e5e4d80 commit ebc5d76
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 ebc5d76

Please sign in to comment.