1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // Multi-Phasic Applications: SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
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 java
.io
.IOException
;
14 import java
.util
.Collections
;
15 import java
.util
.LinkedHashMap
;
16 import java
.util
.List
;
18 import javax
.inject
.Inject
;
20 import org
.gradle
.api
.Action
;
21 import org
.gradle
.api
.internal
.tasks
.testing
.TestFramework
;
22 import org
.gradle
.api
.internal
.tasks
.testing
.WorkerTestClassProcessorFactory
;
23 import org
.gradle
.api
.internal
.tasks
.testing
.detection
.TestFrameworkDetector
;
24 import org
.gradle
.api
.tasks
.Internal
;
25 import org
.gradle
.api
.tasks
.testing
.TestFrameworkOptions
;
26 import org
.gradle
.process
.internal
.worker
.WorkerProcessBuilder
;
29 * Test framework for SquirrelJME.
33 public class VMTestFramework
34 implements TestFramework
36 /** The name of this framework. */
37 public final String declaredDisplayName
=
38 "SquirrelJME Test Framework";
40 /** Is this framework immutable? */
42 public final boolean immutable
=
48 protected final VMModernTestTask task
;
50 /** The classifier. */
53 protected final SourceTargetClassifier classifier
;
56 * Initializes the test framework.
58 * @param __vmTestTask The test task we are using.
59 * @param __classifier The classifier to use.
63 public VMTestFramework(VMModernTestTask __vmTestTask
,
64 SourceTargetClassifier __classifier
)
66 this.task
= __vmTestTask
;
67 this.classifier
= __classifier
;
85 public TestFrameworkDetector
getDetector()
87 return new VMTestFrameworkDetector(
88 VMHelpers
.runningTests(this.task
.getProject(),
89 this.classifier
.getSourceSet()).tests
);
93 * Is this an immutable test framework?
95 * @return If this is immutable.
98 public boolean getImmutable()
100 return this.immutable
;
108 public TestFrameworkOptions
getOptions()
110 return new TestFrameworkOptions();
118 public WorkerTestClassProcessorFactory
getProcessorFactory()
120 // Get the tests we are going to run, since we need to calculate how
121 // to run the test, and everything must be serialized through it
122 Map
<String
, CandidateTestFiles
> tests
= VMHelpers
.runningTests(
123 this.task
.getProject(), this.classifier
.getSourceSet()).tests
;
125 // Determine setup for general suite runs
126 SuiteRunParameters runSuite
= VMTestTaskAction
.runSuite(this.task
,
129 // Calculate run parameters for each test
130 Map
<String
, TestRunParameters
> runParams
= new LinkedHashMap
<>();
131 for (Map
.Entry
<String
, CandidateTestFiles
> test
: tests
.entrySet())
132 runParams
.put(test
.getKey(), VMTestTaskAction
.runTest(this.task
,
133 this.classifier
, runSuite
, test
.getKey(),
136 // Run the processor, this must be serializable
137 return new VMTestFrameworkWorkerTestClassProcessorFactory(
138 tests
, runParams
, this.task
.getProject().getName());
146 public Action
<WorkerProcessBuilder
> getWorkerConfigurationAction()
148 return new VMTestFrameworkWorkerConfigurationAction();
156 public List
<String
> getTestWorkerImplementationModules()
158 // No modules are used
159 return Collections
.emptyList();