Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,13 @@ static boolean isFullJavaId(String possibleNewRunningTestClass) {
}
if (null != outputDir) {
createSession(outputDir);
project2outputDirs.put(visitor.getContext().getCurrentProject(), outputDir);
OutputVisitor.Context context = visitor.getContext();
if (context != null) {
Project currentProject = context.getCurrentProject();
if (currentProject != null) {
Comment on lines +319 to +322
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: you could cover both with one if chained with && like in the other comment. Those are pure field accessors with no extra code so it is ok to call them twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is not final so the current idiom seems safer in the face of potential concurrent modifications.

project2outputDirs.put(currentProject, outputDir);
}
}
}
}
}
Expand All @@ -325,10 +331,13 @@ private String getReportsDirectory(String groupId, String artifactId, String goa
MavenProject currentProject = null;
// get maven module from context if available
OutputVisitor.Context context = visitor.getContext();
if (context != null && context.getCurrentProject() != null) {
NbMavenProject subProject = context.getCurrentProject().getLookup().lookup(NbMavenProject.class);
if (subProject != null) {
currentProject = subProject.getMavenProject();
if (context != null) {
Project cp = context.getCurrentProject();
if (cp != null) {
NbMavenProject subProject = cp.getLookup().lookup(NbMavenProject.class);
if (subProject != null) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Ignore whitespace changes to review.)

currentProject = subProject.getMavenProject();
}
}
}
if (currentProject == null) {
Expand Down Expand Up @@ -590,12 +599,20 @@ private boolean usingJUnit4(MavenProject prj) { // SUREFIRE-724
if (runningTestClass != null) {
generateTest();
}
File outputDir = project2outputDirs.remove(visitor.getContext().getCurrentProject());
TestSession session = outputDir != null ? outputDir2sessions.remove(outputDir) : null;
if (session != null) {
CoreManager junitManager = getManagerProvider();
if (junitManager != null) {
junitManager.sessionFinished(session);
OutputVisitor.Context context = visitor.getContext();
if (context != null) {
Project currentProject = context.getCurrentProject();
if (currentProject != null) {
File outputDir = project2outputDirs.remove(currentProject);
if (outputDir != null) {
TestSession session = outputDir2sessions.remove(outputDir);
if (session != null) {
CoreManager junitManager = getManagerProvider();
if (junitManager != null) {
junitManager.sessionFinished(session);
}
}
}
}
}
runningTestClass = null;
Expand Down Expand Up @@ -633,28 +650,31 @@ static Trouble constructTrouble(@NonNull String type, @NullAllowed String messag
}

public @Override void sequenceFail(String sequenceId, OutputVisitor visitor) {
LOG.log(Level.FINE, "Got sequenceFail: {0}, line {1}", new Object[] { visitor.getContext().getCurrentProject(), visitor.getLine() });
// try to get the failed test class. How can this be solved if it is not the first one in the list?
if(surefireRunningInParallel) {
String saveRunningTestClass = runningTestClass;

Project currentProject = visitor.getContext().getCurrentProject();
for (String s : runningTestClassesInParallel) {
File outputDir = locateOutputDirAndWait(s, false);
// match the output dir to the project
if (outputDir != null) {
Project outputOwner = FileOwnerQuery.getOwner(FileUtil.toFileObject(outputDir));
if (outputOwner == currentProject) {
LOG.log(Level.FINE, "Found unfinished test {0} in {1}, trying to finish", new Object[] { s, currentProject });
runningTestClass = s;
if (Objects.equals(saveRunningTestClass, s)) {
saveRunningTestClass = null;
OutputVisitor.Context context = visitor.getContext();
if (context != null) {
Project currentProject = context.getCurrentProject();
LOG.log(Level.FINE, "Got sequenceFail: {0}, line {1}", new Object[] {currentProject, visitor.getLine()});
// try to get the failed test class. How can this be solved if it is not the first one in the list?
if (currentProject != null && surefireRunningInParallel) {
String saveRunningTestClass = runningTestClass;

for (String s : runningTestClassesInParallel) {
File outputDir = locateOutputDirAndWait(s, false);
// match the output dir to the project
if (outputDir != null) {
Project outputOwner = FileOwnerQuery.getOwner(FileUtil.toFileObject(outputDir));
if (outputOwner == currentProject) {
LOG.log(Level.FINE, "Found unfinished test {0} in {1}, trying to finish", new Object[] {s, currentProject});
runningTestClass = s;
if (Objects.equals(saveRunningTestClass, s)) {
saveRunningTestClass = null;
}
generateTest();
}
generateTest();
}
}
runningTestClass = saveRunningTestClass;
}
runningTestClass = saveRunningTestClass;
}
sequenceEnd(sequenceId, visitor);
}
Expand Down
Loading