From d483dd1994d59ac5f0fc76d6336c9dda3f180f27 Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Tue, 27 Oct 2020 19:52:12 -0700 Subject: [PATCH 1/2] Improved #36: Added compile flags for enabling tests --- COMPILING.md | 25 ++++--------------------- build.sbt | 35 ++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 36 deletions(-) diff --git a/COMPILING.md b/COMPILING.md index 68c2ea1e..450907bb 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -21,29 +21,12 @@ Setting up the test suite for Millfork is tricky, so if you don't need the tests #### Steps -* remove all test dependencies from `build.sbt`: - - "org.scalatest" %% "scalatest" - "com.codingrodent.microprocessor" % "Z80Processor" - "NeatMonster" % "Intel8086" - "com.loomcom.symon" % "symon" - "com.grapeshot" % "halfnes" - "eu.rekawek.coffeegb" % "coffee-gb" - "roug.org.osnine" % "osnine-core" - -* navigate to the project directory - -* run `sbt 'set test in assembly := {}' compile` +* run `sbt compile` to compile the project -* run `sbt 'set test in assembly := {}' assembly` +* run `sbt assembly` to build the executable jar file, it should appear in `target/scala-2.12` -* on Windows, use double quotes for the last two commands: - - sbt "set test in assembly := {}" compile - sbt "set test in assembly := {}" assembly - ### Building with tests Test suite is useful if you plan on modifying the compiler. Some test dependencies need manual installation. @@ -72,9 +55,9 @@ Test suite is useful if you plan on modifying the compiler. Some test dependenci * navigate to the project directory -* run `sbt compile` to compile the project +* run `sbt -DincludeTests compile` to compile the project -* run `sbt assemble` to build the executable jar file, it should appear in `target/scala-2.12` +* run `sbt -DincludeTests assemble` to build the executable jar file, it should appear in `target/scala-2.12` ### Building a native executable diff --git a/build.sbt b/build.sbt index 891447eb..0bbae190 100644 --- a/build.sbt +++ b/build.sbt @@ -14,29 +14,34 @@ libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.8" % "test" libraryDependencies += "com.codingrodent.microprocessor" % "Z80Processor" % "2.0.2" % "test" -// see: https://github.com/NeatMonster/Intel8086 -libraryDependencies += "NeatMonster" % "Intel8086" % "1.0" % "test" from "https://github.com/NeatMonster/Intel8086/raw/master/IBMPC.jar" +if (System.getProperty("includeTests") != null) { + println("Including test dependencies") + // see: https://github.com/NeatMonster/Intel8086 + libraryDependencies += "NeatMonster" % "Intel8086" % "1.0" % "test" from "https://github.com/NeatMonster/Intel8086/raw/master/IBMPC.jar" -// these three are not in Maven Central or any other public repo -// get them from the following links or just build millfork without tests: -// https://github.com/sethm/symon/tree/71905fdb1998ee4f142260879504bc46cf27648f -// https://github.com/andrew-hoffman/halfnes/tree/061 -// https://github.com/trekawek/coffee-gb/tree/coffee-gb-1.0.0 -// https://github.com/sorenroug/osnine-java/tree/b77349a6c314e1362e69b7158c385ac6f89b7ab8 + // these three are not in Maven Central or any other public repo + // get them from the following links or just build millfork without tests: + // https://github.com/sethm/symon/tree/71905fdb1998ee4f142260879504bc46cf27648f + // https://github.com/andrew-hoffman/halfnes/tree/061 + // https://github.com/trekawek/coffee-gb/tree/coffee-gb-1.0.0 + // https://github.com/sorenroug/osnine-java/tree/b77349a6c314e1362e69b7158c385ac6f89b7ab8 -libraryDependencies += "com.loomcom.symon" % "symon" % "1.3.0-SNAPSHOT" % "test" + libraryDependencies += "com.loomcom.symon" % "symon" % "1.3.0-SNAPSHOT" % "test" -libraryDependencies += "com.grapeshot" % "halfnes" % "061" % "test" + libraryDependencies += "com.grapeshot" % "halfnes" % "061" % "test" -libraryDependencies += "eu.rekawek.coffeegb" % "coffee-gb" % "1.0.0" % "test" + libraryDependencies += "eu.rekawek.coffeegb" % "coffee-gb" % "1.0.0" % "test" -libraryDependencies += "roug.org.osnine" % "osnine-core" % "2.0-SNAPSHOT" % "test" + libraryDependencies += "roug.org.osnine" % "osnine-core" % "2.0-SNAPSHOT" % "test" -libraryDependencies += "org.graalvm.sdk" % "graal-sdk" % "20.2.0" % "test" + libraryDependencies += "org.graalvm.sdk" % "graal-sdk" % "20.2.0" % "test" -libraryDependencies += "org.graalvm.js" % "js" % "20.2.0" % "test" + libraryDependencies += "org.graalvm.js" % "js" % "20.2.0" % "test" -libraryDependencies += "org.graalvm.js" % "js-scriptengine" % "20.2.0" % "test" + libraryDependencies += "org.graalvm.js" % "js-scriptengine" % "20.2.0" % "test" +} else { + test in assembly := {} +} mainClass in Compile := Some("millfork.Main") From af565b581a9cd062c78395df1d1509c3718c62d8 Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Fri, 30 Oct 2020 22:14:37 -0700 Subject: [PATCH 2/2] Fixed only some test dependencies being properly emitted --- build.sbt | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/build.sbt b/build.sbt index 0bbae190..7be6a80e 100644 --- a/build.sbt +++ b/build.sbt @@ -12,36 +12,41 @@ libraryDependencies += "org.apache.commons" % "commons-configuration2" % "2.2" libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.8" % "test" -libraryDependencies += "com.codingrodent.microprocessor" % "Z80Processor" % "2.0.2" % "test" - -if (System.getProperty("includeTests") != null) { - println("Including test dependencies") +val testDependencies = Seq( + "com.codingrodent.microprocessor" % "Z80Processor" % "2.0.2" % "test", // see: https://github.com/NeatMonster/Intel8086 - libraryDependencies += "NeatMonster" % "Intel8086" % "1.0" % "test" from "https://github.com/NeatMonster/Intel8086/raw/master/IBMPC.jar" - + "NeatMonster" % "Intel8086" % "1.0" % "test" from "https://github.com/NeatMonster/Intel8086/raw/master/IBMPC.jar", // these three are not in Maven Central or any other public repo // get them from the following links or just build millfork without tests: // https://github.com/sethm/symon/tree/71905fdb1998ee4f142260879504bc46cf27648f // https://github.com/andrew-hoffman/halfnes/tree/061 // https://github.com/trekawek/coffee-gb/tree/coffee-gb-1.0.0 // https://github.com/sorenroug/osnine-java/tree/b77349a6c314e1362e69b7158c385ac6f89b7ab8 + "com.loomcom.symon" % "symon" % "1.3.0-SNAPSHOT" % "test", + "com.grapeshot" % "halfnes" % "061" % "test", + "eu.rekawek.coffeegb" % "coffee-gb" % "1.0.0" % "test", + "roug.org.osnine" % "osnine-core" % "2.0-SNAPSHOT" % "test", + "org.graalvm.sdk" % "graal-sdk" % "20.2.0" % "test", + "org.graalvm.js" % "js" % "20.2.0" % "test", + "org.graalvm.js" % "js-scriptengine" % "20.2.0" % "test" +) - libraryDependencies += "com.loomcom.symon" % "symon" % "1.3.0-SNAPSHOT" % "test" +val includesTests = System.getProperty("includeTests") != null - libraryDependencies += "com.grapeshot" % "halfnes" % "061" % "test" +libraryDependencies ++=( + if (includesTests) { + println("Including test dependencies") + testDependencies + } else { + Seq() + } +) - libraryDependencies += "eu.rekawek.coffeegb" % "coffee-gb" % "1.0.0" % "test" - - libraryDependencies += "roug.org.osnine" % "osnine-core" % "2.0-SNAPSHOT" % "test" - - libraryDependencies += "org.graalvm.sdk" % "graal-sdk" % "20.2.0" % "test" - - libraryDependencies += "org.graalvm.js" % "js" % "20.2.0" % "test" - - libraryDependencies += "org.graalvm.js" % "js-scriptengine" % "20.2.0" % "test" -} else { +(if (!includesTests) { + // Disable assembling tests test in assembly := {} -} + // SBT doesn't like returning Unit, so return Seq +} else Seq()) mainClass in Compile := Some("millfork.Main")