Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/main/java/org/rascalmpl/maven/AbstractRascalMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public abstract class AbstractRascalMojo extends AbstractMojo
@Parameter(defaultValue = "${session}", required = true, readonly = true)
protected MavenSession session;

@Parameter(defaultValue = "0.42.0", required = false, readonly = false)
@Parameter(defaultValue = "0.43.0-RC9", required = false, readonly = false)
protected String bootstrapRascalVersion;

@SuppressWarnings("deprecation") // Can't get @Parameter to work for the pluginManager.
Expand Down Expand Up @@ -410,6 +410,25 @@ protected Process runMain(boolean verbose, String moreClasspath, List<File> srcs
return runningProcess;
}

protected List<File> allRascalSourceFiles(List<File> sourceLocs, List<File> ignoredLocs) {
var result = new LinkedList<File>();
allRascalSourceFiles(sourceLocs.stream().toArray(File[]::new), ignoredLocs, result);
return result;
}

private void allRascalSourceFiles(File[] sourceLocs, List<File> ignoredLocs, List<File> result) {
for (File f : sourceLocs) {
if (!ignoredLocs.contains(f)) {
if (f.getName().endsWith(".rsc")) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if there is a directory named all.rsc ? Maybe we should make sure it's a file?

result.add(f);
}
else if (f.isDirectory()) {
allRascalSourceFiles(f.listFiles(), ignoredLocs, result);
}
}
}
}

protected List<File> getTodoList(File binLoc, List<File> srcLocs, List<File> ignoredLocs, String dirtyExtension, String binaryExtension, String binaryPrefix) throws InclusionScanException, URISyntaxException {
StaleSourceScanner scanner = new StaleSourceScanner(100);
scanner.addSourceMapping(new SourceMapping() {
Expand Down
55 changes: 55 additions & 0 deletions src/main/java/org/rascalmpl/maven/TestRascalMojo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2009-2025, NWO-I Centrum Wiskunde & Informatica (CWI)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.rascalmpl.maven;

import java.io.File;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;

/**
* Maven Goal for running all tests in the current project
*/
@Mojo(name="test", defaultPhase = LifecyclePhase.TEST, requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
public class TestRascalMojo extends AbstractRascalMojo
{
@Parameter(property="parallel", required = false, defaultValue="false")
private boolean parallel;

@Parameter(property="parallelMax", required = false, defaultValue="4")
private int parallelMax;

@Parameter(property = "parallelPreChecks", required = false )
private List<File> parallelPreChecks;

@Parameter(defaultValue = "", property = "modules", required = false)
private List<File> modules;

public TestRascalMojo() {
super("org.rascalmpl.shell.RascalTest","test");
}

@Override
protected void setExtraParameters() {
extraParameters.put("modules", allRascalSourceFiles(srcs, ignores).stream().map(Object::toString).collect(Collectors.joining(File.pathSeparator)));
extraParameters.put("reporting", "true");
extraParameters.put("projectRoot", project.getBasedir().toString());
extraParameters.put("parallel", Boolean.toString(parallel));
extraParameters.put("parallelMax", Integer.toString(parallelMax));
extraParameters.put("parallelPreChecks", files(parallelPreChecks));
}
}
Loading