Skip to content

Commit

Permalink
[bndtools test] Extra debugging prints to debug startup race condition
Browse files Browse the repository at this point in the history
Signed-off-by: Fr Jeremy Krieg <fr.jkrieg@greekwelfaresa.org.au>
  • Loading branch information
kriegfrj committed Nov 14, 2023
1 parent 9dd7db6 commit 5a6f3be
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.assertj.core.api.Assertions;
import org.assertj.core.api.Condition;
Expand Down Expand Up @@ -886,21 +887,32 @@ private void assertImports(Import... imports) {
// it depends) doesn't honour the test=true attribute, which breaks
// a number of the tests above that are trying to test that
// behavior. Need the full JavaBuilder behaviour to get that.
TaskUtils.buildIncremental("Added ICU");
TaskUtils.buildIncremental("Added ICU for cfompilation");

final int problemCount = (int) Arrays.stream(imports)
.filter(x -> x.problem != 0)
.count();
IMarker[] workspaceProbs = icu.getJavaProject()
.getProject()
.getParent()
.findMarkers(null, true, IResource.DEPTH_INFINITE);
System.err.println("workspace problems: " + Stream.of(workspaceProbs)
.map(Object::toString)
.collect(Collectors.joining(",\n")));
IMarker[] problems = icu.getResource()
.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_ZERO);
Arrays.sort(problems, BY_LINE);

if (problems.length != problemCount) {
softly.fail(
"%nExpecting code:%n%s%n%s%n---%nto have:%n <%d>%nproblems, but it has:%n <%d>%nProblems:%n %s",
"%nExpecting code:%n%s%n%s%n---%nto have:%n <%d>%nproblems, but it has:%n <%d>%nThe problems:%n %s",
icu.getPath(), indent(source), problemCount, problems.length, Arrays.stream(problems)
.map(BndContainerInitializerTest::markerToString)
.collect(Collectors.joining(",\n ")));
System.err.println(Arrays.toString(icu.getJavaProject()
.getRawClasspath()));
// System.err.println(Arrays.toString(icu.getJavaProject()
// .getResolvedClasspath(false)));
} else {
int problem = 0;
AtomicBoolean hadFailures = new AtomicBoolean(false);
Expand All @@ -912,6 +924,7 @@ private void assertImports(Import... imports) {
continue;
}
IMarker p = problems[problem++];
try {
softly.assertThat(p)
.as(imp.desc + " (" + imp.pack + ")")
.hasType(JavaProblemMarkerAssert.JAVA_PROBLEM);
Expand All @@ -921,6 +934,11 @@ private void assertImports(Import... imports) {
.as(imp.desc + " (" + imp.pack + ")")
.hasProblemID(imp.problem)
.hasLineNumber(i + 2);
} catch (Exception e) {
if (e instanceof CoreException ce) {
System.err.println("ce status: " + ce.getStatus());
}
}
}
if (hadFailures.get()) {
softly.fail("\nFull list of markers: " + Arrays.stream(problems)
Expand Down

0 comments on commit 5a6f3be

Please sign in to comment.