Skip to content
Snippets Groups Projects
Commit 3bfe38c5 authored by bow's avatar bow
Browse files

Merge branch 'develop' into feature-pom_updates

parents 8fe0a2bb 2c360e07
No related branches found
No related tags found
No related merge requests found
package nl.lumc.sasc.biopet.extensions package nl.lumc.sasc.biopet.extensions
import java.io.File import java.io.File
import scala.sys.process.Process import scala.sys.process.{ Process, ProcessLogger }
import org.broadinstitute.gatk.queue.function.InProcessFunction import org.broadinstitute.gatk.queue.function.InProcessFunction
import org.broadinstitute.gatk.utils.commandline.{ Input, Output } import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
import nl.lumc.sasc.biopet.core.config.Configurable import nl.lumc.sasc.biopet.core.config.Configurable
...@@ -71,15 +71,21 @@ class Ln(val root: Configurable) extends InProcessFunction with Configurable { ...@@ -71,15 +71,21 @@ class Ln(val root: Configurable) extends InProcessFunction with Configurable {
if (relative) { if (relative) {
// workaround until we have `ln` that works with relative path (i.e. `ln -r`) // workaround until we have `ln` that works with relative path (i.e. `ln -r`)
"ln -s '" + inRelative + "' '" + outCanonical + "'" "ln -s " + inRelative + " " + outCanonical
} else { } else {
"ln -s '" + inCanonical + "' '" + outCanonical + "'" "ln -s " + inCanonical + " " + outCanonical
} }
} }
override def run { override def run {
val process = Process(cmd).run val stdout = new StringBuffer()
logger.info("cmd: '" + cmd + "', exitcode: " + process.exitValue) val stderr = new StringBuffer()
val process = Process(cmd).run(ProcessLogger(stdout append _ + "\n", stderr append _ + "\n"))
val exitcode = process.exitValue
if (exitcode != 0) {
throw new Exception("Error creating symbolic link, this was the original message: \n" + stderr)
}
logger.info("cmd: '" + cmd + "', exitcode: " + exitcode)
} }
} }
......
...@@ -19,7 +19,7 @@ class LnUnitTest extends TestNGSuite with Matchers { ...@@ -19,7 +19,7 @@ class LnUnitTest extends TestNGSuite with Matchers {
ln.relative = true ln.relative = true
ln.in = new File("/dir/nested/target.txt") ln.in = new File("/dir/nested/target.txt")
ln.out = new File("/dir/nested/link.txt") ln.out = new File("/dir/nested/link.txt")
ln.cmd should ===("ln -s 'target.txt' '/dir/nested/link.txt'") ln.cmd should ===("ln -s target.txt /dir/nested/link.txt")
} }
@Test(description = "Target is one level above link, relative set to true") @Test(description = "Target is one level above link, relative set to true")
...@@ -28,7 +28,7 @@ class LnUnitTest extends TestNGSuite with Matchers { ...@@ -28,7 +28,7 @@ class LnUnitTest extends TestNGSuite with Matchers {
ln.relative = true ln.relative = true
ln.in = new File("/dir/target.txt") ln.in = new File("/dir/target.txt")
ln.out = new File("/dir/nested/link.txt") ln.out = new File("/dir/nested/link.txt")
ln.cmd should ===("ln -s '../target.txt' '/dir/nested/link.txt'") ln.cmd should ===("ln -s ../target.txt /dir/nested/link.txt")
} }
@Test(description = "Target is two levels above link, relative set to true") @Test(description = "Target is two levels above link, relative set to true")
...@@ -37,7 +37,7 @@ class LnUnitTest extends TestNGSuite with Matchers { ...@@ -37,7 +37,7 @@ class LnUnitTest extends TestNGSuite with Matchers {
ln.relative = true ln.relative = true
ln.in = new File("/target.txt") ln.in = new File("/target.txt")
ln.out = new File("/dir/nested/link.txt") ln.out = new File("/dir/nested/link.txt")
ln.cmd should ===("ln -s '../../target.txt' '/dir/nested/link.txt'") ln.cmd should ===("ln -s ../../target.txt /dir/nested/link.txt")
} }
@Test(description = "Target is a child of a directory one level above link, relative set to true") @Test(description = "Target is a child of a directory one level above link, relative set to true")
...@@ -46,7 +46,7 @@ class LnUnitTest extends TestNGSuite with Matchers { ...@@ -46,7 +46,7 @@ class LnUnitTest extends TestNGSuite with Matchers {
ln.relative = true ln.relative = true
ln.in = new File("/dir/another_nested/target.txt") ln.in = new File("/dir/another_nested/target.txt")
ln.out = new File("/dir/nested/link.txt") ln.out = new File("/dir/nested/link.txt")
ln.cmd should ===("ln -s '../another_nested/target.txt' '/dir/nested/link.txt'") ln.cmd should ===("ln -s ../another_nested/target.txt /dir/nested/link.txt")
} }
@Test(description = "Target is one level below link, relative set to true") @Test(description = "Target is one level below link, relative set to true")
...@@ -55,7 +55,7 @@ class LnUnitTest extends TestNGSuite with Matchers { ...@@ -55,7 +55,7 @@ class LnUnitTest extends TestNGSuite with Matchers {
ln.relative = true ln.relative = true
ln.in = new File("/dir/nested/deeper/target.txt") ln.in = new File("/dir/nested/deeper/target.txt")
ln.out = new File("/dir/nested/link.txt") ln.out = new File("/dir/nested/link.txt")
ln.cmd should ===("ln -s 'deeper/target.txt' '/dir/nested/link.txt'") ln.cmd should ===("ln -s deeper/target.txt /dir/nested/link.txt")
} }
@Test(description = "Target is two levels below link, relative set to true") @Test(description = "Target is two levels below link, relative set to true")
...@@ -64,7 +64,7 @@ class LnUnitTest extends TestNGSuite with Matchers { ...@@ -64,7 +64,7 @@ class LnUnitTest extends TestNGSuite with Matchers {
ln.relative = true ln.relative = true
ln.in = new File("/dir/nested/even/deeper/target.txt") ln.in = new File("/dir/nested/even/deeper/target.txt")
ln.out = new File("/dir/nested/link.txt") ln.out = new File("/dir/nested/link.txt")
ln.cmd should ===("ln -s 'even/deeper/target.txt' '/dir/nested/link.txt'") ln.cmd should ===("ln -s even/deeper/target.txt /dir/nested/link.txt")
} }
@Test(description = "Relative set to false") @Test(description = "Relative set to false")
...@@ -73,7 +73,7 @@ class LnUnitTest extends TestNGSuite with Matchers { ...@@ -73,7 +73,7 @@ class LnUnitTest extends TestNGSuite with Matchers {
ln.relative = false ln.relative = false
ln.in = new File("/dir/nested/target.txt") ln.in = new File("/dir/nested/target.txt")
ln.out = new File("/dir/nested/link.txt") ln.out = new File("/dir/nested/link.txt")
ln.cmd should ===("ln -s '/dir/nested/target.txt' '/dir/nested/link.txt'") ln.cmd should ===("ln -s /dir/nested/target.txt /dir/nested/link.txt")
} }
// TODO: test for case where abosolute is true and input paths are relative? // TODO: test for case where abosolute is true and input paths are relative?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment