From 5784da80de4f2053847cb4d4ef13d029e5cb75d2 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Tue, 5 Apr 2022 15:18:15 +0300 Subject: [PATCH 01/43] added counter handling --- .github/workflows/github-ci.yml | 31 +++++++++++++++++++++++++++++++ transpiler/pom.xml | 2 ++ 2 files changed, 33 insertions(+) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index 4c47714eb..1fb596427 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -113,3 +113,34 @@ jobs: with: name: generatedJava path: /Users/runner/work/py2eo/py2eo/python/python3/test/target/generated-sources/ + + counter: + strategy: + matrix: + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + needs: build + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 14 + uses: actions/setup-java@v2 + with: + java-version: '14' + distribution: 'adopt' + - uses: actions/setup-python@v2 + with: + python-version: '3.8.10' + - name: Build with Maven + run: mvn clean verify -B -DignoreFail=false + - name: archive artifacts + uses: actions/upload-artifact@v2 + with: + name: artifacts + path: | + transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo + scalastyle-output.xml + - name: archive jar + uses: actions/upload-artifact@v2 + with: + name: package + path: transpiler/target/transpiler-0.0.1-SNAPSHOT-jar-with-dependencies.jar \ No newline at end of file diff --git a/transpiler/pom.xml b/transpiler/pom.xml index c38916073..6d24d7ca7 100644 --- a/transpiler/pom.xml +++ b/transpiler/pom.xml @@ -17,6 +17,7 @@ 14 UTF-8 2.13.6 + false @@ -84,6 +85,7 @@ **/Test*.* **/*Suite.* + ${ignoreFail} From 77505c86bef7017e3a26224cf5d3e81d232f31f9 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Fri, 8 Apr 2022 14:58:46 +0300 Subject: [PATCH 02/43] added running tests via CI --- .github/workflows/github-ci.yml | 49 ++------- runEO/pom.xml | 3 +- .../org/polystat/py2eo/transpiler/Main.scala | 13 +++ .../py2eo/transpiler/TestsChecker.scala | 100 ++++++++++++++++++ 4 files changed, 125 insertions(+), 40 deletions(-) create mode 100644 transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index 1fb596427..335eabe47 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -43,16 +43,18 @@ jobs: path: | transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo scalastyle-output.xml + - name: Rename jar + run: cp transpiler/target/transpiler-*-jar-with-dependencies.jar transpiler.jar - name: archive jar uses: actions/upload-artifact@v2 with: name: package - path: transpiler/target/transpiler-0.0.1-SNAPSHOT-jar-with-dependencies.jar + path: transpiler.jar polystatIntegration: strategy: - matrix: - os: [ ubuntu-latest ] + matrix: + os: [ ubuntu-latest ] runs-on: ${{ matrix.os }} needs: test steps: @@ -68,10 +70,10 @@ jobs: with: name: package - - name: download polystat + - name: download polystat run: wget https://repo.maven.apache.org/maven2/org/polystat/polystat/0.4.0/polystat-0.4.0-jar-with-dependencies.jar - name: translate python - run: java -jar ./transpiler-0.0.1-SNAPSHOT-jar-with-dependencies.jar ./transpiler/src/test/resources/org/polystat/py2eo/transpiler/integrationTests/test.py + run: java -jar ./transpiler.jar ./transpiler/src/test/resources/org/polystat/py2eo/transpiler/integrationTests/test.py - name: analysis run: cp ./transpiler/src/test/resources/org/polystat/py2eo/transpiler/integrationTests/genCageEO/test.eo ./transpiler/src/test.eo && cp ./transpiler/src/test/resources/org/polystat/py2eo/transpiler/integrationTests/goto.eo ./transpiler/src/goto.eo && java -jar ./polystat-0.4.0-jar-with-dependencies.jar ./transpiler/src ./temp --sarif - name: upload artifacts @@ -83,8 +85,8 @@ jobs: uses: actions/upload-artifact@v2 if: always() with: - name: py2eo output - path: ./transpiler/src/test.eo + name: py2eo output + path: ./transpiler/src/test.eo runEO: @@ -107,40 +109,9 @@ jobs: name: artifacts path: ./ - name: Build with Maven - run: cd ./runEO && mvn clean test && ls -la ./target/eo-test/04-pull/org/eolang/ + run: cd ./runEO && mvn clean test -DpathToEo="transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo" && ls -la ./target/eo-test/04-pull/org/eolang/ - name: upload artifacts uses: actions/upload-artifact@v2 with: name: generatedJava path: /Users/runner/work/py2eo/py2eo/python/python3/test/target/generated-sources/ - - counter: - strategy: - matrix: - os: [ubuntu-latest] - runs-on: ${{ matrix.os }} - needs: build - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 14 - uses: actions/setup-java@v2 - with: - java-version: '14' - distribution: 'adopt' - - uses: actions/setup-python@v2 - with: - python-version: '3.8.10' - - name: Build with Maven - run: mvn clean verify -B -DignoreFail=false - - name: archive artifacts - uses: actions/upload-artifact@v2 - with: - name: artifacts - path: | - transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo - scalastyle-output.xml - - name: archive jar - uses: actions/upload-artifact@v2 - with: - name: package - path: transpiler/target/transpiler-0.0.1-SNAPSHOT-jar-with-dependencies.jar \ No newline at end of file diff --git a/runEO/pom.xml b/runEO/pom.xml index e10755461..de4d518cc 100644 --- a/runEO/pom.xml +++ b/runEO/pom.xml @@ -10,6 +10,7 @@ 0.21.7 11 11 + ${eo_path} @@ -51,7 +52,7 @@ ${project.baseDir}/../../ - transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo + ${eo_path} ${project.basedir}/target/eo-test false diff --git a/transpiler/src/main/scala/org/polystat/py2eo/transpiler/Main.scala b/transpiler/src/main/scala/org/polystat/py2eo/transpiler/Main.scala index f5ec3cd02..709d8bdb2 100644 --- a/transpiler/src/main/scala/org/polystat/py2eo/transpiler/Main.scala +++ b/transpiler/src/main/scala/org/polystat/py2eo/transpiler/Main.scala @@ -77,4 +77,17 @@ object Main { output.close() outName } + + + def writeEOFile(test: File, dirSuffix: String, fileSuffix: String, what: String, otherLocation: Boolean = false): File = { + val moduleName = test.getName.substring(0, test.getName.lastIndexOf(".")) + val outPath = if (!otherLocation) test.getAbsoluteFile.getParentFile.getPath + "/" + dirSuffix else dirSuffix + val d = new File(outPath) + if (!d.exists()) d.mkdir() + val outName = outPath + "/" + moduleName + fileSuffix + val output = new FileWriter(outName) + output.write(what) + output.close() + new File(outName) + } } diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala new file mode 100644 index 000000000..986f15e71 --- /dev/null +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala @@ -0,0 +1,100 @@ +package org.polystat.py2eo.transpiler + +import jdk.internal.vm.vector.VectorSupport.test +import org.junit.Assert.fail +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.Parameterized +import org.junit.runners.Parameterized.Parameters +import org.polystat.py2eo.transpiler.Main.{debugPrinter, writeEOFile} +import org.yaml.snakeyaml.Yaml +import org.yaml.snakeyaml.error.YAMLException + +import java.io.{File, FileInputStream} +import java.nio.file.{Files, Path} +import java.util.concurrent.TimeUnit +import java.{lang => jl, util => ju} +import scala.reflect.io.Directory + + +@RunWith(value = classOf[Parameterized]) +class TestsChecker (path: jl.String) { + val testsPrefix: String = getClass.getResource("").getFile + private val resourcesPath = Directory.Current.get / "checker/src/test/resources/org/polystat/py2eo/checker" + private val runEOPath = resourcesPath / "runEO" + + case class YamlTest(python: String, disabled: Boolean) + + def yaml2python(f: File): YamlTest = { + val yaml = new Yaml() + val map = yaml.load[java.util.Map[String, String]](new FileInputStream(f)) + + YamlTest(map.get("python"), map.containsKey("disabled") && map.getOrDefault("disabled", "false").asInstanceOf[Boolean]) + } + + def useCageHolder(test: File): Unit = { + def db = debugPrinter(test)(_, _) + + val z = yaml2python(test) + + if (!z.disabled) { + val res = Transpile(test.getName.replace(".yaml", ""), + z.python) + + res match { + case None => fail(s"could not transpile ${test.getName}"); + case Some(transpiled) => + val path = writeEOFile( + test, "genCageEO", ".eo", transpiled + ) + + if(!run(path)){ + fail(s"could not run EO ${test.getName}") + } + } + } + } + + + private def run(file: File):Boolean = { + val dir = new java.io.File(runEOPath.jfile.getPath) + val process = new ProcessBuilder(s"mvn clean test -DpathToEo=\"$file\"").directory(dir).start + val ret = process.waitFor(40, TimeUnit.SECONDS) + + Files delete test + + if (ret) { + process.exitValue == 0 + } else { + false + } + } + + @Test def testDef(): Unit = { + useCageHolder(new File(path)) + } +} + +object TestsChecker { + @Parameters def parameters: ju.Collection[Array[jl.String]] = { + val testsPrefix = System.getProperty("user.dir") + "/src/test/resources/org/polystat/py2eo/transpiler" + + val res = collection.mutable.ArrayBuffer[String]() + val simpleTestsFolder = new File(testsPrefix + File.separator + "simple-tests" + File.separator) + Files.walk(simpleTestsFolder.toPath).filter((p: Path) => p.toString.endsWith(".yaml")).forEach((p: Path) => { + val testHolder = new File(p.toString) + try { + println(testHolder.getPath) + res.addOne(p.toString) + } catch { + case e: YAMLException => println(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") + case e: ClassCastException => println(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") + } + }) + + + val list = new ju.ArrayList[Array[jl.String]]() + res.foreach(n => list.add(Array(n))) + list + } +} \ No newline at end of file From 2dad15921e2d8708006a8f5e25102f6ae584a7d3 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Tue, 12 Apr 2022 12:01:46 +0300 Subject: [PATCH 03/43] added counting test --- .github/workflows/github-ci.yml | 35 +++++++ transpiler/pom.xml | 28 ++++++ .../py2eo/transpiler/TestSingle.scala | 98 +++++++++++++++++++ 3 files changed, 161 insertions(+) create mode 100644 transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index 335eabe47..77cfa97af 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -115,3 +115,38 @@ jobs: with: name: generatedJava path: /Users/runner/work/py2eo/py2eo/python/python3/test/target/generated-sources/ + + + + counter: + strategy: + matrix: + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + needs: build + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 14 + uses: actions/setup-java@v2 + with: + java-version: '14' + distribution: 'adopt' + - uses: actions/setup-python@v2 + with: + python-version: '3.8.10' + - name: Build with Maven + run: mvn clean verify -B -PsingleTest + - name: archive artifacts + uses: actions/upload-artifact@v2 + with: + name: artifacts + path: | + transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo + scalastyle-output.xml + - name: Rename jar + run: cp transpiler/target/transpiler-*-jar-with-dependencies.jar transpiler.jar + - name: archive jar + uses: actions/upload-artifact@v2 + with: + name: package + path: transpiler.jar diff --git a/transpiler/pom.xml b/transpiler/pom.xml index 6d24d7ca7..4d9a6c371 100644 --- a/transpiler/pom.xml +++ b/transpiler/pom.xml @@ -18,6 +18,7 @@ UTF-8 2.13.6 false + @@ -51,6 +52,33 @@ + + + + singleTest + + false + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + **/TestSingle** + + ${ignoreFail} + + + + + + + diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala new file mode 100644 index 000000000..f95267ccd --- /dev/null +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala @@ -0,0 +1,98 @@ +package org.polystat.py2eo.transpiler + +import jdk.internal.vm.vector.VectorSupport.test +import org.junit.Assert.fail +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.Parameterized +import org.junit.runners.Parameterized.Parameters +import org.polystat.py2eo.transpiler.Main.writeEOFile +import org.yaml.snakeyaml.Yaml +import org.yaml.snakeyaml.error.YAMLException + +import java.io.{File, FileInputStream} +import java.nio.file.{Files, Path} +import java.util.concurrent.TimeUnit +import java.{lang => jl, util => ju} +import scala.reflect.io.Directory + + +@RunWith(value = classOf[Parameterized]) +class TestSingle(path: jl.String) { + val testsPrefix: String = getClass.getResource("").getFile + private val resourcesPath = Directory.Current.get / "checker/src/test/resources/org/polystat/py2eo/checker" + private val runEOPath = resourcesPath / "runEO" + + case class YamlTest(python: String) + + def yaml2python(f: File): YamlTest = { + val yaml = new Yaml() + val map = yaml.load[java.util.Map[String, String]](new FileInputStream(f)) + + YamlTest(map.get("python")) + } + + def useCageHolder(test: File): Unit = { + val z = yaml2python(test) + + val res = Transpile(test.getName.replace(".yaml", ""), + z.python) + + res match { + case None => fail(s"could not transpile ${test.getName}"); + case Some(transpiled) => + val path = writeEOFile( + test, "genCageEO", ".eo", transpiled + ) + + if(!run(path)){ + fail(s"could not run EO ${test.getName}") + } + } + } + + + private def run(file: File):Boolean = { + val dir = new java.io.File(runEOPath.jfile.getPath) + val process = new ProcessBuilder(s"mvn clean test -DpathToEo=\"$file\"").directory(dir).start + val ret = process.waitFor(40, TimeUnit.SECONDS) + + Files delete test + + if (ret) { + process.exitValue == 0 + } else { + false + } + } + + @Test def testDef(): Unit = { + useCageHolder(new File(path)) + } +} + + +object TestSingle { + @Parameters def parameters: ju.Collection[Array[jl.String]] = { + val testsPrefix = System.getProperty("user.dir") + "/src/test/resources/org/polystat/py2eo/transpiler" + + val res = collection.mutable.ArrayBuffer[String]() + val simpleTestsFolder = new File(testsPrefix + File.separator + "simple-tests" + File.separator) + Files.walk(simpleTestsFolder.toPath).filter((p: Path) => p.toString.endsWith(".yaml")).forEach((p: Path) => { + val testHolder = new File(p.toString) + try { + println(testHolder.getPath) + res.addOne(p.toString) + } catch { + case e: YAMLException => println(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") + case e: ClassCastException => println(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") + } + }) + + + val list = new ju.ArrayList[Array[jl.String]]() + res.foreach(n => list.add(Array(n))) + list + } +} + From d3d0771f62bb38aa0dcd6efec429c9eaa36e7376 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Tue, 12 Apr 2022 12:11:35 +0300 Subject: [PATCH 04/43] fix CI --- .github/workflows/github-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index 77cfa97af..324b79034 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -135,7 +135,7 @@ jobs: with: python-version: '3.8.10' - name: Build with Maven - run: mvn clean verify -B -PsingleTest + run: mvn clean verify -B -PsingleTest -X - name: archive artifacts uses: actions/upload-artifact@v2 with: From 26222808f12d668c3a2d991555c52e7474749a42 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Tue, 12 Apr 2022 12:49:16 +0300 Subject: [PATCH 05/43] fix CI --- .../scala/org/polystat/py2eo/transpiler/TestSingle.scala | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala index f95267ccd..ee01b77df 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala @@ -1,6 +1,5 @@ package org.polystat.py2eo.transpiler -import jdk.internal.vm.vector.VectorSupport.test import org.junit.Assert.fail import org.junit.Test import org.junit.runner.RunWith @@ -20,7 +19,7 @@ import scala.reflect.io.Directory @RunWith(value = classOf[Parameterized]) class TestSingle(path: jl.String) { val testsPrefix: String = getClass.getResource("").getFile - private val resourcesPath = Directory.Current.get / "checker/src/test/resources/org/polystat/py2eo/checker" + private val resourcesPath = Directory.Current.get / "checker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checker" private val runEOPath = resourcesPath / "runEO" case class YamlTest(python: String) @@ -57,8 +56,6 @@ class TestSingle(path: jl.String) { val process = new ProcessBuilder(s"mvn clean test -DpathToEo=\"$file\"").directory(dir).start val ret = process.waitFor(40, TimeUnit.SECONDS) - Files delete test - if (ret) { process.exitValue == 0 } else { From e5ce71675e8209e7320dfcc28dfe9d8b7667d16e Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Tue, 12 Apr 2022 14:11:05 +0300 Subject: [PATCH 06/43] fix CI --- pom.xml | 2 +- .../scala/org/polystat/py2eo/transpiler/TestsChecker.scala | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 9ac3fd2a1..eefbce644 100644 --- a/pom.xml +++ b/pom.xml @@ -91,7 +91,7 @@ ${project.build.directory}/scalastyle_2.13-1.5.1-assembly.jar -c ${project.basedir}/scalastyle_config.xml - ${project.basedir}/transpiler + ${project.basedir}/transpiler/src/main ${project.basedir}/parser diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala index 986f15e71..d3dd6ace7 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala @@ -1,6 +1,5 @@ package org.polystat.py2eo.transpiler -import jdk.internal.vm.vector.VectorSupport.test import org.junit.Assert.fail import org.junit.Test import org.junit.runner.RunWith @@ -61,8 +60,6 @@ class TestsChecker (path: jl.String) { val process = new ProcessBuilder(s"mvn clean test -DpathToEo=\"$file\"").directory(dir).start val ret = process.waitFor(40, TimeUnit.SECONDS) - Files delete test - if (ret) { process.exitValue == 0 } else { From 3fe4bbf8ce5d8d094902037fa3cc66b46e9d9487 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Tue, 12 Apr 2022 14:36:43 +0300 Subject: [PATCH 07/43] fix CI --- .../scala/org/polystat/py2eo/transpiler/TestsChecker.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala index d3dd6ace7..e6b2fa6a9 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala @@ -19,8 +19,8 @@ import scala.reflect.io.Directory @RunWith(value = classOf[Parameterized]) class TestsChecker (path: jl.String) { val testsPrefix: String = getClass.getResource("").getFile - private val resourcesPath = Directory.Current.get / "checker/src/test/resources/org/polystat/py2eo/checker" - private val runEOPath = resourcesPath / "runEO" + private val resourcesPath = Directory.Current.get / "runEO" + case class YamlTest(python: String, disabled: Boolean) @@ -56,7 +56,7 @@ class TestsChecker (path: jl.String) { private def run(file: File):Boolean = { - val dir = new java.io.File(runEOPath.jfile.getPath) + val dir = new java.io.File(resourcesPath.jfile.getPath) val process = new ProcessBuilder(s"mvn clean test -DpathToEo=\"$file\"").directory(dir).start val ret = process.waitFor(40, TimeUnit.SECONDS) From 684374b228c609dbf1329ffe2ca8e2a8af0eb5e5 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Tue, 12 Apr 2022 16:35:25 +0300 Subject: [PATCH 08/43] fix CI --- .../scala/org/polystat/py2eo/transpiler/TestSingle.scala | 3 +-- .../scala/org/polystat/py2eo/transpiler/TestsChecker.scala | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala index ee01b77df..c60c7a3b5 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala @@ -19,8 +19,7 @@ import scala.reflect.io.Directory @RunWith(value = classOf[Parameterized]) class TestSingle(path: jl.String) { val testsPrefix: String = getClass.getResource("").getFile - private val resourcesPath = Directory.Current.get / "checker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checkerchecker/src/test/resources/org/polystat/py2eo/checker" - private val runEOPath = resourcesPath / "runEO" + private val runEOPath = Directory.Current.get / "runEO" case class YamlTest(python: String) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala index e6b2fa6a9..d3dd6ace7 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala @@ -19,8 +19,8 @@ import scala.reflect.io.Directory @RunWith(value = classOf[Parameterized]) class TestsChecker (path: jl.String) { val testsPrefix: String = getClass.getResource("").getFile - private val resourcesPath = Directory.Current.get / "runEO" - + private val resourcesPath = Directory.Current.get / "checker/src/test/resources/org/polystat/py2eo/checker" + private val runEOPath = resourcesPath / "runEO" case class YamlTest(python: String, disabled: Boolean) @@ -56,7 +56,7 @@ class TestsChecker (path: jl.String) { private def run(file: File):Boolean = { - val dir = new java.io.File(resourcesPath.jfile.getPath) + val dir = new java.io.File(runEOPath.jfile.getPath) val process = new ProcessBuilder(s"mvn clean test -DpathToEo=\"$file\"").directory(dir).start val ret = process.waitFor(40, TimeUnit.SECONDS) From c74e76890a5813f8e079a2f28b284583f5b3f335 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Tue, 12 Apr 2022 20:05:47 +0300 Subject: [PATCH 09/43] fix CI --- .../py2eo/transpiler/TestSingle.scala | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala index c60c7a3b5..0cdffc853 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala @@ -10,16 +10,18 @@ import org.yaml.snakeyaml.Yaml import org.yaml.snakeyaml.error.YAMLException import java.io.{File, FileInputStream} +import java.nio.file.StandardCopyOption.REPLACE_EXISTING import java.nio.file.{Files, Path} import java.util.concurrent.TimeUnit -import java.{lang => jl, util => ju} +import java.{ lang => jl, util => ju} +import scala.language.postfixOps import scala.reflect.io.Directory @RunWith(value = classOf[Parameterized]) class TestSingle(path: jl.String) { val testsPrefix: String = getClass.getResource("").getFile - private val runEOPath = Directory.Current.get / "runEO" + private val runEOPath = Directory.Current.get.jfile + "/runEO" case class YamlTest(python: String) @@ -49,12 +51,34 @@ class TestSingle(path: jl.String) { } } +// private def compile(file: File): Boolean = { +// val path = Path.of(s"D:\\EO\\py2eo\\runEO\\${file.getName}") +// val result = Files.copy(file.toPath, path, REPLACE_EXISTING) +// val ret = Process(s"mvn clean test -DpathToEo=${new File(result.toString)}", new File("D:\\EO\\py2eo\\runEO")).! == 0 +// +// Files delete result +// +// ret +// } + private def run(file: File):Boolean = { - val dir = new java.io.File(runEOPath.jfile.getPath) - val process = new ProcessBuilder(s"mvn clean test -DpathToEo=\"$file\"").directory(dir).start + //val result = new File(runEOPath + s"/${file.getName}") + //val path = Path.of(runEOPath + s"/${file.getName}") + val path = Path.of(s"D:\\EO\\py2eo\\runEO\\${file.getName}") + val test = Files.copy(file.toPath, path, REPLACE_EXISTING).toAbsolutePath + println(test) + val dir = new java.io.File("D:\\EO\\py2eo\\runEO\\") + //var pb = new ProcessBuilder("mvn", "clean", "test", s"-DpathToEo=\"$test\"") + var pb = new ProcessBuilder("mvn", "clean", "test", s"-DpathToEo=\"$test\"") + pb = pb.directory(dir) + pb.inheritIO() + val process = pb.start val ret = process.waitFor(40, TimeUnit.SECONDS) + + Files.delete(test) + if (ret) { process.exitValue == 0 } else { From 7113cb175247189f623f6d092f7f35b1ee04561c Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Tue, 12 Apr 2022 20:15:41 +0300 Subject: [PATCH 10/43] fix CI --- .../test/scala/org/polystat/py2eo/transpiler/TestSingle.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala index 0cdffc853..81c61a732 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala @@ -65,10 +65,10 @@ class TestSingle(path: jl.String) { private def run(file: File):Boolean = { //val result = new File(runEOPath + s"/${file.getName}") //val path = Path.of(runEOPath + s"/${file.getName}") - val path = Path.of(s"D:\\EO\\py2eo\\runEO\\${file.getName}") + val path = Path.of(s"$runEOPath/${file.getName}") val test = Files.copy(file.toPath, path, REPLACE_EXISTING).toAbsolutePath println(test) - val dir = new java.io.File("D:\\EO\\py2eo\\runEO\\") + val dir = new java.io.File(runEOPath) //var pb = new ProcessBuilder("mvn", "clean", "test", s"-DpathToEo=\"$test\"") var pb = new ProcessBuilder("mvn", "clean", "test", s"-DpathToEo=\"$test\"") pb = pb.directory(dir) From 0843fc517e3c971d5ee61d7cc82ac950c2b633b3 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Wed, 13 Apr 2022 15:56:14 +0300 Subject: [PATCH 11/43] fix CI --- transpiler/pom.xml | 2 +- .../transpiler/{TestSingle.scala => Counter.scala} | 14 ++------------ 2 files changed, 3 insertions(+), 13 deletions(-) rename transpiler/src/test/scala/org/polystat/py2eo/transpiler/{TestSingle.scala => Counter.scala} (88%) diff --git a/transpiler/pom.xml b/transpiler/pom.xml index 4d9a6c371..306a91ea9 100644 --- a/transpiler/pom.xml +++ b/transpiler/pom.xml @@ -69,7 +69,7 @@ - **/TestSingle** + **/Counter** ${ignoreFail} diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala similarity index 88% rename from transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala rename to transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala index 81c61a732..95df918d0 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestSingle.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala @@ -19,7 +19,7 @@ import scala.reflect.io.Directory @RunWith(value = classOf[Parameterized]) -class TestSingle(path: jl.String) { +class Counter(path: jl.String) { val testsPrefix: String = getClass.getResource("").getFile private val runEOPath = Directory.Current.get.jfile + "/runEO" @@ -51,16 +51,6 @@ class TestSingle(path: jl.String) { } } -// private def compile(file: File): Boolean = { -// val path = Path.of(s"D:\\EO\\py2eo\\runEO\\${file.getName}") -// val result = Files.copy(file.toPath, path, REPLACE_EXISTING) -// val ret = Process(s"mvn clean test -DpathToEo=${new File(result.toString)}", new File("D:\\EO\\py2eo\\runEO")).! == 0 -// -// Files delete result -// -// ret -// } - private def run(file: File):Boolean = { //val result = new File(runEOPath + s"/${file.getName}") @@ -92,7 +82,7 @@ class TestSingle(path: jl.String) { } -object TestSingle { +object Counter { @Parameters def parameters: ju.Collection[Array[jl.String]] = { val testsPrefix = System.getProperty("user.dir") + "/src/test/resources/org/polystat/py2eo/transpiler" From 9b8acea152b0277f0abcbbaf24f075bf80a53655 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Wed, 13 Apr 2022 16:36:42 +0300 Subject: [PATCH 12/43] fix CI --- .../py2eo/transpiler/TestsChecker.scala | 97 ------------------- 1 file changed, 97 deletions(-) delete mode 100644 transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala deleted file mode 100644 index d3dd6ace7..000000000 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsChecker.scala +++ /dev/null @@ -1,97 +0,0 @@ -package org.polystat.py2eo.transpiler - -import org.junit.Assert.fail -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.Parameterized -import org.junit.runners.Parameterized.Parameters -import org.polystat.py2eo.transpiler.Main.{debugPrinter, writeEOFile} -import org.yaml.snakeyaml.Yaml -import org.yaml.snakeyaml.error.YAMLException - -import java.io.{File, FileInputStream} -import java.nio.file.{Files, Path} -import java.util.concurrent.TimeUnit -import java.{lang => jl, util => ju} -import scala.reflect.io.Directory - - -@RunWith(value = classOf[Parameterized]) -class TestsChecker (path: jl.String) { - val testsPrefix: String = getClass.getResource("").getFile - private val resourcesPath = Directory.Current.get / "checker/src/test/resources/org/polystat/py2eo/checker" - private val runEOPath = resourcesPath / "runEO" - - case class YamlTest(python: String, disabled: Boolean) - - def yaml2python(f: File): YamlTest = { - val yaml = new Yaml() - val map = yaml.load[java.util.Map[String, String]](new FileInputStream(f)) - - YamlTest(map.get("python"), map.containsKey("disabled") && map.getOrDefault("disabled", "false").asInstanceOf[Boolean]) - } - - def useCageHolder(test: File): Unit = { - def db = debugPrinter(test)(_, _) - - val z = yaml2python(test) - - if (!z.disabled) { - val res = Transpile(test.getName.replace(".yaml", ""), - z.python) - - res match { - case None => fail(s"could not transpile ${test.getName}"); - case Some(transpiled) => - val path = writeEOFile( - test, "genCageEO", ".eo", transpiled - ) - - if(!run(path)){ - fail(s"could not run EO ${test.getName}") - } - } - } - } - - - private def run(file: File):Boolean = { - val dir = new java.io.File(runEOPath.jfile.getPath) - val process = new ProcessBuilder(s"mvn clean test -DpathToEo=\"$file\"").directory(dir).start - val ret = process.waitFor(40, TimeUnit.SECONDS) - - if (ret) { - process.exitValue == 0 - } else { - false - } - } - - @Test def testDef(): Unit = { - useCageHolder(new File(path)) - } -} - -object TestsChecker { - @Parameters def parameters: ju.Collection[Array[jl.String]] = { - val testsPrefix = System.getProperty("user.dir") + "/src/test/resources/org/polystat/py2eo/transpiler" - - val res = collection.mutable.ArrayBuffer[String]() - val simpleTestsFolder = new File(testsPrefix + File.separator + "simple-tests" + File.separator) - Files.walk(simpleTestsFolder.toPath).filter((p: Path) => p.toString.endsWith(".yaml")).forEach((p: Path) => { - val testHolder = new File(p.toString) - try { - println(testHolder.getPath) - res.addOne(p.toString) - } catch { - case e: YAMLException => println(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") - case e: ClassCastException => println(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") - } - }) - - - val list = new ju.ArrayList[Array[jl.String]]() - res.foreach(n => list.add(Array(n))) - list - } -} \ No newline at end of file From 9ca447e887d9fa7b6b7d94f4e08975f8a765c62c Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Fri, 15 Apr 2022 13:19:13 +0300 Subject: [PATCH 13/43] fix CI --- .../polystat/py2eo/transpiler/Counter.scala | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala index 95df918d0..1edada5c5 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala @@ -10,10 +10,9 @@ import org.yaml.snakeyaml.Yaml import org.yaml.snakeyaml.error.YAMLException import java.io.{File, FileInputStream} -import java.nio.file.StandardCopyOption.REPLACE_EXISTING -import java.nio.file.{Files, Path} +import java.nio.file.{Files, Path, Paths, StandardCopyOption} import java.util.concurrent.TimeUnit -import java.{ lang => jl, util => ju} +import java.{lang => jl, util => ju} import scala.language.postfixOps import scala.reflect.io.Directory @@ -56,18 +55,27 @@ class Counter(path: jl.String) { //val result = new File(runEOPath + s"/${file.getName}") //val path = Path.of(runEOPath + s"/${file.getName}") val path = Path.of(s"$runEOPath/${file.getName}") - val test = Files.copy(file.toPath, path, REPLACE_EXISTING).toAbsolutePath - println(test) + + val pathResult = Files.move( + Paths.get(file.getPath), + path, + StandardCopyOption.REPLACE_EXISTING + ) + + + +// val test = Files.copy(file.toPath, path, REPLACE_EXISTING).toAbsolutePath +// println(test) val dir = new java.io.File(runEOPath) //var pb = new ProcessBuilder("mvn", "clean", "test", s"-DpathToEo=\"$test\"") - var pb = new ProcessBuilder("mvn", "clean", "test", s"-DpathToEo=\"$test\"") + var pb = new ProcessBuilder("mvn", "clean", "test", s"-DpathToEo=\"$pathResult\"") pb = pb.directory(dir) pb.inheritIO() val process = pb.start val ret = process.waitFor(40, TimeUnit.SECONDS) - Files.delete(test) + Files.delete(pathResult) if (ret) { process.exitValue == 0 From 6a3e57085d9672b46695c41c19de153aec0a8d0b Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Fri, 15 Apr 2022 13:27:19 +0300 Subject: [PATCH 14/43] fix CI --- .../src/test/scala/org/polystat/py2eo/transpiler/Counter.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala index 1edada5c5..6614b3821 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala @@ -14,13 +14,12 @@ import java.nio.file.{Files, Path, Paths, StandardCopyOption} import java.util.concurrent.TimeUnit import java.{lang => jl, util => ju} import scala.language.postfixOps -import scala.reflect.io.Directory @RunWith(value = classOf[Parameterized]) class Counter(path: jl.String) { val testsPrefix: String = getClass.getResource("").getFile - private val runEOPath = Directory.Current.get.jfile + "/runEO" + private val runEOPath = Paths.get(".").toAbsolutePath.getParent.getParent + "/runEO" case class YamlTest(python: String) From c32f5de23850156ad13b9e4711e85689f6f6341b Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Thu, 21 Apr 2022 12:43:45 +0300 Subject: [PATCH 15/43] fix CI --- transpiler/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/transpiler/pom.xml b/transpiler/pom.xml index 306a91ea9..1450c4bff 100644 --- a/transpiler/pom.xml +++ b/transpiler/pom.xml @@ -71,6 +71,10 @@ **/Counter** + + **/Test*.* + **/*Suite.* + ${ignoreFail} From 9b7e9b754df0c3398b300d0475b7572adcb471b6 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Thu, 21 Apr 2022 12:57:49 +0300 Subject: [PATCH 16/43] fix CI --- .../scala/org/polystat/py2eo/transpiler/Counter.scala | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala index 6614b3821..812c56b69 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala @@ -21,20 +21,17 @@ class Counter(path: jl.String) { val testsPrefix: String = getClass.getResource("").getFile private val runEOPath = Paths.get(".").toAbsolutePath.getParent.getParent + "/runEO" - case class YamlTest(python: String) - - def yaml2python(f: File): YamlTest = { + def yaml2python(f: File): String = { val yaml = new Yaml() val map = yaml.load[java.util.Map[String, String]](new FileInputStream(f)) - YamlTest(map.get("python")) + map.get("python") } def useCageHolder(test: File): Unit = { val z = yaml2python(test) - val res = Transpile(test.getName.replace(".yaml", ""), - z.python) + val res = Transpile(test.getName.replace(".yaml", ""), z) res match { case None => fail(s"could not transpile ${test.getName}"); From eeec5ff5905f5c6b4395ed169ed0c26b72dab9b7 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Tue, 26 Apr 2022 14:35:40 +0300 Subject: [PATCH 17/43] added handling for yaml fields --- .../org/polystat/py2eo/transpiler/Counter.scala | 14 ++++++++++---- .../polystat/py2eo/transpiler/TestsSimple.scala | 13 ++++++++++--- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala index 812c56b69..193185c81 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala @@ -94,12 +94,18 @@ object Counter { val simpleTestsFolder = new File(testsPrefix + File.separator + "simple-tests" + File.separator) Files.walk(simpleTestsFolder.toPath).filter((p: Path) => p.toString.endsWith(".yaml")).forEach((p: Path) => { val testHolder = new File(p.toString) + val yaml = new Yaml() + val map = yaml.load[java.util.Map[String, String]](new FileInputStream(testHolder)) + try { - println(testHolder.getPath) - res.addOne(p.toString) + if (map.containsKey("enabled") && !map.getOrDefault("enabled", "false").asInstanceOf[Boolean]){ + res.addOne(p.toString) + }else{ + println(s"The test ${testHolder.getName} is disabled") + } } catch { - case e: YAMLException => println(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") - case e: ClassCastException => println(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") + case e: YAMLException => fail(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") + case e: ClassCastException => fail(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") } }) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsSimple.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsSimple.scala index b5086938e..32dbc8776 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsSimple.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsSimple.scala @@ -5,13 +5,13 @@ import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized import org.junit.runners.Parameterized.Parameters +import org.yaml.snakeyaml.Yaml import org.yaml.snakeyaml.error.YAMLException -import java.io.File +import java.io.{File, FileInputStream} import java.nio.file.{Files, Path} import java.{lang => jl, util => ju} - @RunWith(value = classOf[Parameterized]) class TestsSimple(path: jl.String) extends Commons { @Test def testDef(): Unit = { @@ -27,8 +27,15 @@ object TestsSimple { val simpleTestsFolder = new File(testsPrefix + File.separator + "simple-tests" + File.separator) Files.walk(simpleTestsFolder.toPath).filter((p: Path) => p.toString.endsWith(".yaml")).forEach((p: Path) => { val testHolder = new File(p.toString) + val yaml = new Yaml() + val map = yaml.load[java.util.Map[String, String]](new FileInputStream(testHolder)) + try { - res.addOne(p.toString) + if (map.containsKey("enabled") && map.getOrDefault("enabled", "false").asInstanceOf[Boolean]){ + res.addOne(p.toString) + }else{ + println(s"The test ${testHolder.getName} is disabled") + } } catch { case e: YAMLException => fail(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") case e: ClassCastException => fail(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") From 44a08c270cca1854892dca62c7cbd6757a8801ab Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Tue, 26 Apr 2022 14:44:53 +0300 Subject: [PATCH 18/43] fixed gitlab_ci --- .github/workflows/github-ci.yml | 37 +-------------------------------- 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index 324b79034..bf973c996 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -114,39 +114,4 @@ jobs: uses: actions/upload-artifact@v2 with: name: generatedJava - path: /Users/runner/work/py2eo/py2eo/python/python3/test/target/generated-sources/ - - - - counter: - strategy: - matrix: - os: [ubuntu-latest] - runs-on: ${{ matrix.os }} - needs: build - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 14 - uses: actions/setup-java@v2 - with: - java-version: '14' - distribution: 'adopt' - - uses: actions/setup-python@v2 - with: - python-version: '3.8.10' - - name: Build with Maven - run: mvn clean verify -B -PsingleTest -X - - name: archive artifacts - uses: actions/upload-artifact@v2 - with: - name: artifacts - path: | - transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo - scalastyle-output.xml - - name: Rename jar - run: cp transpiler/target/transpiler-*-jar-with-dependencies.jar transpiler.jar - - name: archive jar - uses: actions/upload-artifact@v2 - with: - name: package - path: transpiler.jar + path: /Users/runner/work/py2eo/py2eo/python/python3/test/target/generated-sources/ \ No newline at end of file From ca476b3de04dc71c55ea495f77eb23ee86763038 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Tue, 26 Apr 2022 15:50:51 +0300 Subject: [PATCH 19/43] fix CI --- .../transpiler/{Counter.scala => CounterTests.scala} | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) rename transpiler/src/test/scala/org/polystat/py2eo/transpiler/{Counter.scala => CounterTests.scala} (94%) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/CounterTests.scala similarity index 94% rename from transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala rename to transpiler/src/test/scala/org/polystat/py2eo/transpiler/CounterTests.scala index 193185c81..434278b36 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/CounterTests.scala @@ -17,7 +17,7 @@ import scala.language.postfixOps @RunWith(value = classOf[Parameterized]) -class Counter(path: jl.String) { +class CounterTests(path: jl.String) { val testsPrefix: String = getClass.getResource("").getFile private val runEOPath = Paths.get(".").toAbsolutePath.getParent.getParent + "/runEO" @@ -34,14 +34,14 @@ class Counter(path: jl.String) { val res = Transpile(test.getName.replace(".yaml", ""), z) res match { - case None => fail(s"could not transpile ${test.getName}"); + case None => assume(assumption = true,s"could not transpile ${test.getName}"); case Some(transpiled) => val path = writeEOFile( test, "genCageEO", ".eo", transpiled ) if(!run(path)){ - fail(s"could not run EO ${test.getName}") + assume(assumption = true,s"could not run EO ${test.getName}") } } } @@ -57,9 +57,6 @@ class Counter(path: jl.String) { path, StandardCopyOption.REPLACE_EXISTING ) - - - // val test = Files.copy(file.toPath, path, REPLACE_EXISTING).toAbsolutePath // println(test) val dir = new java.io.File(runEOPath) @@ -86,7 +83,7 @@ class Counter(path: jl.String) { } -object Counter { +object CounterTests { @Parameters def parameters: ju.Collection[Array[jl.String]] = { val testsPrefix = System.getProperty("user.dir") + "/src/test/resources/org/polystat/py2eo/transpiler" From 8e465eecd2b75c4360a069d5bbcc67ba19086a34 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Tue, 26 Apr 2022 16:33:44 +0300 Subject: [PATCH 20/43] renamed Tests --- .../transpiler/{CounterTests.scala => TestCounter.scala} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename transpiler/src/test/scala/org/polystat/py2eo/transpiler/{CounterTests.scala => TestCounter.scala} (98%) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/CounterTests.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestCounter.scala similarity index 98% rename from transpiler/src/test/scala/org/polystat/py2eo/transpiler/CounterTests.scala rename to transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestCounter.scala index 434278b36..94f13c2c4 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/CounterTests.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestCounter.scala @@ -17,7 +17,7 @@ import scala.language.postfixOps @RunWith(value = classOf[Parameterized]) -class CounterTests(path: jl.String) { +class TestCounter(path: jl.String) { val testsPrefix: String = getClass.getResource("").getFile private val runEOPath = Paths.get(".").toAbsolutePath.getParent.getParent + "/runEO" @@ -83,7 +83,7 @@ class CounterTests(path: jl.String) { } -object CounterTests { +object TestCounter { @Parameters def parameters: ju.Collection[Array[jl.String]] = { val testsPrefix = System.getProperty("user.dir") + "/src/test/resources/org/polystat/py2eo/transpiler" From 2aa2a7d727eb005838ed09a1a14e77906f9fa52f Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Wed, 27 Apr 2022 14:49:18 +0300 Subject: [PATCH 21/43] CI processing support --- .github/workflows/github-ci.yml | 36 ++++++++++++++++++- transpiler/pom.xml | 3 +- .../py2eo/transpiler/TestCounter.scala | 4 +-- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index bf973c996..5ee591339 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -114,4 +114,38 @@ jobs: uses: actions/upload-artifact@v2 with: name: generatedJava - path: /Users/runner/work/py2eo/py2eo/python/python3/test/target/generated-sources/ \ No newline at end of file + path: /Users/runner/work/py2eo/py2eo/python/python3/test/target/generated-sources/ + + + counter: + strategy: + matrix: + os: [ ubuntu-latest ] + runs-on: ${{ matrix.os }} + needs: build + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 14 + uses: actions/setup-java@v2 + with: + java-version: '14' + distribution: 'adopt' + - uses: actions/setup-python@v2 + with: + python-version: '3.8.10' + - name: Build with Maven + run: mvn clean verify -B -PsingleTest -X + - name: archive artifacts + uses: actions/upload-artifact@v2 + with: + name: artifacts + path: | + transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo + scalastyle-output.xml + - name: Rename jar + run: cp transpiler/target/transpiler-*-jar-with-dependencies.jar transpiler.jar + - name: archive jar + uses: actions/upload-artifact@v2 + with: + name: package + path: transpiler.jar \ No newline at end of file diff --git a/transpiler/pom.xml b/transpiler/pom.xml index 1450c4bff..ba8a59c09 100644 --- a/transpiler/pom.xml +++ b/transpiler/pom.xml @@ -75,7 +75,7 @@ **/Test*.* **/*Suite.* - ${ignoreFail} + true @@ -117,7 +117,6 @@ **/Test*.* **/*Suite.* - ${ignoreFail} diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestCounter.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestCounter.scala index 94f13c2c4..d8bc9a7b7 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestCounter.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestCounter.scala @@ -34,14 +34,14 @@ class TestCounter(path: jl.String) { val res = Transpile(test.getName.replace(".yaml", ""), z) res match { - case None => assume(assumption = true,s"could not transpile ${test.getName}"); + case None => fail(s"could not transpile ${test.getName}"); case Some(transpiled) => val path = writeEOFile( test, "genCageEO", ".eo", transpiled ) if(!run(path)){ - assume(assumption = true,s"could not run EO ${test.getName}") + fail(s"could not run EO ${test.getName}") } } } From b6f51efa4654ba0a380b16bbdbdf8f13fe595ce6 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Wed, 27 Apr 2022 15:08:34 +0300 Subject: [PATCH 22/43] renamed files for CI --- .../py2eo/transpiler/{TestCounter.scala => Counter.scala} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename transpiler/src/test/scala/org/polystat/py2eo/transpiler/{TestCounter.scala => Counter.scala} (98%) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestCounter.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala similarity index 98% rename from transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestCounter.scala rename to transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala index d8bc9a7b7..2e134f202 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestCounter.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala @@ -17,7 +17,7 @@ import scala.language.postfixOps @RunWith(value = classOf[Parameterized]) -class TestCounter(path: jl.String) { +class Counter(path: jl.String) { val testsPrefix: String = getClass.getResource("").getFile private val runEOPath = Paths.get(".").toAbsolutePath.getParent.getParent + "/runEO" @@ -83,7 +83,7 @@ class TestCounter(path: jl.String) { } -object TestCounter { +object Counter { @Parameters def parameters: ju.Collection[Array[jl.String]] = { val testsPrefix = System.getProperty("user.dir") + "/src/test/resources/org/polystat/py2eo/transpiler" From b71e4847a39a8243dcaf70a63c9d63462775c7c7 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Wed, 27 Apr 2022 16:08:15 +0300 Subject: [PATCH 23/43] removed logging --- .github/workflows/github-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index 5ee591339..ad8f1734c 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -134,7 +134,7 @@ jobs: with: python-version: '3.8.10' - name: Build with Maven - run: mvn clean verify -B -PsingleTest -X + run: mvn clean verify -B -PsingleTest - name: archive artifacts uses: actions/upload-artifact@v2 with: From ca208cd5f25d9e8f76f35c87d7b7f7345e97b1f0 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko <69813637+AndrewG0R@users.noreply.github.com> Date: Thu, 28 Apr 2022 12:39:01 +0300 Subject: [PATCH 24/43] Update github-ci.yml --- .github/workflows/github-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index ad8f1734c..95e347761 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -109,7 +109,7 @@ jobs: name: artifacts path: ./ - name: Build with Maven - run: cd ./runEO && mvn clean test -DpathToEo="transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo" && ls -la ./target/eo-test/04-pull/org/eolang/ + run: cd ./runEO && mvn clean test -DpathToEo="transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo" - name: upload artifacts uses: actions/upload-artifact@v2 with: @@ -148,4 +148,4 @@ jobs: uses: actions/upload-artifact@v2 with: name: package - path: transpiler.jar \ No newline at end of file + path: transpiler.jar From a435944f24f416be0310908466e7d26469c1c974 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko <69813637+AndrewG0R@users.noreply.github.com> Date: Thu, 5 May 2022 14:41:03 +0300 Subject: [PATCH 25/43] Update Counter.scala --- .../test/scala/org/polystat/py2eo/transpiler/Counter.scala | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala index 2e134f202..67852f701 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala @@ -95,11 +95,7 @@ object Counter { val map = yaml.load[java.util.Map[String, String]](new FileInputStream(testHolder)) try { - if (map.containsKey("enabled") && !map.getOrDefault("enabled", "false").asInstanceOf[Boolean]){ - res.addOne(p.toString) - }else{ - println(s"The test ${testHolder.getName} is disabled") - } + res.addOne(p.toString) } catch { case e: YAMLException => fail(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") case e: ClassCastException => fail(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") From 4217cd10fa10232273198fcd47fca94b5f90f632 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Fri, 6 May 2022 17:30:07 +0300 Subject: [PATCH 26/43] get string from pb --- .../org/polystat/py2eo/transpiler/Counter.scala | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala index 67852f701..81c19da56 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala @@ -1,5 +1,10 @@ package org.polystat.py2eo.transpiler +import java.io.{File, FileInputStream} +import java.nio.file.{Files, Path, Paths, StandardCopyOption} +import java.util.concurrent.TimeUnit +import java.{lang => jl, util => ju} + import org.junit.Assert.fail import org.junit.Test import org.junit.runner.RunWith @@ -9,10 +14,6 @@ import org.polystat.py2eo.transpiler.Main.writeEOFile import org.yaml.snakeyaml.Yaml import org.yaml.snakeyaml.error.YAMLException -import java.io.{File, FileInputStream} -import java.nio.file.{Files, Path, Paths, StandardCopyOption} -import java.util.concurrent.TimeUnit -import java.{lang => jl, util => ju} import scala.language.postfixOps @@ -64,9 +65,12 @@ class Counter(path: jl.String) { var pb = new ProcessBuilder("mvn", "clean", "test", s"-DpathToEo=\"$pathResult\"") pb = pb.directory(dir) pb.inheritIO() + val process = pb.start val ret = process.waitFor(40, TimeUnit.SECONDS) + println(process.getErrorStream.toString) + println(process.getOutputStream.toString) Files.delete(pathResult) From 57e5922a0e3149d814e423d30e38eb5dc78a2ad6 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Fri, 6 May 2022 17:46:59 +0300 Subject: [PATCH 27/43] add redirect of error --- .../src/test/scala/org/polystat/py2eo/transpiler/Counter.scala | 3 +++ 1 file changed, 3 insertions(+) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala index 81c19da56..91fd228b8 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala @@ -66,12 +66,15 @@ class Counter(path: jl.String) { pb = pb.directory(dir) pb.inheritIO() + pb.redirectError(new java.io.File(s"$runEOPath/error_${file.getName}.txt")) + val process = pb.start val ret = process.waitFor(40, TimeUnit.SECONDS) println(process.getErrorStream.toString) println(process.getOutputStream.toString) + Files.delete(pathResult) if (ret) { From 8e6141a515bcdfcd6fdc8c8ecc1a476ff64d330b Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Fri, 6 May 2022 17:52:31 +0300 Subject: [PATCH 28/43] add redirect of error --- .../scala/org/polystat/py2eo/transpiler/Counter.scala | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala index 91fd228b8..2102c999b 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala @@ -66,14 +66,17 @@ class Counter(path: jl.String) { pb = pb.directory(dir) pb.inheritIO() - pb.redirectError(new java.io.File(s"$runEOPath/error_${file.getName}.txt")) + + val errorFile = new java.io.File(s"$runEOPath/error_${file.getName}.txt") + pb.redirectError(errorFile) val process = pb.start val ret = process.waitFor(40, TimeUnit.SECONDS) - println(process.getErrorStream.toString) - println(process.getOutputStream.toString) + val source = scala.io.Source.fromFile(errorFile) + val lines = try source.mkString finally source.close() + println(lines) Files.delete(pathResult) From 221f49e5e8f08110dde7790a90f31885379053ec Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Wed, 11 May 2022 14:50:19 +0300 Subject: [PATCH 29/43] added output --- .../test/scala/org/polystat/py2eo/transpiler/Counter.scala | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala index 2102c999b..8a1b7cce5 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala @@ -70,9 +70,15 @@ class Counter(path: jl.String) { val errorFile = new java.io.File(s"$runEOPath/error_${file.getName}.txt") pb.redirectError(errorFile) + val outPut = new java.io.File(s"$runEOPath/output_${file.getName}.txt") + pb.redirectOutput(outPut) + val process = pb.start val ret = process.waitFor(40, TimeUnit.SECONDS) + val sourceOutput = scala.io.Source.fromFile(outPut) + val linesOutput = try sourceOutput.mkString finally sourceOutput.close() + println(linesOutput) val source = scala.io.Source.fromFile(errorFile) val lines = try source.mkString finally source.close() From 4f3b7b85aef5e7e8f679186604aaaf8d2406d263 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Wed, 11 May 2022 17:31:54 +0300 Subject: [PATCH 30/43] fixed CI --- runEO/pom.xml | 49 +++------- .../polystat/py2eo/transpiler/Counter.scala | 96 ++++++++++--------- 2 files changed, 63 insertions(+), 82 deletions(-) diff --git a/runEO/pom.xml b/runEO/pom.xml index 708cbe279..ec9b29c9f 100644 --- a/runEO/pom.xml +++ b/runEO/pom.xml @@ -7,58 +7,31 @@ 0.0.1 UTF-8 - 0.22.2 + 0.21.7 11 11 - ${eo_path} - - maven-resources-plugin - 3.2.0 - - - copy-resources - - validate - - copy-resources - - - ${basedir}/target/eo-test/04-pull/org/eolang/ - - - ${basedir}/../transpiler/src/main/eo - **.eo - - - - - - org.eolang eo-maven-plugin ${eolang.version} - - compile + + compile register assemble transpile - - ${project.baseDir}/../../ - - ${eo_path} - - ${project.basedir}/target/eo-test - false - true - ${project.basedir}/target/generated-test-sources - + + ${project.basedir} + ${project.basedir}/target/eo-test + false + true + ${project.basedir}/target/generated-test-sources + @@ -77,4 +50,4 @@ 5.8.1 - + \ No newline at end of file diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala index 8a1b7cce5..f5f415adb 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala @@ -1,10 +1,5 @@ package org.polystat.py2eo.transpiler -import java.io.{File, FileInputStream} -import java.nio.file.{Files, Path, Paths, StandardCopyOption} -import java.util.concurrent.TimeUnit -import java.{lang => jl, util => ju} - import org.junit.Assert.fail import org.junit.Test import org.junit.runner.RunWith @@ -14,7 +9,12 @@ import org.polystat.py2eo.transpiler.Main.writeEOFile import org.yaml.snakeyaml.Yaml import org.yaml.snakeyaml.error.YAMLException +import java.io.{File, FileInputStream} +import java.nio.file.StandardCopyOption.REPLACE_EXISTING +import java.nio.file.{Files, Path, Paths} +import java.{lang => jl, util => ju} import scala.language.postfixOps +import scala.sys.process.Process @RunWith(value = classOf[Parameterized]) @@ -49,48 +49,56 @@ class Counter(path: jl.String) { private def run(file: File):Boolean = { - //val result = new File(runEOPath + s"/${file.getName}") + val test = new File(runEOPath + s"/${file.getName}") //val path = Path.of(runEOPath + s"/${file.getName}") val path = Path.of(s"$runEOPath/${file.getName}") - val pathResult = Files.move( - Paths.get(file.getPath), - path, - StandardCopyOption.REPLACE_EXISTING - ) -// val test = Files.copy(file.toPath, path, REPLACE_EXISTING).toAbsolutePath -// println(test) - val dir = new java.io.File(runEOPath) - //var pb = new ProcessBuilder("mvn", "clean", "test", s"-DpathToEo=\"$test\"") - var pb = new ProcessBuilder("mvn", "clean", "test", s"-DpathToEo=\"$pathResult\"") - pb = pb.directory(dir) - pb.inheritIO() - - - val errorFile = new java.io.File(s"$runEOPath/error_${file.getName}.txt") - pb.redirectError(errorFile) - - val outPut = new java.io.File(s"$runEOPath/output_${file.getName}.txt") - pb.redirectOutput(outPut) - - val process = pb.start - val ret = process.waitFor(40, TimeUnit.SECONDS) - - val sourceOutput = scala.io.Source.fromFile(outPut) - val linesOutput = try sourceOutput.mkString finally sourceOutput.close() - println(linesOutput) - - val source = scala.io.Source.fromFile(errorFile) - val lines = try source.mkString finally source.close() - println(lines) - - Files.delete(pathResult) - - if (ret) { - process.exitValue == 0 - } else { - false - } + val result = Files.copy(file.toPath, Path.of(s"$runEOPath/test.eo"), REPLACE_EXISTING) + val ret = Process("mvn clean test", new File(runEOPath)).! == 0 + + Files delete result + + ret + +// val pathResult = Files.move( +// Paths.get(file.getPath), +// path, +// StandardCopyOption.REPLACE_EXISTING +// ) +//// val test = Files.copy(file.toPath, path, REPLACE_EXISTING).toAbsolutePath +//// println(test) +// val dir = new java.io.File(runEOPath) +// //var pb = new ProcessBuilder("mvn", "clean", "test", s"-DpathToEo=\"$test\"") +// +// var pb = new ProcessBuilder("C:\\apache\\bin\\mvn.cmd", "clean", "test", s"-DpathToEo=\"${pathResult.getParent}\"", "-X") +// pb = pb.directory(dir) +// pb.inheritIO() +// +// +// val errorFile = new java.io.File(s"$runEOPath/error_${file.getName}.txt") +// pb.redirectError(errorFile) +// +// val outPut = new java.io.File(s"$runEOPath/output_${file.getName}.txt") +// pb.redirectOutput(outPut) +// +// val process = pb.start +// val ret = process.waitFor(40, TimeUnit.SECONDS) +// +// val sourceOutput = scala.io.Source.fromFile(outPut) +// val linesOutput = try sourceOutput.mkString finally sourceOutput.close() +// println(linesOutput) +// +// val source = scala.io.Source.fromFile(errorFile) +// val lines = try source.mkString finally source.close() +// println(lines) +// +// //Files.delete(pathResult) +// +// if (ret) { +// process.exitValue == 0 +// } else { +// false +// } } @Test def testDef(): Unit = { From 53bd127e32b05a0cb18099a8061bfed9b9bc69cc Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Wed, 11 May 2022 19:17:39 +0300 Subject: [PATCH 31/43] fixed CI stages --- .github/workflows/counter.yaml | 38 ++++++++++++++++++++ .github/workflows/github-ci.yml | 64 ++++++++++++++++----------------- 2 files changed, 70 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/counter.yaml diff --git a/.github/workflows/counter.yaml b/.github/workflows/counter.yaml new file mode 100644 index 000000000..9a6c9769c --- /dev/null +++ b/.github/workflows/counter.yaml @@ -0,0 +1,38 @@ +name: Count tests failures + +on: + release: + types: [ published ] + +jobs: + build: + strategy: + matrix: + os: [ ubuntu-latest ] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 14 + uses: actions/setup-java@v2 + with: + java-version: '14' + distribution: 'adopt' + - uses: actions/setup-python@v2 + with: + python-version: '3.8.10' + - name: Build with Maven + run: mvn clean verify -B -PsingleTest + - name: archive artifacts + uses: actions/upload-artifact@v2 + with: + name: artifacts + path: | + transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo + scalastyle-output.xml + - name: Rename jar + run: cp transpiler/target/transpiler-*-jar-with-dependencies.jar transpiler.jar + - name: archive jar + uses: actions/upload-artifact@v2 + with: + name: package + path: transpiler.jar \ No newline at end of file diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index 95e347761..756c0eb7b 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -117,35 +117,35 @@ jobs: path: /Users/runner/work/py2eo/py2eo/python/python3/test/target/generated-sources/ - counter: - strategy: - matrix: - os: [ ubuntu-latest ] - runs-on: ${{ matrix.os }} - needs: build - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 14 - uses: actions/setup-java@v2 - with: - java-version: '14' - distribution: 'adopt' - - uses: actions/setup-python@v2 - with: - python-version: '3.8.10' - - name: Build with Maven - run: mvn clean verify -B -PsingleTest - - name: archive artifacts - uses: actions/upload-artifact@v2 - with: - name: artifacts - path: | - transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo - scalastyle-output.xml - - name: Rename jar - run: cp transpiler/target/transpiler-*-jar-with-dependencies.jar transpiler.jar - - name: archive jar - uses: actions/upload-artifact@v2 - with: - name: package - path: transpiler.jar +# counter: +# strategy: +# matrix: +# os: [ ubuntu-latest ] +# runs-on: ${{ matrix.os }} +# needs: build +# steps: +# - uses: actions/checkout@v2 +# - name: Set up JDK 14 +# uses: actions/setup-java@v2 +# with: +# java-version: '14' +# distribution: 'adopt' +# - uses: actions/setup-python@v2 +# with: +# python-version: '3.8.10' +# - name: Build with Maven +# run: mvn clean verify -B -PsingleTest +# - name: archive artifacts +# uses: actions/upload-artifact@v2 +# with: +# name: artifacts +# path: | +# transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo +# scalastyle-output.xml +# - name: Rename jar +# run: cp transpiler/target/transpiler-*-jar-with-dependencies.jar transpiler.jar +# - name: archive jar +# uses: actions/upload-artifact@v2 +# with: +# name: package +# path: transpiler.jar From 49724eb3b2cf00f6d1297711e3cecb3e5203ab20 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Wed, 11 May 2022 19:26:08 +0300 Subject: [PATCH 32/43] fixed CI stages --- .github/workflows/counter.yaml | 38 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/counter.yaml b/.github/workflows/counter.yaml index 9a6c9769c..258d9e769 100644 --- a/.github/workflows/counter.yaml +++ b/.github/workflows/counter.yaml @@ -17,22 +17,22 @@ jobs: with: java-version: '14' distribution: 'adopt' - - uses: actions/setup-python@v2 - with: - python-version: '3.8.10' - - name: Build with Maven - run: mvn clean verify -B -PsingleTest - - name: archive artifacts - uses: actions/upload-artifact@v2 - with: - name: artifacts - path: | - transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo - scalastyle-output.xml - - name: Rename jar - run: cp transpiler/target/transpiler-*-jar-with-dependencies.jar transpiler.jar - - name: archive jar - uses: actions/upload-artifact@v2 - with: - name: package - path: transpiler.jar \ No newline at end of file + - uses: actions/setup-python@v2 + with: + python-version: '3.8.10' + - name: Build with Maven + run: mvn clean verify -B -PsingleTest + - name: archive artifacts + uses: actions/upload-artifact@v2 + with: + name: artifacts + path: | + transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo + scalastyle-output.xml + - name: Rename jar + run: cp transpiler/target/transpiler-*-jar-with-dependencies.jar transpiler.jar + - name: archive jar + uses: actions/upload-artifact@v2 + with: + name: package + path: transpiler.jar \ No newline at end of file From 83efa77fde2930ae3cf4b6d3b617fb6e66f8f8f4 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Wed, 11 May 2022 19:33:06 +0300 Subject: [PATCH 33/43] fixed CI stages --- .github/workflows/counter.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/counter.yaml b/.github/workflows/counter.yaml index 258d9e769..e9a2a46d8 100644 --- a/.github/workflows/counter.yaml +++ b/.github/workflows/counter.yaml @@ -1,8 +1,9 @@ name: Count tests failures -on: - release: - types: [ published ] +#on: +# release: +# types: [ published ] +on: [push] jobs: build: From 243386c13a6b13aea6aea20a571d0b69db43aafd Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Wed, 11 May 2022 19:34:08 +0300 Subject: [PATCH 34/43] fixed CI stages --- .github/workflows/counter.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/counter.yaml b/.github/workflows/counter.yaml index e9a2a46d8..258d9e769 100644 --- a/.github/workflows/counter.yaml +++ b/.github/workflows/counter.yaml @@ -1,9 +1,8 @@ name: Count tests failures -#on: -# release: -# types: [ published ] -on: [push] +on: + release: + types: [ published ] jobs: build: From 28d4187bf77de132e4d8e12a0ee05c441213cad2 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Wed, 11 May 2022 19:38:56 +0300 Subject: [PATCH 35/43] fixed CI stages --- .../polystat/py2eo/transpiler/Counter.scala | 54 ++----------------- 1 file changed, 4 insertions(+), 50 deletions(-) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala index f5f415adb..6add428cd 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala @@ -30,9 +30,9 @@ class Counter(path: jl.String) { } def useCageHolder(test: File): Unit = { - val z = yaml2python(test) + val yamlData = yaml2python(test) - val res = Transpile(test.getName.replace(".yaml", ""), z) + val res = Transpile(test.getName.replace(".yaml", ""), yamlData) res match { case None => fail(s"could not transpile ${test.getName}"); @@ -41,64 +41,20 @@ class Counter(path: jl.String) { test, "genCageEO", ".eo", transpiled ) - if(!run(path)){ + if (!run(path)) { fail(s"could not run EO ${test.getName}") } } } - private def run(file: File):Boolean = { - val test = new File(runEOPath + s"/${file.getName}") - //val path = Path.of(runEOPath + s"/${file.getName}") - val path = Path.of(s"$runEOPath/${file.getName}") - + private def run(file: File): Boolean = { val result = Files.copy(file.toPath, Path.of(s"$runEOPath/test.eo"), REPLACE_EXISTING) val ret = Process("mvn clean test", new File(runEOPath)).! == 0 Files delete result ret - -// val pathResult = Files.move( -// Paths.get(file.getPath), -// path, -// StandardCopyOption.REPLACE_EXISTING -// ) -//// val test = Files.copy(file.toPath, path, REPLACE_EXISTING).toAbsolutePath -//// println(test) -// val dir = new java.io.File(runEOPath) -// //var pb = new ProcessBuilder("mvn", "clean", "test", s"-DpathToEo=\"$test\"") -// -// var pb = new ProcessBuilder("C:\\apache\\bin\\mvn.cmd", "clean", "test", s"-DpathToEo=\"${pathResult.getParent}\"", "-X") -// pb = pb.directory(dir) -// pb.inheritIO() -// -// -// val errorFile = new java.io.File(s"$runEOPath/error_${file.getName}.txt") -// pb.redirectError(errorFile) -// -// val outPut = new java.io.File(s"$runEOPath/output_${file.getName}.txt") -// pb.redirectOutput(outPut) -// -// val process = pb.start -// val ret = process.waitFor(40, TimeUnit.SECONDS) -// -// val sourceOutput = scala.io.Source.fromFile(outPut) -// val linesOutput = try sourceOutput.mkString finally sourceOutput.close() -// println(linesOutput) -// -// val source = scala.io.Source.fromFile(errorFile) -// val lines = try source.mkString finally source.close() -// println(lines) -// -// //Files.delete(pathResult) -// -// if (ret) { -// process.exitValue == 0 -// } else { -// false -// } } @Test def testDef(): Unit = { @@ -115,8 +71,6 @@ object Counter { val simpleTestsFolder = new File(testsPrefix + File.separator + "simple-tests" + File.separator) Files.walk(simpleTestsFolder.toPath).filter((p: Path) => p.toString.endsWith(".yaml")).forEach((p: Path) => { val testHolder = new File(p.toString) - val yaml = new Yaml() - val map = yaml.load[java.util.Map[String, String]](new FileInputStream(testHolder)) try { res.addOne(p.toString) From 2d094c975434546fd65636511e182d7d6a166395 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Wed, 11 May 2022 22:37:42 +0300 Subject: [PATCH 36/43] fixed CI stages --- .github/workflows/github-ci.yml | 36 +-------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index 756c0eb7b..9b7cb6298 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -114,38 +114,4 @@ jobs: uses: actions/upload-artifact@v2 with: name: generatedJava - path: /Users/runner/work/py2eo/py2eo/python/python3/test/target/generated-sources/ - - -# counter: -# strategy: -# matrix: -# os: [ ubuntu-latest ] -# runs-on: ${{ matrix.os }} -# needs: build -# steps: -# - uses: actions/checkout@v2 -# - name: Set up JDK 14 -# uses: actions/setup-java@v2 -# with: -# java-version: '14' -# distribution: 'adopt' -# - uses: actions/setup-python@v2 -# with: -# python-version: '3.8.10' -# - name: Build with Maven -# run: mvn clean verify -B -PsingleTest -# - name: archive artifacts -# uses: actions/upload-artifact@v2 -# with: -# name: artifacts -# path: | -# transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo -# scalastyle-output.xml -# - name: Rename jar -# run: cp transpiler/target/transpiler-*-jar-with-dependencies.jar transpiler.jar -# - name: archive jar -# uses: actions/upload-artifact@v2 -# with: -# name: package -# path: transpiler.jar + path: /Users/runner/work/py2eo/py2eo/python/python3/test/target/generated-sources/ \ No newline at end of file From 77d0a84f2e9cd95e5b7d6794765750a7e4f7ff35 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Thu, 12 May 2022 11:15:14 +0300 Subject: [PATCH 37/43] fixed EO version in runEO --- runEO/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runEO/pom.xml b/runEO/pom.xml index ec9b29c9f..2ca8b5246 100644 --- a/runEO/pom.xml +++ b/runEO/pom.xml @@ -7,7 +7,7 @@ 0.0.1 UTF-8 - 0.21.7 + 0.22.2 11 11 From 4a94c1d6807f964fe6d8fccfc8439e18ea683cb3 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Thu, 12 May 2022 11:30:37 +0300 Subject: [PATCH 38/43] removed junk code --- .../org/polystat/py2eo/transpiler/Main.scala | 15 +-------------- .../org/polystat/py2eo/transpiler/Counter.scala | 6 +++--- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/transpiler/src/main/scala/org/polystat/py2eo/transpiler/Main.scala b/transpiler/src/main/scala/org/polystat/py2eo/transpiler/Main.scala index 709d8bdb2..bc0b90e6e 100644 --- a/transpiler/src/main/scala/org/polystat/py2eo/transpiler/Main.scala +++ b/transpiler/src/main/scala/org/polystat/py2eo/transpiler/Main.scala @@ -66,20 +66,7 @@ object Main { s.mkString } - def writeFile(test: File, dirSuffix: String, fileSuffix: String, what: String, otherLocation: Boolean = false): String = { - val moduleName = test.getName.substring(0, test.getName.lastIndexOf(".")) - val outPath = if (!otherLocation) test.getAbsoluteFile.getParentFile.getPath + "/" + dirSuffix else dirSuffix - val d = new File(outPath) - if (!d.exists()) d.mkdir() - val outName = outPath + "/" + moduleName + fileSuffix - val output = new FileWriter(outName) - output.write(what) - output.close() - outName - } - - - def writeEOFile(test: File, dirSuffix: String, fileSuffix: String, what: String, otherLocation: Boolean = false): File = { + def writeFile(test: File, dirSuffix: String, fileSuffix: String, what: String, otherLocation: Boolean = false): File = { val moduleName = test.getName.substring(0, test.getName.lastIndexOf(".")) val outPath = if (!otherLocation) test.getAbsoluteFile.getParentFile.getPath + "/" + dirSuffix else dirSuffix val d = new File(outPath) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala index 6add428cd..ae987641b 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala @@ -5,11 +5,11 @@ import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized import org.junit.runners.Parameterized.Parameters -import org.polystat.py2eo.transpiler.Main.writeEOFile +import org.polystat.py2eo.transpiler.Main.writeFile import org.yaml.snakeyaml.Yaml import org.yaml.snakeyaml.error.YAMLException -import java.io.{File, FileInputStream} +import java.io.{File, FileInputStream, FileWriter} import java.nio.file.StandardCopyOption.REPLACE_EXISTING import java.nio.file.{Files, Path, Paths} import java.{lang => jl, util => ju} @@ -37,7 +37,7 @@ class Counter(path: jl.String) { res match { case None => fail(s"could not transpile ${test.getName}"); case Some(transpiled) => - val path = writeEOFile( + val path = writeFile( test, "genCageEO", ".eo", transpiled ) From 470d7558816d46313d4775725ac72056746590c1 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Thu, 12 May 2022 12:47:27 +0300 Subject: [PATCH 39/43] removed junk code --- .../polystat/py2eo/transpiler/Commons.scala | 61 ++++++++++++------- .../polystat/py2eo/transpiler/Counter.scala | 61 +++---------------- .../py2eo/transpiler/DummyTests.scala | 39 ++---------- .../polystat/py2eo/transpiler/RunSingle.scala | 2 +- .../py2eo/transpiler/TestsSimple.scala | 46 +++----------- 5 files changed, 64 insertions(+), 145 deletions(-) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Commons.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Commons.scala index 559561172..7c9380bb3 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Commons.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Commons.scala @@ -3,36 +3,55 @@ package org.polystat.py2eo.transpiler import org.junit.Assert.fail import org.polystat.py2eo.transpiler.Main.writeFile import org.yaml.snakeyaml.Yaml +import org.yaml.snakeyaml.error.YAMLException import java.io.{File, FileInputStream} +import java.nio.file.{Files, Path} +import java.{lang => jl, util => ju} trait Commons { val testsPrefix: String = System.getProperty("user.dir") + "/src/test/resources/org/polystat/py2eo/transpiler" - case class YamlTest(python: String, enabled: Boolean) - def yaml2python(f: File): YamlTest = { - val yaml = new Yaml() - val map = yaml.load[java.util.Map[String, String]](new FileInputStream(f)) - - YamlTest(map.get("python"), map.containsKey("enabled") && map.getOrDefault("enabled", "false").asInstanceOf[Boolean]) + def yaml2python(f: File): String = { + val map = new Yaml().load[java.util.Map[String, String]](new FileInputStream(f)) + map.get("python") } def useCageHolder(test: File): Unit = { - val yamlObj = yaml2python(test) - - if (yamlObj.enabled) { - val res = Transpile.transpileOption(Main.debugPrinter(test))( - test.getName.replace(".yaml", ""), - yamlObj.python - ) - - res match { - case None => fail(s"could not transpile ${test.getName}"); - case Some(transpiled) => - writeFile( - test, "genCageEO", ".eo", transpiled - ) - } + Transpile(test.getName.replace(".yaml", ""), yaml2python(test)) match { + case None => fail(s"could not transpile ${test.getName}"); + case Some(transpiled) => writeFile(test, "genCageEO", ".eo", transpiled) } } + + def collect(dir: String, needsFiltering: Boolean = false): ju.Collection[Array[jl.String]] = { + val testsPrefix = System.getProperty("user.dir") + "/src/test/resources/org/polystat/py2eo/transpiler" + + val res = collection.mutable.ArrayBuffer[String]() + val simpleTestsFolder = new File(testsPrefix + File.separator + dir + File.separator) + Files.walk(simpleTestsFolder.toPath).filter((p: Path) => p.toString.endsWith(".yaml")).forEach((p: Path) => { + val testHolder = new File(p.toString) + + try { + val map = new Yaml().load[java.util.Map[String, String]](new FileInputStream(testHolder)) + if (needsFiltering) { + if (map.containsKey("enabled") && map.getOrDefault("enabled", "false").asInstanceOf[Boolean]) { + res.addOne(p.toString) + } else { + println(s"The test ${testHolder.getName} is disabled") + } + } else { + res.addOne(p.toString) + } + } catch { + case e: YAMLException => fail(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") + case e: ClassCastException => fail(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") + } + }) + + + val list = new ju.ArrayList[Array[jl.String]]() + res.foreach(n => list.add(Array(n))) + list + } } diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala index ae987641b..175dfad8d 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala @@ -6,40 +6,30 @@ import org.junit.runner.RunWith import org.junit.runners.Parameterized import org.junit.runners.Parameterized.Parameters import org.polystat.py2eo.transpiler.Main.writeFile -import org.yaml.snakeyaml.Yaml -import org.yaml.snakeyaml.error.YAMLException -import java.io.{File, FileInputStream, FileWriter} +import java.io.File import java.nio.file.StandardCopyOption.REPLACE_EXISTING import java.nio.file.{Files, Path, Paths} import java.{lang => jl, util => ju} import scala.language.postfixOps import scala.sys.process.Process +object Counter extends Commons { + @Parameters def parameters: ju.Collection[Array[jl.String]] = collect("simple-tests") +} @RunWith(value = classOf[Parameterized]) -class Counter(path: jl.String) { - val testsPrefix: String = getClass.getResource("").getFile +class Counter(path: jl.String) extends Commons { private val runEOPath = Paths.get(".").toAbsolutePath.getParent.getParent + "/runEO" - def yaml2python(f: File): String = { - val yaml = new Yaml() - val map = yaml.load[java.util.Map[String, String]](new FileInputStream(f)) - - map.get("python") - } - - def useCageHolder(test: File): Unit = { + @Test def testDef(): Unit = { + val test = new File(path) val yamlData = yaml2python(test) - val res = Transpile(test.getName.replace(".yaml", ""), yamlData) - - res match { + Transpile(test.getName.replace(".yaml", ""), yamlData) match { case None => fail(s"could not transpile ${test.getName}"); case Some(transpiled) => - val path = writeFile( - test, "genCageEO", ".eo", transpiled - ) + val path = writeFile(test, "genCageEO", ".eo", transpiled) if (!run(path)) { fail(s"could not run EO ${test.getName}") @@ -47,7 +37,6 @@ class Counter(path: jl.String) { } } - private def run(file: File): Boolean = { val result = Files.copy(file.toPath, Path.of(s"$runEOPath/test.eo"), REPLACE_EXISTING) val ret = Process("mvn clean test", new File(runEOPath)).! == 0 @@ -56,34 +45,4 @@ class Counter(path: jl.String) { ret } - - @Test def testDef(): Unit = { - useCageHolder(new File(path)) - } -} - - -object Counter { - @Parameters def parameters: ju.Collection[Array[jl.String]] = { - val testsPrefix = System.getProperty("user.dir") + "/src/test/resources/org/polystat/py2eo/transpiler" - - val res = collection.mutable.ArrayBuffer[String]() - val simpleTestsFolder = new File(testsPrefix + File.separator + "simple-tests" + File.separator) - Files.walk(simpleTestsFolder.toPath).filter((p: Path) => p.toString.endsWith(".yaml")).forEach((p: Path) => { - val testHolder = new File(p.toString) - - try { - res.addOne(p.toString) - } catch { - case e: YAMLException => fail(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") - case e: ClassCastException => fail(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") - } - }) - - - val list = new ju.ArrayList[Array[jl.String]]() - res.foreach(n => list.add(Array(n))) - list - } -} - +} \ No newline at end of file diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/DummyTests.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/DummyTests.scala index ee478d6ca..6f505be45 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/DummyTests.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/DummyTests.scala @@ -1,45 +1,18 @@ package org.polystat.py2eo.transpiler -import org.junit.Assert.fail import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized import org.junit.runners.Parameterized.Parameters -import org.yaml.snakeyaml.error.YAMLException import java.io.File -import java.nio.file.{Files, Path} import java.{lang => jl, util => ju} -@RunWith(value = classOf[Parameterized]) -class DummyTests(path: jl.String) extends Commons { - @Test def testDef(): Unit = { - useCageHolder(new File(path)) - } +object DummyTests extends Commons { + @Parameters def parameters: ju.Collection[Array[jl.String]] = collect("dummy_tests") } -object DummyTests { - @Parameters def parameters: ju.Collection[Array[jl.String]] = { - val testsPrefix = System.getProperty("user.dir") + "/src/test/resources/org/polystat/py2eo/transpiler" - - val res = collection.mutable.ArrayBuffer[String]() - val simpleTestsFolder = new File(testsPrefix + File.separator + "dummy_tests" + File.separator) - Files.walk(simpleTestsFolder.toPath).filter((p: Path) => p.toString.endsWith(".yaml")).forEach((p: Path) => { - val testHolder = new File(p.toString) - try { - res.addOne(p.toString) - } catch { - case e: YAMLException => fail(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") - case e: ClassCastException => fail(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") - } - }) - - - val list = new ju.ArrayList[Array[jl.String]]() - res.foreach(n => list.add(Array(n))) - list - } -} - - - +@RunWith(value = classOf[Parameterized]) +class DummyTests(path: jl.String) extends Commons { + @Test def testDef(): Unit = useCageHolder(new File(path)) +} \ No newline at end of file diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/RunSingle.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/RunSingle.scala index b2715593a..49be2bc42 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/RunSingle.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/RunSingle.scala @@ -11,4 +11,4 @@ class RunSingle extends Commons { val testPath = simpleTestsFolder + File.separator + "assign" + File.separator + "assign-1.yaml" useCageHolder(new File(testPath)) } -} +} \ No newline at end of file diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsSimple.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsSimple.scala index 32dbc8776..9080be14b 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsSimple.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsSimple.scala @@ -1,50 +1,18 @@ package org.polystat.py2eo.transpiler -import org.junit.Assert.fail import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized import org.junit.runners.Parameterized.Parameters -import org.yaml.snakeyaml.Yaml -import org.yaml.snakeyaml.error.YAMLException -import java.io.{File, FileInputStream} -import java.nio.file.{Files, Path} +import java.io.File import java.{lang => jl, util => ju} -@RunWith(value = classOf[Parameterized]) -class TestsSimple(path: jl.String) extends Commons { - @Test def testDef(): Unit = { - useCageHolder(new File(path)) - } +object TestsSimple extends Commons { + @Parameters def parameters: ju.Collection[Array[jl.String]] = collect("simple-tests", needsFiltering = true) } -object TestsSimple { - @Parameters def parameters: ju.Collection[Array[jl.String]] = { - val testsPrefix = System.getProperty("user.dir") + "/src/test/resources/org/polystat/py2eo/transpiler" - - val res = collection.mutable.ArrayBuffer[String]() - val simpleTestsFolder = new File(testsPrefix + File.separator + "simple-tests" + File.separator) - Files.walk(simpleTestsFolder.toPath).filter((p: Path) => p.toString.endsWith(".yaml")).forEach((p: Path) => { - val testHolder = new File(p.toString) - val yaml = new Yaml() - val map = yaml.load[java.util.Map[String, String]](new FileInputStream(testHolder)) - - try { - if (map.containsKey("enabled") && map.getOrDefault("enabled", "false").asInstanceOf[Boolean]){ - res.addOne(p.toString) - }else{ - println(s"The test ${testHolder.getName} is disabled") - } - } catch { - case e: YAMLException => fail(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") - case e: ClassCastException => fail(s"Couldn't parse ${testHolder.getName} file with error ${e.getMessage}") - } - }) - - - val list = new ju.ArrayList[Array[jl.String]]() - res.foreach(n => list.add(Array(n))) - list - } -} +@RunWith(value = classOf[Parameterized]) +class TestsSimple(path: jl.String) extends Commons { + @Test def testDef(): Unit = useCageHolder(new File(path)) +} \ No newline at end of file From cd4bb0cee2d1b129b0414f57b61cb74e78141b99 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Thu, 12 May 2022 13:07:16 +0300 Subject: [PATCH 40/43] fixed arguments naming --- .../test/scala/org/polystat/py2eo/transpiler/Commons.scala | 4 ++-- .../scala/org/polystat/py2eo/transpiler/TestsSimple.scala | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Commons.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Commons.scala index 7c9380bb3..6e2d0319f 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Commons.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Commons.scala @@ -24,7 +24,7 @@ trait Commons { } } - def collect(dir: String, needsFiltering: Boolean = false): ju.Collection[Array[jl.String]] = { + def collect(dir: String, filterEnabled: Boolean = false): ju.Collection[Array[jl.String]] = { val testsPrefix = System.getProperty("user.dir") + "/src/test/resources/org/polystat/py2eo/transpiler" val res = collection.mutable.ArrayBuffer[String]() @@ -34,7 +34,7 @@ trait Commons { try { val map = new Yaml().load[java.util.Map[String, String]](new FileInputStream(testHolder)) - if (needsFiltering) { + if (filterEnabled) { if (map.containsKey("enabled") && map.getOrDefault("enabled", "false").asInstanceOf[Boolean]) { res.addOne(p.toString) } else { diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsSimple.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsSimple.scala index 9080be14b..11150a701 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsSimple.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsSimple.scala @@ -9,7 +9,7 @@ import java.io.File import java.{lang => jl, util => ju} object TestsSimple extends Commons { - @Parameters def parameters: ju.Collection[Array[jl.String]] = collect("simple-tests", needsFiltering = true) + @Parameters def parameters: ju.Collection[Array[jl.String]] = collect("simple-tests", filterEnabled = true) } @RunWith(value = classOf[Parameterized]) From 7988ec31cf5bc80225daa9ebd438a89095df8bd1 Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Thu, 12 May 2022 14:12:09 +0300 Subject: [PATCH 41/43] fix CI --- .github/workflows/github-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index 9b7cb6298..5e839f0ac 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -109,7 +109,7 @@ jobs: name: artifacts path: ./ - name: Build with Maven - run: cd ./runEO && mvn clean test -DpathToEo="transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo" + run: cp transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo ./runEO && cd ./runEO && mvn clean test - name: upload artifacts uses: actions/upload-artifact@v2 with: From 0c7b8d2072fe5e02e25c487bc060554cb532fafb Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Thu, 12 May 2022 14:17:54 +0300 Subject: [PATCH 42/43] fix CI --- .../src/test/scala/org/polystat/py2eo/transpiler/Tests.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Tests.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Tests.scala index d5538d3b9..4d0b20a10 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Tests.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Tests.scala @@ -2,7 +2,7 @@ package org.polystat.py2eo.transpiler import org.junit.Assert.assertTrue import org.junit.{Ignore, Test} -import org.polystat.py2eo.parser.{Parse, Statement} +import org.polystat.py2eo.parser.Statement import org.polystat.py2eo.transpiler.Common.dfsFiles import org.yaml.snakeyaml.Yaml @@ -44,6 +44,7 @@ class Tests { def chopExtension(fileName : String): String = fileName.substring(0, fileName.lastIndexOf(".")) + @Ignore @Test def parserPrinterOnCPython(): Unit = { val dirName = testsPrefix + "/testParserPrinter" val dir = new File(dirName) From 933e4b77f290448496b7d26fba2f76f1cb93f54c Mon Sep 17 00:00:00 2001 From: Andrew Goroshko Date: Thu, 12 May 2022 14:27:47 +0300 Subject: [PATCH 43/43] added cpython --- .../src/test/scala/org/polystat/py2eo/transpiler/Tests.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Tests.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Tests.scala index 4d0b20a10..ee61b23ef 100644 --- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Tests.scala +++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Tests.scala @@ -44,7 +44,6 @@ class Tests { def chopExtension(fileName : String): String = fileName.substring(0, fileName.lastIndexOf(".")) - @Ignore @Test def parserPrinterOnCPython(): Unit = { val dirName = testsPrefix + "/testParserPrinter" val dir = new File(dirName)