package dev.caskeleton.buildlogic.strictlane; import java.io.File; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; import org.gradle.api.Action; import org.gradle.api.Named; import org.gradle.api.tasks.testing.Test; public class StrictTestLaneSpec implements Named { private final String name; private String tag; private String description; private String group; private String sourceSet = "test"; private String maxHeapSize; private boolean rejectSkipped; private boolean mainStage; private String explicitOnlyReason; private TestLaneCategory category = TestLaneCategory.TEST; private final List requiredTests = new ArrayList<>(); private final List jvmArgs = new ArrayList<>(); private final List shouldRunAfter = new ArrayList<>(); private final List dependsOn = new ArrayList<>(); private final List inputDirectories = new ArrayList<>(); private final Map systemProperties = new LinkedHashMap<>(); private Action customize; public StrictTestLaneSpec(String name) { this.name = Objects.requireNonNull(name, "name"); } @Override public String getName() { return name; } public String getTag() { return tag; } public void setTag(String tag) { this.tag = tag; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getGroup() { return group; } public void setGroup(String group) { this.group = group; } public String getSourceSet() { return sourceSet; } public void setSourceSet(String sourceSet) { this.sourceSet = sourceSet; } public String getMaxHeapSize() { return maxHeapSize; } public void setMaxHeapSize(String maxHeapSize) { this.maxHeapSize = maxHeapSize; } public boolean isRejectSkipped() { return rejectSkipped; } public void setRejectSkipped(boolean rejectSkipped) { this.rejectSkipped = rejectSkipped; } public boolean isMainStage() { return mainStage; } /** * Runs this lane in the leaf's {@code mainCheck} instead of its {@code test}: the lane's tag is * excluded from {@code test}. For checks that compare a leaf with documents or registries, which * are not worth a pull request's wait (review 2026-09-24 BUILD-계획-B4-27). */ public void mainStage() { mainStage = true; } public String getExplicitOnlyReason() { return explicitOnlyReason; } /** * Keeps this lane out of every aggregate ({@code strictTestLaneCheck}, {@code * integrationTestLaneCheck}, ...): it runs only when named. For a lane that cannot pass without * an input the aggregate's caller does not have — protected credentials, an external topology — * so that the aggregate states the gap instead of failing on it (review NEW-16). */ public void explicitOnly(String reason) { explicitOnlyReason = Objects.requireNonNull(reason, "reason"); } public TestLaneCategory getCategory() { return category; } public void setCategory(TestLaneCategory category) { this.category = Objects.requireNonNull(category, "category"); } public void test() { category = TestLaneCategory.TEST; } public void integration() { category = TestLaneCategory.INTEGRATION; } public void system() { category = TestLaneCategory.SYSTEM; } public void architecture() { category = TestLaneCategory.ARCHITECTURE; } /** * A lane whose tests are resource or latency bounds. Besides rerunning every time and taking the * build-wide real-server slot, it rejects skipped tests and always runs with its bounds asserted: * the convention sets {@code performance.assertions.enabled=true}, and a build or lane that sets * it to anything else fails before a test runs. */ public void performance() { category = TestLaneCategory.PERFORMANCE; } public List getRequiredTests() { return List.copyOf(requiredTests); } public void requires(String... selectors) { requiredTests.addAll(List.of(selectors)); } public List getJvmArgs() { return List.copyOf(jvmArgs); } public void jvmArgs(String... arguments) { jvmArgs.addAll(List.of(arguments)); } public List getShouldRunAfter() { return List.copyOf(shouldRunAfter); } public void shouldRunAfter(String... taskNames) { shouldRunAfter.addAll(List.of(taskNames)); } public List getDependsOn() { return List.copyOf(dependsOn); } public void dependsOn(String... taskNames) { dependsOn.addAll(List.of(taskNames)); } public Map getSystemProperties() { return Map.copyOf(systemProperties); } public void systemProperty(String name, String value) { systemProperties.put(Objects.requireNonNull(name, "name"), Objects.requireNonNull(value, "value")); } public List getInputDirectories() { return List.copyOf(inputDirectories); } public void inputDirectory(File directory) { inputDirectories.add(Objects.requireNonNull(directory, "directory")); } public Action getCustomize() { return customize; } public void setCustomize(Action customize) { this.customize = customize; } public void customize(Action customize) { this.customize = customize; } }