Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import util::Eval;
import util::PathConfig;
import Message;

PathConfig init() = pathConfig(srcs=[|memory://LoadingErrorModules/|]);
PathConfig init() = pathConfig(projectRoot=|cwd:///|, srcs=[|memory://LoadingErrorModules/|]);

loc moduleFile(str name) = |memory://LoadingErrorModules/| + "<name>.rsc";

Expand Down
2 changes: 1 addition & 1 deletion src/org/rascalmpl/library/util/Eval.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private static class RascalRuntime {
private int duration = -1;

public RascalRuntime(PathConfig pcfg, Reader input, PrintWriter stderr, PrintWriter stdout, IDEServices services) throws IOException, URISyntaxException{
eval = ShellEvaluatorFactory.getDefaultEvaluatorForPathConfig(URIUtil.rootLocation("cwd"), pcfg, input, stdout, stderr, services);
eval = ShellEvaluatorFactory.getDefaultEvaluatorForPathConfig(pcfg, input, stdout, stderr, services);
}

public void clearLoadMessages() {
Expand Down
19 changes: 9 additions & 10 deletions src/org/rascalmpl/shell/RascalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import engineering.swat.watch.DaemonThreadPool;
import io.usethesource.vallang.IConstructor;
import io.usethesource.vallang.IList;
import io.usethesource.vallang.ISourceLocation;
import io.usethesource.vallang.IString;
import io.usethesource.vallang.io.StandardTextWriter;
import io.usethesource.vallang.type.Type;
Expand All @@ -46,9 +45,8 @@ public static void main(String[] args) {
var parser = new CommandlineParser(out);
var parsedArgs = parser.parseKeywordCommandLineArgs("RascalTest", args, parameterTypes());
var pcfgCons = (IConstructor) parsedArgs.get("pcfg");
PathConfig pcfg = pcfgCons != null ? new PathConfig(pcfgCons) : new PathConfig();
var pcfg = pcfgCons != null ? new PathConfig(pcfgCons) : new PathConfig(URIUtil.rootLocation("cwd"));

var projectRoot = pcfg.getProjectRoot().getScheme().equals("unknown") ? URIUtil.rootLocation("cwd") : pcfg.getProjectRoot();
boolean reporting = vf.bool(true).equals(parsedArgs.get("reporting"));
boolean isParallel = isTrueParameter(parsedArgs, "parallel");
int parAmount = parallelAmount(intParameter(parsedArgs, "parallelMax", 10).intValue());
Expand All @@ -58,10 +56,10 @@ public static void main(String[] args) {
IList modules = allRascalSourceFiles(pcfg.getSrcs(), pcfg.getIgnores());

if (isParallel && parAmount > 1) {
System.exit(runParallelTests(modules, preChecks, monitor, projectRoot, pcfg, term, err, out, reporting, parAmount));
System.exit(runParallelTests(modules, preChecks, monitor, pcfg, term, err, out, reporting, parAmount));
}
else {
System.exit(runTestsForModules(modules, monitor, projectRoot, pcfg, term, err, out, reporting));
System.exit(runTestsForModules(modules, monitor, pcfg, term, err, out, reporting));
}
}
catch (IOException | URISyntaxException e) {
Expand All @@ -70,11 +68,11 @@ public static void main(String[] args) {
}
}

private static int runParallelTests(IList modules, IList preChecks, IRascalMonitor monitor, ISourceLocation projectRoot,
private static int runParallelTests(IList modules, IList preChecks, IRascalMonitor monitor,
PathConfig pcfg, Terminal term, PrintWriter err, PrintWriter out, boolean reporting, int parAmount) throws URISyntaxException {
// first we run the pre-checks
if (preChecks.size() > 0) {
if (runTestsForModules(preChecks, monitor, projectRoot, pcfg, term, err, out, reporting) != 0) {
if (runTestsForModules(preChecks, monitor, pcfg, term, err, out, reporting) != 0) {
return 1;
}
}
Expand All @@ -95,7 +93,7 @@ private static int runParallelTests(IList modules, IList preChecks, IRascalMonit

workers.add(exec.submit(() -> {
out.println("Starting worker " + index + " on " + chunk.size() + " modules.");
return runTestsForModules(chunk, monitor, projectRoot, pcfg, term, err, out, reporting);
return runTestsForModules(chunk, monitor, pcfg, term, err, out, reporting);
}));
}

Expand All @@ -109,12 +107,13 @@ private static int runParallelTests(IList modules, IList preChecks, IRascalMonit
* Thread-safe execution of tests in given modules in a specific project
* @return exit code where 0 means all test succeeded and not 0 means at least one test failed or error'ed
*/
private static int runTestsForModules(IList modules, IRascalMonitor monitor, ISourceLocation projectRoot, PathConfig pcfg, Terminal term, PrintWriter err, PrintWriter out, boolean reporting) {
private static int runTestsForModules(IList modules, IRascalMonitor monitor, PathConfig pcfg, Terminal term, PrintWriter err, PrintWriter out, boolean reporting) {
try {
var modNames = sourceFilesToModuleNames(modules, pcfg);
var projectRoot = pcfg.getProjectRoot();

// using our own evaluator makes this thread safe.
var eval = ShellEvaluatorFactory.getDefaultEvaluatorForPathConfig(projectRoot, pcfg, term.reader(), out, err, monitor);
var eval = ShellEvaluatorFactory.getDefaultEvaluatorForPathConfig(pcfg, term.reader(), out, err, monitor);
if (modNames.size() == 0) {
eval.warning("The module list for testing is empty.", projectRoot);
}
Expand Down
10 changes: 5 additions & 5 deletions src/org/rascalmpl/shell/ShellEvaluatorFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ public static Evaluator getDefaultEvaluator(Reader input, PrintWriter stdout, Pr
return getBasicEvaluator(input, stdout, stderr, monitor, rootEnvironment);
}

public static Evaluator getDefaultEvaluatorForPathConfig(ISourceLocation projectRoot, PathConfig pcfg, Reader input, PrintWriter stdout, PrintWriter stderr, IRascalMonitor monitor) {
setupProjectResolver(projectRoot, monitor);
return getDefaultEvaluatorForPathConfig(projectRoot, pcfg, input, stdout, stderr, monitor, ModuleEnvironment.SHELL_MODULE);
public static Evaluator getDefaultEvaluatorForPathConfig(PathConfig pcfg, Reader input, PrintWriter stdout, PrintWriter stderr, IRascalMonitor monitor) {
setupProjectResolver(pcfg.getProjectRoot(), monitor);
return getDefaultEvaluatorForPathConfig(pcfg, input, stdout, stderr, monitor, ModuleEnvironment.SHELL_MODULE);
}

private static Evaluator getDefaultEvaluatorForPathConfig(ISourceLocation projectRoot, PathConfig pcfg, Reader input, PrintWriter stdout, PrintWriter stderr, IRascalMonitor monitor, String rootEnvironment) {
private static Evaluator getDefaultEvaluatorForPathConfig(PathConfig pcfg, Reader input, PrintWriter stdout, PrintWriter stderr, IRascalMonitor monitor, String rootEnvironment) {
var evaluator = getBasicEvaluator(input, stdout, stderr, monitor, rootEnvironment);

for (var srcPath : pcfg.getSrcs()) {
Expand Down Expand Up @@ -97,7 +97,7 @@ public static Evaluator getDefaultEvaluatorForLocation(ISourceLocation projectFi
Messages.write(pcfg.getMessages(), pcfg.getProjectRoot(), stdout);
}

return getDefaultEvaluatorForPathConfig(projectRoot, pcfg, input, stdout, stderr, monitor, rootEnvironment);
return getDefaultEvaluatorForPathConfig(pcfg, input, stdout, stderr, monitor, rootEnvironment);
}

private static void registerProjectAndTargetResolver(ISourceLocation projectFile) {
Expand Down
Loading