Skip to content

Commit

Permalink
Merge branch 'main' into features/required-version
Browse files Browse the repository at this point in the history
  • Loading branch information
lukfor authored May 12, 2024
2 parents 824a4cf + c2734d9 commit 9fcb239
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 15 deletions.
16 changes: 16 additions & 0 deletions docs/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ This page collects videos and blog posts about nf-test created by the community.

---

### :material-tooltip-text:{ style="color: #337ab7" } Training Module: Hello nf-test

This training modules introduces nf-test in a simple and easy to follow-along hello-nextflow style aimed for beginners.

[hello nf-test training module](https://training.nextflow.io/hello_nextflow/05_hello_nf-test/)

---

### :material-tooltip-text:{ style="color: #337ab7" } Blog post: Leveraging nf-test for enhanced quality control in nf-core

Reproducibility is an important attribute of all good science. This is specially true in the realm of bioinformatics, where software is hopefully being constantly updated, and pipelines are ideally being maintained. This blog post covers nf-test in the nf-core context.

[Read blog post](https://nextflow.io/blog/2024/nf-test-in-nf-core.html)

---

### :fontawesome-brands-youtube:{ style="color: #EE0F0F" } nf-core/bytesize: Converting pytest modules to nf-test

**Adam Talbot** & **Sateesh Peri** do a live demo of converting nf-core DSL2 modules pytests to nf-test
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.askimed</groupId>
<artifactId>nf-test</artifactId>
<version>0.8.3</version>
<version>0.8.4</version>
<name>nf-test</name>
<description>Simple test framework for Nextflow pipelines</description>
<url>https://github.com/askimed/nf-test</url>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/askimed/nf/test/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class App {

public static final String NAME = "nf-test";

public static final String VERSION = "0.8.3";
public static final String VERSION = "0.8.4";

public static final String PACKAGE = "com.askimed.nf.test";

Expand Down
31 changes: 21 additions & 10 deletions src/main/java/com/askimed/nf/test/core/AbstractTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,26 @@ public File getConfig() {
return config;
}

@Override
public void setup(Config config, File testDirectory) throws IOException {
public void defineDirectories(File testDirectory) throws IOException {

if (testDirectory == null) {
throw new IOException("Testcase setup failed: No home directory set");
}

launchDir = initDirectory("Launch Directory", testDirectory, DIRECTORY_TESTS, getHash());
metaDir = initDirectory("Meta Directory", launchDir, DIRECTORY_META);
outputDir = initDirectory("Output Directory", launchDir, DIRECTORY_OUTPUT);
workDir = initDirectory("Working Directory", launchDir, DIRECTORY_WORK);
launchDir = constructDirectory(testDirectory, DIRECTORY_TESTS, getHash());
metaDir = constructDirectory(launchDir, DIRECTORY_META);
outputDir = constructDirectory(launchDir, DIRECTORY_OUTPUT);
workDir = constructDirectory(launchDir, DIRECTORY_WORK);

}

@Override
public void setup(Config config) throws IOException {

initDirectory("Launch Directory", launchDir);
initDirectory("Meta Directory", metaDir);
initDirectory("Output Directory", outputDir);
initDirectory("Working Directory", workDir);
FileStaging[] sharedDirectories = new FileStaging[]{
new FileStaging("bin", config != null ? config.getStageMode() : FileStaging.MODE_COPY),
new FileStaging("lib", config != null ? config.getStageMode() : FileStaging.MODE_COPY),
Expand Down Expand Up @@ -136,15 +145,17 @@ public void execute() throws Throwable {
}
}

public File initDirectory(String name, File root, String... childs) throws IOException {

public File constructDirectory(File root, String... childs) {
String path = FileUtil.path(root.getAbsolutePath(), FileUtil.path(childs));

File directory = new File(path).getAbsoluteFile();
return directory;
}

public void initDirectory(String name, File directory) throws IOException {

try {
FileUtil.deleteDirectory(directory);
FileUtil.createDirectory(directory);
return directory;
} catch (Exception e) {
throw new IOException(name + " '" + directory + "' could not be deleted or created:\n" + e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,19 @@ public void evalualteTestClosures() throws Throwable {
Closure closure = namedClosure.closure;

ITest test = getNewTestInstance(testName);
test.setup(config, getHomeDirectory());
test.defineDirectories(getHomeDirectory());
closure.setDelegate(test);
closure.setResolveStrategy(Closure.DELEGATE_ONLY);
closure.call();
addTest(test);
}
}

public void setupTest(ITest test) throws Throwable {
test.setup(config);
}


protected abstract ITest getNewTestInstance(String name);

public void setScript(String script) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/askimed/nf/test/core/ITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

public interface ITest extends ITaggable {

public void setup(Config config, File homeDirectory) throws Throwable;
public void defineDirectories(File testDirectory) throws Throwable;

public void setup(Config config) throws Throwable;

public void execute() throws Throwable;

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/askimed/nf/test/core/ITestSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ public interface ITestSuite extends ITaggable {

public void evalualteTestClosures() throws Throwable;

}
public void setupTest(ITest test) throws Throwable;

}
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ public int execute() throws Throwable {
log.info("Run test '{}'. type: {}", test, test.getClass().getName());
totalTests++;

testSuite.setupTest(test);

listener.executionStarted(test);
TestExecutionResult result = new TestExecutionResult(test);
test.setWithTrace(withTrace);
Expand Down

0 comments on commit 9fcb239

Please sign in to comment.