From 3926caf7c9f3b60a786dffde785cd64b8509245e Mon Sep 17 00:00:00 2001 From: Yossi Farjoun Date: Tue, 18 Apr 2017 11:10:49 -0400 Subject: [PATCH 1/3] Adding a pre-test check that looks for java files in the test/scala directory and for scala files anywhere else (and fails if it finds either of these) --- build.gradle | 29 ++++++++++++++-------- scripts/checkScalaAndJavaFiles.sh | 14 +++++++++++ .../htsjdk/samtools/util/StringUtilTest.scala | 4 +-- 3 files changed, 34 insertions(+), 13 deletions(-) create mode 100755 scripts/checkScalaAndJavaFiles.sh diff --git a/build.gradle b/build.gradle index 9760a79fa..c4d063b53 100644 --- a/build.gradle +++ b/build.gradle @@ -81,6 +81,23 @@ tasks.withType(Test) { task -> task.jvmArgs '-Djava.awt.headless=true' //this prevents awt from displaying a java icon while the tests are running } +task testSRA(type: Test) { + description = "Run the SRA tests" + jvmArgs += '-Dsamjdk.sra_libraries_download=true' + + tags { + exclude "slow" + exclude "broken" + } +} + + +task FindScalaAndJavaTypes(type: Exec) { + description = "Check for Scala outside the scala test dir and java files there." + commandLine './scripts/checkScalaAndJavaFiles.sh' +} + + test { description = "Runs the unit tests other than the SRA tests" @@ -98,17 +115,7 @@ test { if (System.env.CI == "false") exclude "sra" if (!OperatingSystem.current().isUnix()) exclude "unix" } -} - -task testSRA(type: Test) { - description = "Run the SRA tests" - jvmArgs += '-Dsamjdk.sra_libraries_download=true' - - tags { - exclude "slow" - exclude "broken" - } -} +} dependsOn FindScalaAndJavaTypes task wrapper(type: Wrapper) { description = "Regenerate the gradle wrapper" diff --git a/scripts/checkScalaAndJavaFiles.sh b/scripts/checkScalaAndJavaFiles.sh new file mode 100755 index 000000000..90a867f18 --- /dev/null +++ b/scripts/checkScalaAndJavaFiles.sh @@ -0,0 +1,14 @@ +#/bin/bash + +if `find src | grep -v '^src/test/scala' | grep -q '\.scala$' ` ; then + echo 'Found scala file(s) outside of scala test directory'; + find src | grep -v '^src/test/scala' | grep '\.scala$' + exit 1; +fi + +if `find src/test/scala | grep -q '\.java$' ` ; then + echo 'Found java file(s) in scala test directory'; + find src/test/scala | grep '\.java$' + exit 1; +fi + diff --git a/src/test/scala/htsjdk/samtools/util/StringUtilTest.scala b/src/test/scala/htsjdk/samtools/util/StringUtilTest.scala index 6962e3674..c9af44c76 100644 --- a/src/test/scala/htsjdk/samtools/util/StringUtilTest.scala +++ b/src/test/scala/htsjdk/samtools/util/StringUtilTest.scala @@ -1,4 +1,4 @@ -/* + /* * The MIT License * * Copyright (c) 2017 The Broad Institute @@ -106,7 +106,7 @@ class StringUtilTest extends UnitSpec { StringUtil.assertCharactersNotInString("HelloWorld", ' ', '!', '_') } - val textForWrapping = + val textForWrapping: String = """This is a little bit |of text with nice short |lines. From 83904daa28b3ec325243452c4c4a02efc21dc253 Mon Sep 17 00:00:00 2001 From: Yossi Farjoun Date: Tue, 18 Apr 2017 14:18:56 -0400 Subject: [PATCH 2/3] responding to verbal review comments --- build.gradle | 28 +++++++++++++--------------- scripts/checkScalaAndJavaFiles.sh | 3 +++ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/build.gradle b/build.gradle index c4d063b53..a60afe5f5 100644 --- a/build.gradle +++ b/build.gradle @@ -81,23 +81,11 @@ tasks.withType(Test) { task -> task.jvmArgs '-Djava.awt.headless=true' //this prevents awt from displaying a java icon while the tests are running } -task testSRA(type: Test) { - description = "Run the SRA tests" - jvmArgs += '-Dsamjdk.sra_libraries_download=true' - - tags { - exclude "slow" - exclude "broken" - } -} - - -task FindScalaAndJavaTypes(type: Exec) { - description = "Check for Scala outside the scala test dir and java files there." +task findScalaAndJavaTypes(type: Exec) { + description = "Check that Scala files only exist in the scala test dir and that java files do not reside in the scala test dir." commandLine './scripts/checkScalaAndJavaFiles.sh' } - test { description = "Runs the unit tests other than the SRA tests" @@ -115,7 +103,17 @@ test { if (System.env.CI == "false") exclude "sra" if (!OperatingSystem.current().isUnix()) exclude "unix" } -} dependsOn FindScalaAndJavaTypes +} dependsOn findScalaAndJavaTypes + +task testSRA(type: Test) { + description = "Run the SRA tests" + jvmArgs += '-Dsamjdk.sra_libraries_download=true' + + tags { + exclude "slow" + exclude "broken" + } +} task wrapper(type: Wrapper) { description = "Regenerate the gradle wrapper" diff --git a/scripts/checkScalaAndJavaFiles.sh b/scripts/checkScalaAndJavaFiles.sh index 90a867f18..adadfd31c 100755 --- a/scripts/checkScalaAndJavaFiles.sh +++ b/scripts/checkScalaAndJavaFiles.sh @@ -1,5 +1,8 @@ #/bin/bash +# Check that Scala files only exist in the scala test dir and +# that java files do not reside in the scala test dir + if `find src | grep -v '^src/test/scala' | grep -q '\.scala$' ` ; then echo 'Found scala file(s) outside of scala test directory'; find src | grep -v '^src/test/scala' | grep '\.scala$' From b26e2c9814d5b11505d7821cbb87f97a57a4b2a7 Mon Sep 17 00:00:00 2001 From: Yossi Farjoun Date: Tue, 18 Apr 2017 14:20:59 -0400 Subject: [PATCH 3/3] -extra space --- src/test/scala/htsjdk/samtools/util/StringUtilTest.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/scala/htsjdk/samtools/util/StringUtilTest.scala b/src/test/scala/htsjdk/samtools/util/StringUtilTest.scala index c9af44c76..35957d681 100644 --- a/src/test/scala/htsjdk/samtools/util/StringUtilTest.scala +++ b/src/test/scala/htsjdk/samtools/util/StringUtilTest.scala @@ -1,4 +1,4 @@ - /* +/* * The MIT License * * Copyright (c) 2017 The Broad Institute