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

Fix incorrect declaration of output directory #219

Merged
merged 1 commit into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
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 @@ -253,4 +253,38 @@ class JavaApplicationWithTestsFunctionalTest extends AbstractFunctionalTest {
where:
junitVersion = System.getProperty('versions.junit')
}

@Issue("https://github.com/graalvm/native-build-tools/issues/218")
def "test list directory output is properly configured"() {
given:
withSample("java-application-with-tests")

buildFile << """
tasks.register("otherTest", Test) {
classpath = tasks.test.classpath
testClassesDirs = tasks.test.testClassesDirs
}
"""

when:
run 'test'

then:
file("build/test-results/test/testlist").isDirectory()
!file("build/test-results/otherTest/testlist").isDirectory()

when:
run 'otherTest'

then:
!file("build/test-results/otherTest/testlist").isDirectory()

when:
run 'test'

then:
tasks {
upToDate(':test')
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.JavaExec;
import org.gradle.api.tasks.PathSensitive;
import org.gradle.api.tasks.PathSensitivity;
import org.gradle.api.tasks.OutputDirectory;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.TaskContainer;
Expand All @@ -96,8 +94,8 @@
import org.gradle.api.tasks.testing.Test;
import org.gradle.jvm.toolchain.JavaToolchainService;
import org.gradle.language.base.plugins.LifecycleBasePlugin;
import org.gradle.process.ExecOperations;
import org.gradle.process.CommandLineArgumentProvider;
import org.gradle.process.ExecOperations;
import org.gradle.process.JavaForkOptions;
import org.gradle.util.GFileUtils;

Expand Down Expand Up @@ -380,8 +378,9 @@ public void registerTestBinary(Project project,
TaskProvider<Test> testTask = config.validate().getTestTask();
testOptions.getAgent().getInstrumentedTask().set(testTask);
testTask.configure(test -> {
testListDirectory.set(new File(testResultsDir, test.getName() + "/testlist"));
test.getOutputs().dir(testResultsDir);
File testList = new File(testResultsDir, test.getName() + "/testlist");
testListDirectory.set(testList);
test.getOutputs().dir(testList);
// Set system property read by the UniqueIdTrackingListener.
test.systemProperty(JUNIT_PLATFORM_LISTENERS_UID_TRACKING_ENABLED, true);
TrackingDirectorySystemPropertyProvider directoryProvider = project.getObjects().newInstance(TrackingDirectorySystemPropertyProvider.class);
Expand Down Expand Up @@ -588,8 +587,7 @@ public void execute(Task task) {
}

public abstract static class TrackingDirectorySystemPropertyProvider implements CommandLineArgumentProvider {
@InputFiles
@PathSensitive(PathSensitivity.RELATIVE)
@OutputDirectory
public abstract DirectoryProperty getDirectory();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@ abstract class AbstractFunctionalTest extends Specification {
}
}

void upToDate(String... tasks) {
tasks.each { task ->
contains(task)
assert result.task(task).outcome == TaskOutcome.UP_TO_DATE
}
}

void contains(String... tasks) {
tasks.each { task ->
assert result.task(task) != null: "Expected to find task $task in the graph but it was missing"
Expand Down