Skip to content

Commit

Permalink
Merge pull request apache#6665 from mbien/stabilize-php-tag-folding-test
Browse files Browse the repository at this point in the history
Fix php tag fold test (attempt 2)
  • Loading branch information
mbien authored Nov 7, 2023
2 parents 0c8313e + 49cda01 commit 54b5d2a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2146,13 +2146,6 @@ protected void checkFolds(String relFilePath) throws Exception {
ParserManager.parse(Collections.singleton(testSource), new UserTask() {
public @Override void run(ResultIterator resultIterator) throws Exception {

// FoldingScanner#folds calls source.getDocument(false) and receive non null values on JDK 8.
// On JDK 11+ however the document is null which leads to test failures in FoldingTest#testPHPTags.
// This is likely a race condition which is more likely to occur on JDK 11+ since the test can be
// brute forced to passing on linux if restarted often enough.
// This fixes it by making sure the document is open before folds are computed
assertNotNull(resultIterator.getSnapshot().getSource().getDocument(true));

StructureScanner analyzer = getStructureScanner();
assertNotNull("getStructureScanner must be implemented", analyzer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public Map<String, List<OffsetRange>> folds(ParserResult info) {
program.accept(new FoldingVisitor(folds));
Source source = phpParseResult.getSnapshot().getSource();
assert source != null : "source was null";
Document doc = source.getDocument(false);
Document doc = source.getDocument(true);
if (FOLD_PHPTAG) {
processPHPTags(folds, doc);
}
Expand Down

0 comments on commit 54b5d2a

Please sign in to comment.