Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saner test event logging default for CI #1576

Merged
merged 4 commits into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions changelog/@unreleased/pr-1576.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: fix
fix:
description: Print more test logging output to avoid builds with long running tests
getting terminated by circle ("context deadline exceeded").
links:
- https://github.com/palantir/gradle-baseline/pull/1576
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.palantir.baseline.plugins;

import com.google.common.collect.ImmutableSet;
import com.palantir.baseline.tasks.CheckJUnitDependencies;
import com.palantir.baseline.tasks.CheckUnusedDependenciesTask;
import java.util.Objects;
Expand All @@ -32,6 +33,7 @@
import org.gradle.api.tasks.TaskProvider;
import org.gradle.api.tasks.testing.Test;
import org.gradle.api.tasks.testing.junitplatform.JUnitPlatformOptions;
import org.gradle.api.tasks.testing.logging.TestLogEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -140,8 +142,17 @@ private static void enableJunit5ForTestTask(Test task) {
// Computes the desired parallelism based on the number of available processors/cores
task.systemProperty("junit.jupiter.execution.parallel.config.strategy", "dynamic");

// provide some stdout feedback when tests fail
task.testLogging(testLogging -> testLogging.events("failed"));
// provide some stdout feedback when tests fail when running on CI and locally
task.getTestLogging().getEvents().add(TestLogEvent.FAILED);

// Only on CI, print out more detailed test information to avoid hitting the circleci 10 min deadline if
// there are lots of tests. Don't do this locally to avoid spamming massive amount of info for people running
// unit tests through the command line
if ("true".equals(System.getenv("CI"))) {
task.getTestLogging()
Copy link
Contributor

Choose a reason for hiding this comment

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

@CRogers can we try to not apply this to the ./gradlew test tasks which are normally just unit-tests??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I have a commit to do this actually, I was just distracted by testing it on c-v-s that had the silently not running tests problem :p

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed

.getEvents()
.addAll(ImmutableSet.of(TestLogEvent.STARTED, TestLogEvent.PASSED, TestLogEvent.SKIPPED));
}
}

public static boolean useJUnitPlatformEnabled(Test task) {
Expand Down