|
136 | 136 | import java.util.Map;
|
137 | 137 | import java.util.Objects;
|
138 | 138 | import java.util.Set;
|
| 139 | +import java.util.concurrent.atomic.AtomicBoolean; |
139 | 140 | import java.util.function.Consumer;
|
140 | 141 | import java.util.function.Predicate;
|
141 | 142 | import java.util.function.Supplier;
|
@@ -682,7 +683,7 @@ public void registerTestBinary(Project project,
|
682 | 683 | test.systemProperty(JUNIT_PLATFORM_LISTENERS_UID_TRACKING_ENABLED, true);
|
683 | 684 |
|
684 | 685 | // Set system property to skip execution of JVM tests before native tests
|
685 |
| - if (shouldSkipJVMTests(testOptions.getSkipJVMTests().get())) { |
| 686 | + if (shouldSkipJVMTests(project, testOptions.getSkipJVMTests())) { |
686 | 687 | if (graalExtension.getAgent().getEnabled().get()) {
|
687 | 688 | throw new IllegalStateException("Native Image Agent and skipJVMTests cannot be used at the same time.");
|
688 | 689 | }
|
@@ -724,13 +725,44 @@ public void registerTestBinary(Project project,
|
724 | 725 | });
|
725 | 726 | }
|
726 | 727 |
|
727 |
| - private boolean shouldSkipJVMTests(boolean valueFromBuildFile) { |
| 728 | + private boolean isNativeTestTask(Project project) { |
| 729 | + List<String> userCalledTasks = project.getGradle().getStartParameter().getTaskNames(); |
| 730 | + for (var task : userCalledTasks) { |
| 731 | + if (task.contains("native") && task.contains("Test")) { |
| 732 | + return true; |
| 733 | + } |
| 734 | + } |
| 735 | + |
| 736 | + return false; |
| 737 | + } |
| 738 | + private boolean shouldSkipJVMTests(Project project, Property<Boolean> valueFromBuildFile) { |
728 | 739 | String valueFromCommandLine = System.getProperty("skipJVMTests");
|
729 |
| - if (valueFromCommandLine == null) { |
730 |
| - return valueFromBuildFile; |
| 740 | + if (valueFromCommandLine != null) { |
| 741 | + // value explicitly set through system property (command line) |
| 742 | + boolean val = Boolean.parseBoolean(valueFromCommandLine); |
| 743 | + logger.log("Skipping JVM tests execution explicitly set to " + val + " using system property"); |
| 744 | + |
| 745 | + return val; |
| 746 | + } |
| 747 | + |
| 748 | + if (valueFromBuildFile.isPresent()) { |
| 749 | + // value explicitly set through build file |
| 750 | + boolean val = valueFromBuildFile.get(); |
| 751 | + logger.log("Skipping JVM tests execution explicitly set to " + val + " using build file"); |
| 752 | + |
| 753 | + return val; |
| 754 | + } |
| 755 | + |
| 756 | + List<String> userCalledTasks = project.getGradle().getStartParameter().getTaskNames(); |
| 757 | + for (String task : userCalledTasks) { |
| 758 | + if (task.contains("native") && task.contains("Test")) { |
| 759 | + logger.log("Task " + task + " sets skipping JVM tests execution to true"); |
| 760 | + |
| 761 | + return true; |
| 762 | + } |
731 | 763 | }
|
732 | 764 |
|
733 |
| - return Boolean.parseBoolean(valueFromCommandLine); |
| 765 | + return false; |
734 | 766 | }
|
735 | 767 |
|
736 | 768 | /**
|
|
0 commit comments