1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc
.squirreljme
.plugin
.multivm
;
12 import cc
.squirreljme
.plugin
.multivm
.ident
.SourceTargetClassifier
;
13 import cc
.squirreljme
.plugin
.util
.SingleTaskOutputFile
;
14 import javax
.inject
.Inject
;
16 import org
.gradle
.api
.DefaultTask
;
17 import org
.gradle
.api
.tasks
.Internal
;
18 import org
.gradle
.workers
.WorkerExecutor
;
21 * Used to test the virtual machine, generates test results from the run.
25 public class VMLegacyTestTask
27 implements VMBaseTask
, VMExecutableTask
29 /** Property for running single test. */
30 public static final String SINGLE_TEST_PROPERTY
=
33 /** Second property for test. */
34 public static final String SINGLE_TEST_PROPERTY_B
=
37 /** The classifier used. */
40 protected final SourceTargetClassifier classifier
;
43 * Initializes the task.
45 * @param __executor The executor for the task.
46 * @param __classifier The classifier used.
47 * @param __libTask The task used to create libraries, this may be directly
52 public VMLegacyTestTask(WorkerExecutor __executor
,
53 SourceTargetClassifier __classifier
, VMLibraryTask __libTask
)
54 throws NullPointerException
56 if (__executor
== null || __classifier
== null || __libTask
== null)
57 throw new NullPointerException("NARG");
59 // These are used at the test stage
60 this.classifier
= __classifier
;
62 // Set details of this task
63 this.setGroup("squirreljme");
64 this.setDescription("Runs the various automated tests (legacy).");
66 // Depends on the library to exist first along with the emulator
68 this.dependsOn(this.getProject().provider(
69 new VMRunDependencies(this.getProject(), __classifier
)),
70 new VMEmulatorDependencies(this.getProject(),
71 __classifier
.getTargetClassifier()));
73 // Add the entire JAR as input, so that if it changes for any reason
74 // then all tests should be considered invalid and rerun
75 // All the input source files to be tested
76 this.getInputs().files(
77 this.getProject().provider(
78 new SingleTaskOutputFile(__libTask
)),
79 this.getProject().provider(
80 new VMTestInputs(this, __classifier
.getSourceSet())));
82 // All the test results that are created
83 this.getOutputs().files(this.getProject().provider(
84 new VMTestOutputs(this, __classifier
)));
86 // Add additional testing to see if our test run will not be up-to-
87 // date when we run these. Also, this is never up-to-date if
88 // test.single/single.test is used because we do not want to
89 // interfere with the caching or not running tests in such
91 this.getOutputs().upToDateWhen((__task
) ->
93 return new VMRunUpToDateWhen(__classifier
)
94 .isSatisfiedBy(__task
) &&
95 !VMHelpers
.runningTests(__task
.getProject(),
96 __classifier
.getSourceSet()).isSingle
;
99 // Only run if there are actual tests to run
100 this.onlyIf(new CheckForTests(__classifier
.getSourceSet()));
102 // Performs the action of the task
103 this.doLast(new VMTestTaskAction(__executor
, __classifier
));