Skip to content

Commit

Permalink
Merge branch 'main' into features/dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
lukfor authored Oct 7, 2023
2 parents fa803f7 + 9b56901 commit 1a96a99
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 28 deletions.
8 changes: 6 additions & 2 deletions docs/docs/cli/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ nf-test test [<NEXTFLOW_FILES>|<SCRIPT_FOLDERS>]

To run your test using a specific Nextflow profile, you can use the `--profile` argument. [Learn more](/docs/configuration/#managing-profiles).

#### `--debug`
#### `--verbose`

The debug parameter prints out all available output channels which can be accessed in the `then` clause.
Prints out the Nextflow output during test runs.

#### `--without-trace`

Expand All @@ -32,6 +32,10 @@ Writes test results in [TAP format](https://testanything.org) to file.

Writes test results in [JUnit XML format](https://junit.org/) to file, which conforms to [the standard schema](https://github.com/junit-team/junit5/blob/242f3b3ef84cfd96c9de26992588812a68cdef8b/platform-tests/src/test/resources/jenkins-junit.xsd).

#### `--debug`

The debug parameter prints out debugging messages and all available output channels which can be accessed in the `then` clause.

## Examples

- Run all test scripts that can be found in the `testDir` defined in the `nf-test.config` file in the current working directory:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.askimed.nf.test.core.reports.TapTestReportWriter;
import com.askimed.nf.test.core.reports.XmlReportWriter;
import com.askimed.nf.test.lang.TestSuiteBuilder;
import com.askimed.nf.test.nextflow.NextflowCommand;
import com.askimed.nf.test.plugins.PluginManager;
import com.askimed.nf.test.util.AnsiColors;

Expand All @@ -37,9 +38,13 @@ public class RunTestsCommand extends AbstractCommand {
private List<File> testPaths = new ArrayList<File>();

@Option(names = {
"--debug" }, description = "Show Nextflow output", required = false, showDefaultValue = Visibility.ALWAYS)
"--debug" }, description = "Show debugging infos and dump channels", required = false, showDefaultValue = Visibility.ALWAYS)
private boolean debug = false;

@Option(names = {
"--verbose" }, description = "Show Nextflow output", required = false, showDefaultValue = Visibility.ALWAYS)
private boolean verbose = false;

@Option(names = {
"--profile" }, description = "Profile to execute all tests", required = false, showDefaultValue = Visibility.ALWAYS)
private String profile = null;
Expand Down Expand Up @@ -155,6 +160,8 @@ public Integer execute() throws Exception {
listener.addListener(new XmlReportWriter(junitXml));
}

NextflowCommand.setVerbose(verbose);

TagQuery tagQuery = new TagQuery(tags);

TestExecutionEngine engine = new TestExecutionEngine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void execute() throws Throwable {
}
nextflow.setOut(outFile);
nextflow.setErr(errFile);
nextflow.setSilent(!isDebug());
nextflow.setDebug(isDebug());
nextflow.setLog(logFile);
nextflow.setLaunchDir(launchDir);
nextflow.setWorkDir(workDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void then(@DelegatesTo(value = PipelineTest.class, strategy = Closure.DEL
public void execute() throws Throwable {

super.execute();

context.init(this);

if (setup != null) {
Expand Down Expand Up @@ -94,21 +94,21 @@ public void execute() throws Throwable {
if (!script.startsWith("/") && !script.startsWith("./")) {
script = new File(script).getAbsolutePath();
}
//file not found. try as github location

// file not found. try as github location
if (!new File(script).exists()) {
script = parent.getScript();
}

NextflowCommand nextflow = new NextflowCommand();
nextflow.setScript(script);
nextflow.setParams(context.getParams());
for (String profile: parent.getProfiles()) {
for (String profile : parent.getProfiles()) {
nextflow.addProfile(profile);
}
File projectConfig = new File("nextflow.config");
if (projectConfig.exists()) {
nextflow.addConfig(projectConfig);
nextflow.addConfig(projectConfig);
}
nextflow.addConfig(parent.getGlobalConfigFile());
nextflow.addConfig(parent.getLocalConfig());
Expand All @@ -118,7 +118,7 @@ public void execute() throws Throwable {
}
nextflow.setOut(outFile);
nextflow.setErr(errFile);
nextflow.setSilent(!isDebug());
nextflow.setDebug(isDebug());
nextflow.setLog(logFile);
nextflow.setLaunchDir(launchDir);
nextflow.setWorkDir(workDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void execute() throws Throwable {
}
nextflow.setOut(outFile);
nextflow.setErr(errFile);
nextflow.setSilent(!isDebug());
nextflow.setDebug(isDebug());
nextflow.setLog(logFile);
nextflow.setLaunchDir(launchDir);
nextflow.setWorkDir(workDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void execute() throws Throwable {
}
nextflow.setOut(outFile);
nextflow.setErr(errFile);
nextflow.setSilent(!isDebug());
nextflow.setDebug(isDebug());
nextflow.setLog(logFile);
nextflow.setLaunchDir(launchDir);
nextflow.setWorkDir(workDir);
Expand Down
39 changes: 25 additions & 14 deletions src/main/java/com/askimed/nf/test/nextflow/NextflowCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.nio.file.Files;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -36,7 +35,7 @@ public class NextflowCommand {

private File launchDir;

private boolean silent = true;
private boolean debug = false;

private File trace = null;

Expand All @@ -48,6 +47,8 @@ public class NextflowCommand {

private String options = "";

private static boolean verbose = false;

public static String ERROR = "Nextflow Binary not found. Please check if Nextflow is in a directory accessible by your $PATH variable or set $NEXTFLOW_HOME.";

public NextflowCommand() {
Expand Down Expand Up @@ -86,8 +87,12 @@ public void setParams(Map<String, Object> params) {
this.params = params;
}

public void setSilent(boolean silent) {
this.silent = silent;
public void setDebug(boolean debug) {
this.debug = debug;
}

public static void setVerbose(boolean verbose) {
NextflowCommand.verbose = verbose;
}

public void setTrace(File trace) {
Expand Down Expand Up @@ -168,7 +173,9 @@ public int execute() throws IOException {
writeParamsJson(params, paramsFile);

List<String> args = new Vector<String>();
args.add("-quiet");
if (!verbose) {
args.add("-quiet");
}
if (log != null) {
args.add("-log");
args.add(log.getAbsolutePath());
Expand Down Expand Up @@ -203,26 +210,30 @@ public int execute() throws IOException {
nextflow.setDirectory(launchDir.getAbsolutePath());
}
nextflow.setParams(args);
nextflow.setSilent(true);
if (verbose) {
System.out.println("");
}
nextflow.setSilent(!verbose);
if (out != null) {
nextflow.saveStdOut(out.getAbsolutePath());
}
if (err != null) {
nextflow.saveStdErr(err.getAbsolutePath());
}
if (!silent) {
System.out.println();
System.out.println(" Nextflow:");
System.out.println(" Profiles: " + profiles);
System.out.println(" Configs: " + configs);
System.out.println(" Command: " + nextflow.getExecutedCommand());
if (debug) {
//System.out.println();
System.out.println(" Profiles: " + profiles);
System.out.println(" Configs: " + configs);
System.out.println(" Command: " + nextflow.getExecutedCommand());
}

int result = nextflow.execute();

if (!silent) {
if (debug) {
printDebugInfo();
}
if (verbose || debug) {
System.out.print(" ");
}
return result;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void run() {
while ((size = is.read(buffer)) > 0) {
if (!silent) {
String line = new String(buffer, 0, size);
System.out.println(line);
System.out.print(" > " + line);
}
if (save) {
writer.write(buffer, 0, size);
Expand Down

0 comments on commit 1a96a99

Please sign in to comment.