Skip to content

Commit

Permalink
Merge pull request #65 from chris-allan/symlink-check
Browse files Browse the repository at this point in the history
Handle symlink as the root directory (Fixes #62)
  • Loading branch information
chris-allan authored Jun 28, 2021
2 parents f97ecc4 + eb6760f commit 602ae48
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencies {
// be careful here, this is a newer version of org.json:json than formats-gpl uses
implementation 'org.json:json:20190722'
testImplementation 'junit:junit:4.12'
testImplementation 'org.apache.commons:commons-lang3:3.12.0'
testImplementation 'com.glencoesoftware:bioformats2raw:0.3.0-SNAPSHOT'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ public static void main(String[] args) {

@Override
public Void call() throws Exception {
// Resolve symlinks
inputDirectory = inputDirectory.toRealPath();
if (printVersion) {
printVersion();
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
import picocli.CommandLine;
import picocli.CommandLine.ExecutionException;

import org.apache.commons.lang3.SystemUtils;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
Expand Down Expand Up @@ -241,14 +243,7 @@ Object getPlane(ImageReader reader, int planeIndex) throws Exception {
reader.isLittleEndian());
}

/**
* Test defaults.
*/
@Test
public void testDefaults() throws Exception {
input = fake();
assertBioFormats2Raw();
assertTool();
private void assertDefaults() throws Exception {
ZarrArray series0 = ZarrGroup.open(output.resolve("0")).openArray("0");
Assert.assertTrue(series0.getNested());
// Also ensure we're using the latest .zarray metadata
Expand All @@ -268,6 +263,32 @@ public void testDefaults() throws Exception {
* Test defaults.
*/
@Test
public void testDefaults() throws Exception {
input = fake();
assertBioFormats2Raw();
assertTool();
assertDefaults();
}

/**
* Test symlink as the root.
*/
@Test
public void testSymlinkAsRoot() throws Exception {
Assume.assumeTrue(SystemUtils.IS_OS_LINUX);
input = fake();
assertBioFormats2Raw();
Path notASymlink = output.resolveSibling(output.getFileName() + ".old");
Files.move(output, notASymlink);
Files.createSymbolicLink(output, notASymlink);
assertTool();
assertDefaults();
}

/**
* Test series count check.
*/
@Test
public void testSeriesCountCheck() throws Exception {
input = fake();
assertBioFormats2Raw();
Expand Down

0 comments on commit 602ae48

Please sign in to comment.