From 13e6abc3f1d6cb8b98d82ea108952984a5e21abd Mon Sep 17 00:00:00 2001 From: fhackett Date: Mon, 28 Oct 2024 16:26:41 +0100 Subject: [PATCH] change to scala-cli and update dependencies --- .github/workflows/ci.yml | 17 +++++----- .gitignore | 1 + build.sbt | 31 ------------------- project.scala | 23 ++++++++++++++ .../pgo/util/TLAExpressionFuzzTestUtils.scala | 17 ++++++---- 5 files changed, 42 insertions(+), 47 deletions(-) delete mode 100644 build.sbt create mode 100644 project.scala diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 808e3352..61784c6e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: branches: [ 'main' ] jobs: - build: + tests: runs-on: ubuntu-latest strategy: matrix: @@ -16,17 +16,14 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK ${{ matrix.java-version }} - uses: actions/setup-java@v4 - with: - java-version: ${{ matrix.java-version }} - distribution: 'temurin' - - name: Setup Go environment - uses: actions/setup-go@v5 + - uses: actions/setup-go@v5 with: go-version: ${{ matrix.golang-version }} - - name: Run tests - run: sbt "testOnly -- -l org.scalatest.tags.Slow" + - uses: VirtusLab/scala-cli-setup@main + with: + jvm: ${{ matrix.java-version }} + - name: 'Run tests' + run: scala-cli test . -- -l org.scalatest.tags.Slow" - name: 'Upload Fuzz Test Results on Test Failure (in case there are some)' if: ${{ failure() }} uses: actions/upload-artifact@v4 diff --git a/.gitignore b/.gitignore index 1110c3b5..68731bdd 100644 --- a/.gitignore +++ b/.gitignore @@ -395,3 +395,4 @@ test/files/**/*.txt *.old .metals/ +.scala-build/ \ No newline at end of file diff --git a/build.sbt b/build.sbt deleted file mode 100644 index 32ee1cff..00000000 --- a/build.sbt +++ /dev/null @@ -1,31 +0,0 @@ - -ThisBuild / scalaVersion := "2.13.6" - -lazy val pgo = (project in file(".")) - .settings( - name := "pgo", - - scalacOptions += "-deprecation", - - Compile / scalaSource := baseDirectory.value / "src", - Test / scalaSource := baseDirectory.value / "test", - - libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value, - - libraryDependencies += "org.rogach" %% "scallop" % "4.1.0", - - libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.1", - libraryDependencies += "com.lihaoyi" %% "os-lib" % "0.8.1", - - libraryDependencies += "com.lihaoyi" %% "upickle" % "1.5.0", - libraryDependencies += "io.github.java-diff-utils" % "java-diff-utils" % "4.11", - libraryDependencies += "com.lihaoyi" % "ammonite" % "2.5.2" cross CrossVersion.full, - - libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.15.4" % Test, - libraryDependencies += "com.lihaoyi" %% "pprint" % "0.7.1" % Test, - libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.11" % Test, - - libraryDependencies += "com.lihaoyi" %% "mainargs" % "0.2.2" % Test, - libraryDependencies += "com.lihaoyi" %% "upickle" % "1.5.0" % Test, - libraryDependencies += "com.github.daddykotex" %% "courier" % "3.1.0" % Test, - ) \ No newline at end of file diff --git a/project.scala b/project.scala new file mode 100644 index 00000000..657fe202 --- /dev/null +++ b/project.scala @@ -0,0 +1,23 @@ +// Main +//> using scala "2.13.15" +//> using options "-deprecation" + +//> using dependency "com.lihaoyi:::ammonite:3.0.0" +//> using dependency "com.lihaoyi::os-lib:0.11.3" +//> using dependency "com.lihaoyi::upickle:1.5.0" +//> using dependency "io.github.java-diff-utils:java-diff-utils:4.12" +//> using dependency "org.rogach::scallop:5.1.0" +//> using dependency "org.scala-lang.modules::scala-parser-combinators:2.4.0" +//> using dependency "org.scala-lang:scala-reflect:2.13.15" + +//> using exclude "systems/" + +// Test +//> using testFramework org.scalatest.tools.Framework +//> using test.dependency "com.github.daddykotex::courier:3.2.0" +//> using test.dependency "com.lihaoyi::mainargs:0.7.6" +//> using test.dependency "com.lihaoyi::pprint:0.9.0" +//> using test.dependency "com.lihaoyi::upickle:4.0.2" +//> using test.dependency "org.scalacheck::scalacheck:1.18.1" +//> using test.dependency "org.scalatest::scalatest:3.2.19" + diff --git a/test/pgo/util/TLAExpressionFuzzTestUtils.scala b/test/pgo/util/TLAExpressionFuzzTestUtils.scala index dcbed9b3..11a52488 100644 --- a/test/pgo/util/TLAExpressionFuzzTestUtils.scala +++ b/test/pgo/util/TLAExpressionFuzzTestUtils.scala @@ -17,7 +17,9 @@ import scala.util.control.NonFatal import scala.util.{Failure, Success} trait TLAExpressionFuzzTestUtils { - final class TLAExpressionFuzzTestProps(seedStr: String, workDir: os.Path) extends Properties("TLAExpression") { + private abstract class TLAExpressionFuzzTestProps extends Properties("TLAExpression") { + def seedStr: String + def workDir: os.Path import org.scalacheck.Prop._ private val testFile = workDir / "TestBed.tla" @@ -171,13 +173,16 @@ trait TLAExpressionFuzzTestUtils { def runExpressionFuzzTesting(seed: Seed = Seed.random(), dealWithGoCache: Boolean = false): FuzzTestingResult = { var resultCatcher: Option[Test.Result] = None - val seedStr = seed.toBase64 + val _seedStr = seed.toBase64 if(dealWithGoCache) { os.proc("go", "clean", "-cache").call() } - val workDir = os.temp.dir(deleteOnExit = false) + val _workDir = os.temp.dir(deleteOnExit = false) try { - val props = new TLAExpressionFuzzTestProps(seedStr = seedStr, workDir = workDir) + object props extends TLAExpressionFuzzTestProps { + def seedStr = _seedStr + def workDir = _workDir + } Test.checkProperties( prms = Test.Parameters.default .withInitialSeed(seed) @@ -193,7 +198,7 @@ trait TLAExpressionFuzzTestUtils { FuzzTestingResult( success = resultCatcher.get.passed, - seed = seedStr, + seed = _seedStr, cases = props.cases, degenerateCases = props.degenerateCases, testOut = props.testOut, @@ -203,7 +208,7 @@ trait TLAExpressionFuzzTestUtils { nodeFrequencies = props.nodeFrequencies, treeSizes = props.treeSizes) } finally { - os.remove.all(workDir) + os.remove.all(_workDir) } }