From 280f922d8cc2d5cc71a4251935bd336ca2a2df28 Mon Sep 17 00:00:00 2001 From: bow <bow@bow.web.id> Date: Mon, 16 Feb 2015 11:59:45 +0100 Subject: [PATCH] Use unique and transient temp directory for each pipeline test --- .../sasc/biopet/pipelines/carp/CarpTest.scala | 18 ++++++++++++----- .../pipelines/flexiprep/FlexiprepTest.scala | 20 +++++++++++++------ .../pipelines/mapping/MappingTest.scala | 18 ++++++++++++----- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/public/carp/src/test/scala/nl/lumc/sasc/biopet/pipelines/carp/CarpTest.scala b/public/carp/src/test/scala/nl/lumc/sasc/biopet/pipelines/carp/CarpTest.scala index da63e765d..fd57a752a 100644 --- a/public/carp/src/test/scala/nl/lumc/sasc/biopet/pipelines/carp/CarpTest.scala +++ b/public/carp/src/test/scala/nl/lumc/sasc/biopet/pipelines/carp/CarpTest.scala @@ -2,15 +2,18 @@ package nl.lumc.sasc.biopet.pipelines.carp import java.io.File +import com.google.common.io.Files +import org.apache.commons.io.FileUtils +import org.broadinstitute.gatk.queue.QSettings +import org.testng.annotations.{ AfterClass, Test, DataProvider } +import org.scalatest.Matchers +import org.scalatest.testng.TestNGSuite + import nl.lumc.sasc.biopet.core.config.Config import nl.lumc.sasc.biopet.extensions.bwa.BwaMem import nl.lumc.sasc.biopet.extensions.macs2.Macs2CallPeak import nl.lumc.sasc.biopet.extensions.picard.{ MergeSamFiles, SortSam } import nl.lumc.sasc.biopet.utils.ConfigUtils -import org.broadinstitute.gatk.queue.QSettings -import org.testng.annotations.{ Test, DataProvider } -import org.scalatest.Matchers -import org.scalatest.testng.TestNGSuite /** * Created by pjvan_thof on 2/13/15. @@ -69,10 +72,15 @@ class CarpTest extends TestNGSuite with Matchers { carp.functions.count(_.isInstanceOf[Macs2CallPeak]) shouldBe (numberSamples + (if (threatment) 1 else 0)) } } + + // remove temporary run directory all tests in the class have been run + @AfterClass def removeTempOutputDir() = { + FileUtils.deleteDirectory(CarpTest.outputDir) + } } object CarpTest { - val outputDir = System.getProperty("java.io.tmpdir") + File.separator + "flexiprep" + val outputDir = Files.createTempDir() val excutables = Map( "reference" -> "test", diff --git a/public/flexiprep/src/test/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/FlexiprepTest.scala b/public/flexiprep/src/test/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/FlexiprepTest.scala index 1fcaab37b..7f6c81a34 100644 --- a/public/flexiprep/src/test/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/FlexiprepTest.scala +++ b/public/flexiprep/src/test/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/FlexiprepTest.scala @@ -2,15 +2,17 @@ package nl.lumc.sasc.biopet.pipelines.flexiprep import java.io.File +import com.google.common.io.Files +import org.apache.commons.io.FileUtils +import org.broadinstitute.gatk.queue.QSettings +import org.scalatest.Matchers +import org.scalatest.testng.TestNGSuite +import org.testng.annotations.{ AfterClass, DataProvider, Test } + import nl.lumc.sasc.biopet.core.config.Config import nl.lumc.sasc.biopet.extensions.{ Gzip, Zcat } import nl.lumc.sasc.biopet.tools.FastqSync import nl.lumc.sasc.biopet.utils.ConfigUtils -import org.broadinstitute.gatk.queue.QSettings -import org.broadinstitute.gatk.queue.function.QFunction -import org.scalatest.Matchers -import org.scalatest.testng.TestNGSuite -import org.testng.annotations.{ DataProvider, Test } /** * Created by pjvan_thof on 2/11/15. @@ -67,9 +69,15 @@ class FlexiprepTest extends TestNGSuite with Matchers { flexiprep.functions.count(_.isInstanceOf[Sickle]) shouldBe (if (skipTrim) 0 else 1) flexiprep.functions.count(_.isInstanceOf[Gzip]) shouldBe (if (paired) 2 else 1) } + + // remove temporary run directory all tests in the class have been run + @AfterClass def removeTempOutputDir() = { + FileUtils.deleteDirectory(FlexiprepTest.outputDir) + } } + object FlexiprepTest { - val outputDir = System.getProperty("java.io.tmpdir") + File.separator + "flexiprep" + val outputDir = Files.createTempDir() val excutables = Map( "seqstat" -> Map("exe" -> "test"), diff --git a/public/mapping/src/test/scala/nl/lumc/sasc/biopet/pipelines/mapping/MappingTest.scala b/public/mapping/src/test/scala/nl/lumc/sasc/biopet/pipelines/mapping/MappingTest.scala index 43085064c..19b773aba 100644 --- a/public/mapping/src/test/scala/nl/lumc/sasc/biopet/pipelines/mapping/MappingTest.scala +++ b/public/mapping/src/test/scala/nl/lumc/sasc/biopet/pipelines/mapping/MappingTest.scala @@ -2,6 +2,13 @@ package nl.lumc.sasc.biopet.pipelines.mapping import java.io.File +import com.google.common.io.Files +import org.apache.commons.io.FileUtils +import org.broadinstitute.gatk.queue.QSettings +import org.scalatest.Matchers +import org.scalatest.testng.TestNGSuite +import org.testng.annotations.{ AfterClass, DataProvider, Test } + import nl.lumc.sasc.biopet.core.config.Config import nl.lumc.sasc.biopet.extensions.bwa.{ BwaSamse, BwaSampe, BwaAln, BwaMem } import nl.lumc.sasc.biopet.extensions.picard.{ MergeSamFiles, AddOrReplaceReadGroups, MarkDuplicates, SortSam } @@ -12,10 +19,6 @@ import nl.lumc.sasc.biopet.pipelines.flexiprep.Sickle import nl.lumc.sasc.biopet.pipelines.flexiprep._ import nl.lumc.sasc.biopet.tools.FastqSync import nl.lumc.sasc.biopet.utils.ConfigUtils -import org.broadinstitute.gatk.queue.QSettings -import org.scalatest.Matchers -import org.scalatest.testng.TestNGSuite -import org.testng.annotations.{ DataProvider, Test } /** * Created by pjvan_thof on 2/12/15. @@ -94,10 +97,15 @@ class MappingTest extends TestNGSuite with Matchers { mapping.functions.count(_.isInstanceOf[MergeSamFiles]) shouldBe (if (skipMarkDuplicate && chunks > 1) 1 else 0) mapping.functions.count(_.isInstanceOf[MarkDuplicates]) shouldBe (if (skipMarkDuplicate) 0 else 1) } + + // remove temporary run directory all tests in the class have been run + @AfterClass def removeTempOutputDir() = { + FileUtils.deleteDirectory(MappingTest.outputDir) + } } object MappingTest { - val outputDir = System.getProperty("java.io.tmpdir") + File.separator + "flexiprep" + val outputDir = Files.createTempDir() val excutables = Map( "reference" -> "test", -- GitLab