Commit 25d603e3 authored by Stephanie Gawroriski's avatar Stephanie Gawroriski
Browse files

Cherry pick from wip-ratufarefactor the ability to do full setups with tests;...

Cherry pick from wip-ratufarefactor the ability to do full setups with tests; Correct direction of test result comparison; Update CircleCI Docker image; Do not create test libraries if modules have no tests in them, this should reduce wasted size and time spent compiling; Add long-ignore-sign for logarithms since it can differ by JVMs but still be correct (results in NaN).
parent 39673520
Pipeline #109840 passed with stages
in 2 minutes and 15 seconds
......@@ -15,7 +15,7 @@ version: 2.1
executors:
buildenv:
docker:
- image: circleci/openjdk:8-jdk
- image: circleci/openjdk:11-jdk
orbs:
win: circleci/windows@2.4.0
......
......@@ -109,6 +109,11 @@ public class DeveloperNoteTask
for (;;)
try
{
// Stop the loop if we were interrupted
if (Thread.interrupted())
break;
// Otherwise wait for another packet
if (!server.next(this::__httpHandler))
break;
}
......@@ -125,7 +130,7 @@ public class DeveloperNoteTask
throw new RuntimeException("Server read/write error.", e);
}
// Store the note in the unversioned space, but only if saved
// Store the note in the un-versioned space, but only if saved
if (session._saveCount > 0)
exe.unversionedStoreBytes(filePath, session._content);
......@@ -234,6 +239,9 @@ public class DeveloperNoteTask
// Store into the session bytes
__session._content = data.getBytes(StandardCharsets.UTF_8);
__session._saveCount++;
// Note it down
System.out.println("Notes saved!");
}
// All done?
......
......@@ -154,7 +154,9 @@ public final class TaskInitialization
throw new NullPointerException("NARG");
for (VMType vmType : VMType.values())
TaskInitialization.initializeFullSuiteTask(__project, vmType);
for (String sourceSet : TaskInitialization._SOURCE_SETS)
TaskInitialization.initializeFullSuiteTask(__project,
sourceSet, vmType);
}
/**
......@@ -163,20 +165,22 @@ public final class TaskInitialization
* launching.
*
* @param __project The root project.
* @param __sourceSet Source set used.
* @param __vmType The virtual machine type.
* @throws NullPointerException On null arguments.
* @since 2020/10/17
*/
private static void initializeFullSuiteTask(Project __project,
VMType __vmType)
String __sourceSet, VMType __vmType)
throws NullPointerException
{
if (__project == null || __vmType == null)
if (__project == null || __sourceSet == null || __vmType == null)
throw new NullPointerException("NARG");
// Standard ROM
__project.getTasks().create(
TaskInitialization.task("full", "", __vmType),
VMFullSuite.class, __vmType);
TaskInitialization.task("full", __sourceSet, __vmType),
VMFullSuite.class, __sourceSet, __vmType);
}
/**
......@@ -225,33 +229,51 @@ public final class TaskInitialization
}
/**
* Builds a name for a task.
* Builds a name for a task, without the virtual machine type.
*
* @param __name The task name.
* @param __sourceSet The source set for the task base.
* @param __vmType The type of virtual machine used.
* @return A string representing the task.
* @throws NullPointerException On null arguments.
* @since 2020/08/07
* @since 2021/12/19
*/
public static String task(String __name, String __sourceSet,
VMSpecifier __vmType)
public static String task(String __name, String __sourceSet)
throws NullPointerException
{
if (__name == null || __sourceSet == null || __vmType == null)
if (__name == null || __sourceSet == null)
throw new NullPointerException("NARG");
// If this is the main source set, never include the source set as
// it becomes implied. Additionally if the name and the source set
// it becomes implied. Additionally, if the name and the source set
// are the same, reduce the confusion so there is no "testTestHosted".
if (__sourceSet.equals(SourceSet.MAIN_SOURCE_SET_NAME) ||
__sourceSet.equals(__name) || __sourceSet.isEmpty())
return __name + __vmType.vmName(VMNameFormat.PROPER_NOUN);
return __name;
// Otherwise include it
// Otherwise, include it
return __name +
Character.toUpperCase(__sourceSet.charAt(0)) +
__sourceSet.substring(1) +
__sourceSet.substring(1);
}
/**
* Builds a name for a task.
*
* @param __name The task name.
* @param __sourceSet The source set for the task base.
* @param __vmType The type of virtual machine used.
* @return A string representing the task.
* @throws NullPointerException On null arguments.
* @since 2020/08/07
*/
public static String task(String __name, String __sourceSet,
VMSpecifier __vmType)
throws NullPointerException
{
if (__name == null || __sourceSet == null || __vmType == null)
throw new NullPointerException("NARG");
return TaskInitialization.task(__name, __sourceSet) +
__vmType.vmName(VMNameFormat.PROPER_NOUN);
}
}
......@@ -37,18 +37,19 @@ public class VMFullSuite
/**
* Initializes the full suite task.
*
* @param __sourceSet The source set used.
* @param __vmType The virtual machine type.
* @throws NullPointerException On null arguments.
* @since 2020/10/17
*/
@Inject
public VMFullSuite(VMSpecifier __vmType)
public VMFullSuite(String __sourceSet, VMSpecifier __vmType)
throws NullPointerException
{
if (__vmType == null)
if (__vmType == null || __sourceSet == null)
throw new NullPointerException("NARG");
this.sourceSet = SourceSet.MAIN_SOURCE_SET_NAME;
this.sourceSet = __sourceSet;
this.vmType = __vmType;
// Runs the entire API/Library suite of SquirrelJME to run a given
......@@ -61,10 +62,11 @@ public class VMFullSuite
this.getOutputs().upToDateWhen(new AlwaysFalse());
// This depends on everything!
this.dependsOn(new VMFullSuiteDepends(this, __vmType),
this.dependsOn(
new VMFullSuiteDepends(this, __sourceSet, __vmType),
new VMEmulatorDependencies(this, __vmType));
// Actual running of everything
this.doLast(new VMFullSuiteTaskAction(__vmType));
this.doLast(new VMFullSuiteTaskAction(__sourceSet, __vmType));
}
}
......@@ -10,9 +10,11 @@
package cc.squirreljme.plugin.multivm;
import cc.squirreljme.plugin.SquirrelJMEPluginConfiguration;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.concurrent.Callable;
import org.gradle.api.Project;
import org.gradle.api.Task;
......@@ -29,6 +31,9 @@ public class VMFullSuiteDepends
/** The task to execute for. */
protected final Task task;
/** The source set used. */
protected final String sourceSet;
/** The virtual machine creating for. */
protected final VMSpecifier vmType;
......@@ -40,13 +45,15 @@ public class VMFullSuiteDepends
* @throws NullPointerException On null arguments.
* @since 2020/10/17
*/
public VMFullSuiteDepends(Task __task, VMSpecifier __vmType)
public VMFullSuiteDepends(Task __task, String __sourceSet,
VMSpecifier __vmType)
throws NullPointerException
{
if (__task == null || __vmType == null)
if (__task == null || __sourceSet == null || __vmType == null)
throw new NullPointerException("NARG");
this.task = __task;
this.sourceSet = __sourceSet;
this.vmType = __vmType;
}
......@@ -56,7 +63,6 @@ public class VMFullSuiteDepends
*/
@Override
public Iterable<Task> call()
throws Exception
{
Project root = this.task.getProject().getRootProject();
Collection<Task> tasks = new LinkedHashSet<>();
......@@ -68,6 +74,14 @@ public class VMFullSuiteDepends
if (emulJar != null)
tasks.add(emulJar);
// Which source sets should be used
List<String> sourceSets;
if (!this.sourceSet.equals(SourceSet.MAIN_SOURCE_SET_NAME))
sourceSets = Arrays.asList(SourceSet.MAIN_SOURCE_SET_NAME,
this.sourceSet);
else
sourceSets = Collections.singletonList(this.sourceSet);
// Go through every single project, and try to use it as a dependency
for (Project project : root.getAllprojects())
{
......@@ -77,18 +91,22 @@ public class VMFullSuiteDepends
if (config == null)
continue;
// Find the associated library task
Task libTask = project.getTasks().findByName(TaskInitialization
.task("lib", SourceSet.MAIN_SOURCE_SET_NAME,
this.vmType));
if (libTask == null)
continue;
// Use all of their dependencies, if not yet added
for (VMLibraryTask subDep : new VMRunDependencies(
(VMExecutableTask)libTask, SourceSet.MAIN_SOURCE_SET_NAME,
this.vmType).call())
tasks.add(subDep);
// Include whatever libraries are needed for the source set
for (String sourceSet : sourceSets)
{
// Find the associated library task
Task libTask = project.getTasks().findByName(TaskInitialization
.task("lib", sourceSet,
this.vmType));
if (libTask == null)
continue;
// Use all of their dependencies, if not yet added
for (VMLibraryTask subDep : new VMRunDependencies(
(VMExecutableTask)libTask, sourceSet,
this.vmType).call())
tasks.add(subDep);
}
}
return Collections.unmodifiableCollection(tasks);
......
......@@ -9,6 +9,7 @@
package cc.squirreljme.plugin.multivm;
import cc.squirreljme.plugin.util.UnassistedLaunchEntry;
import cc.squirreljme.plugin.util.GradleJavaExecSpecFiller;
import cc.squirreljme.plugin.util.GuardedOutputStream;
import java.io.File;
......@@ -38,23 +39,28 @@ public class VMFullSuiteTaskAction
public static final String LIBRARIES_PROPERTY =
"full.libraries";
/** The source set used. */
public final String sourceSet;
/** The virtual machine creating for. */
protected final VMSpecifier vmType;
/**
* Initializes the task.
*
* @param __sourceSet The source set.
* @param __vmType The VM to make a ROM for.
* @throws NullPointerException On null arguments.
* @since 2020/10/17
*/
public VMFullSuiteTaskAction(VMSpecifier __vmType)
public VMFullSuiteTaskAction(String __sourceSet, VMSpecifier __vmType)
throws NullPointerException
{
if (__vmType == null)
if (__vmType == null || __sourceSet == null)
throw new NullPointerException("NARG");
this.vmType = __vmType;
this.sourceSet = __sourceSet;
}
/**
......@@ -120,7 +126,7 @@ public class VMFullSuiteTaskAction
// Use filled JVM arguments
this.vmType.spawnJvmArguments(__task, true,
new GradleJavaExecSpecFiller(__spec),
"javax.microedition.midlet.__MainHandler__",
UnassistedLaunchEntry.MIDLET_MAIN_CLASS,
"fullSuite",
new LinkedHashMap<String, String>(),
libPath.<Path>toArray(new Path[libPath.size()]),
......
......@@ -10,12 +10,13 @@
package cc.squirreljme.plugin.multivm;
import java.nio.file.Path;
import java.util.function.Supplier;
import javax.inject.Inject;
import lombok.Getter;
import org.gradle.api.DefaultTask;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Internal;
import org.gradle.jvm.tasks.Jar;
......@@ -39,6 +40,11 @@ public class VMLibraryTask
@Getter
public final VMSpecifier vmType;
/** The base JAR. */
@Internal
@Getter
public final Jar baseJar;
/**
* Initializes the library creation task.
*
......@@ -57,6 +63,7 @@ public class VMLibraryTask
Project project = this.getProject();
Jar baseJar = VMHelpers.jarTask(project, __sourceSet);
this.baseJar = baseJar;
// These are used at the build stage
this.sourceSet = __sourceSet;
......@@ -70,11 +77,15 @@ public class VMLibraryTask
this.dependsOn(baseJar,
new VMLibraryTaskDependencies(this, this.vmType));
// Only run if the JAR would run
this.onlyIf(this::onlyIf);
// The input of this task is the JAR that was created
this.getInputs().file(baseJar.getArchiveFile());
// The output depends on the task and its source set
this.getOutputs().file(this.outputPath());
this.getOutputs().files(
this.getProject().provider(() -> this.__taskOutputFile()));
this.getOutputs().upToDateWhen(
new VMLibraryTaskUpToDate(this.vmType));
......@@ -82,6 +93,18 @@ public class VMLibraryTask
this.doLast(new VMLibraryTaskAction(__sourceSet, __vmType));
}
/**
* When should this run?
*
* @param __task The task to check.
* @return If this should run.
* @since 2022/05/20
*/
private boolean onlyIf(Task __task)
{
return this.baseJar.getOnlyIf().isSatisfiedBy(this.baseJar);
}
/**
* Returns the output path of the archive.
*
......@@ -95,4 +118,17 @@ public class VMLibraryTask
.resolve(this.vmType.outputLibraryName(this.getProject(),
this.sourceSet)));
}
/**
* Returns the output file for this task.
*
* @return The output file for this task.
* @since 2022/05/20
*/
private Object __taskOutputFile()
{
if (this.onlyIf(this))
return this.outputPath();
return null;
}
}
......@@ -45,6 +45,22 @@ public class TestsJarTask
// Setup the task
this.getArchiveClassifier().set("tests");
this.from((Callable<FileCollection>)this::__from);
// Only run if there are actual tests
this.onlyIf(this::__onlyIf);
}
/**
* Only run this task in this situation.
*
* @param __task This task.
* @return If this should run or not.
* @since 2022/05/20
*/
private boolean __onlyIf(Task __task)
{
// Only run if there are files to actually be added
return !this.__from().getAsFileTree().getFiles().isEmpty();
}
/**
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package cc.squirreljme.plugin.util;
/**
* This is used to allow for unassisted launches when building ROMs and
* otherwise.
*
* @since 2021/08/22
*/
public final class UnassistedLaunchEntry
{
/** MIDlet starting class. */
public static final String MIDLET_MAIN_CLASS =
"javax.microedition.midlet.__MainHandler__";
/** The main entry class. */
public final String mainClass;
/** The arguments to the call. */
private final String[] _args;
/**
* Initializes the unassisted launch entry.
*
* @param __mainClass The main class.
* @param __args The arguments to the call.
* @since 2021/08/22
*/
public UnassistedLaunchEntry(String __mainClass, String... __args)
{
this.mainClass = __mainClass;
this._args = __args;
}
/**
* Returns the launch arguments.
*
* @return The launch arguments.
* @since 2021/08/22
*/
public final String[] args()
{
return this._args.clone();
}
}
result: NoResult
thrown: NoExceptionThrown
secondary-random----1432335638160804534: long:-2251799813685248
secondary-random----1888909202756794383: long:-2251799813685248
secondary-random----1967517401509503925: long:-2251799813685248
secondary-random----2219394418870420802: long:-2251799813685248
secondary-random----2624158267349034417: long:-2251799813685248
secondary-random----3122980739108447343: long:-2251799813685248
secondary-random----3339783707453616697: long:-2251799813685248
secondary-random----5400592651466114974: long:-2251799813685248
secondary-random----5722537487475081571: long:-2251799813685248
secondary-random----6115910518010414781: long:-2251799813685248
secondary-random----6408905489149784990: long:-2251799813685248
secondary-random----6437715043167905200: long:-2251799813685248
secondary-random----7033748006474773329: long:-2251799813685248
secondary-random----7867116347168471483: long:-2251799813685248
secondary-random----8831809862686031823: long:-2251799813685248
secondary-random----1432335638160804534: long-ignore-sign:-2251799813685248
secondary-random----1888909202756794383: long-ignore-sign:-2251799813685248
secondary-random----1967517401509503925: long-ignore-sign:-2251799813685248
secondary-random----2219394418870420802: long-ignore-sign:-2251799813685248
secondary-random----2624158267349034417: long-ignore-sign:-2251799813685248
secondary-random----3122980739108447343: long-ignore-sign:-2251799813685248
secondary-random----3339783707453616697: long-ignore-sign:-2251799813685248
secondary-random----5400592651466114974: long-ignore-sign:-2251799813685248
secondary-random----5722537487475081571: long-ignore-sign:-2251799813685248
secondary-random----6115910518010414781: long-ignore-sign:-2251799813685248
secondary-random----6408905489149784990: long-ignore-sign:-2251799813685248
secondary-random----6437715043167905200: long-ignore-sign:-2251799813685248
secondary-random----7033748006474773329: long-ignore-sign:-2251799813685248
secondary-random----7867116347168471483: long-ignore-sign:-2251799813685248
secondary-random----8831809862686031823: long-ignore-sign:-2251799813685248
secondary-random--1255568899445664322: long:-4575623698181355925
secondary-random--1434825769210690147: long:-4576075885753216990
secondary-random--158884801877076938: long:-4574139165859803029
......@@ -32,8 +32,8 @@ secondary-random--7843894698618392042: long:4647472167532842776
secondary-random--7866673980374278231: long:4647533729646704837
secondary-random--8572265387981001411: long:4648579681512836525
secondary-random--9133131972231561590: long:4649338522149113304
secondary-value----01: long:-2251799813685248
secondary-value----02: long:-2251799813685248
secondary-value----01: long-ignore-sign:-2251799813685248
secondary-value----02: long-ignore-sign:-2251799813685248
secondary-value--000: long:-4503599627370496
secondary-value--001: long:0
secondary-value--002: long:4604418534313441775
......
......@@ -9,6 +9,8 @@
package net.multiphasicapps.tac;
import cc.squirreljme.runtime.cldc.debug.Debugging;
/**
* Runs all of the tests within the suite.
*
......@@ -24,6 +26,6 @@ public class MainSuiteRunner
*/
public static void main(String... __args)
{
throw new todo.TODO();
throw Debugging.todo();
}
}
......@@ -72,8 +72,8 @@ public final class TestExecution
this.testClass, this.result);
// Print comparison to show what failed
this.expected.printComparison(System.err,
this.result);
this.result.printComparison(System.err,
this.expected);
break;
case TEST_EXCEPTION:
......
......@@ -462,6 +462,18 @@ public final class TestResult
return !la.isEmpty();
}
// Compare against long but ignoring whatever sign is used
else if (__act.startsWith("long:") &&
__exp.startsWith("long-ignore-sign:"))
{
// Parse values
long act = Long.parseLong(__act.substring("long:".length()));
long exp = Long.parseLong(
__exp.substring("long-ignore-sign:".length()));
return (act & ~Long.MIN_VALUE) == (exp & ~Long.MIN_VALUE);
}
// Comparing against fudged long value (which is a plus or minus value)
else if (__act.startsWith("long:") && __exp.startsWith("long-fudge:"))
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment