diff --git a/.github/workflows/counter.yaml b/.github/workflows/counter.yaml
new file mode 100644
index 000000000..258d9e769
--- /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 c47dff292..5e839f0ac 100644
--- a/.github/workflows/github-ci.yml
+++ b/.github/workflows/github-ci.yml
@@ -53,8 +53,8 @@ jobs:
polystatIntegration:
strategy:
- matrix:
- os: [ ubuntu-latest ]
+ matrix:
+ os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
needs: test
steps:
@@ -70,7 +70,7 @@ 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.jar ./transpiler/src/test/resources/org/polystat/py2eo/transpiler/integrationTests/test.py
@@ -85,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:
@@ -109,9 +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: 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:
name: generatedJava
- path: /Users/runner/work/py2eo/py2eo/python/python3/test/target/generated-sources/
+ path: /Users/runner/work/py2eo/py2eo/python/python3/test/target/generated-sources/
\ No newline at end of file
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/runEO/pom.xml b/runEO/pom.xml
index a20e7a1b4..2ca8b5246 100644
--- a/runEO/pom.xml
+++ b/runEO/pom.xml
@@ -13,51 +13,25 @@
-
- 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}/../../
-
- transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo
-
- ${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
+
@@ -76,4 +50,4 @@
5.8.1
-
+
\ No newline at end of file
diff --git a/transpiler/pom.xml b/transpiler/pom.xml
index c38916073..ba8a59c09 100644
--- a/transpiler/pom.xml
+++ b/transpiler/pom.xml
@@ -17,6 +17,8 @@
14
UTF-8
2.13.6
+ false
+
@@ -50,6 +52,37 @@
+
+
+
+ singleTest
+
+ false
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+
+
+ **/Counter**
+
+
+ **/Test*.*
+ **/*Suite.*
+
+ true
+
+
+
+
+
+
+
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..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,7 +66,7 @@ object Main {
s.mkString
}
- def writeFile(test: File, dirSuffix: String, fileSuffix: String, what: String, otherLocation: Boolean = false): String = {
+ 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)
@@ -75,6 +75,6 @@ object Main {
val output = new FileWriter(outName)
output.write(what)
output.close()
- outName
+ new File(outName)
}
}
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..6e2d0319f 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, 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]()
+ 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 (filterEnabled) {
+ 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
new file mode 100644
index 000000000..175dfad8d
--- /dev/null
+++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Counter.scala
@@ -0,0 +1,48 @@
+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.writeFile
+
+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) extends Commons {
+ private val runEOPath = Paths.get(".").toAbsolutePath.getParent.getParent + "/runEO"
+
+ @Test def testDef(): Unit = {
+ val test = new File(path)
+ val yamlData = yaml2python(test)
+
+ 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)
+
+ if (!run(path)) {
+ fail(s"could not run EO ${test.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
+ }
+}
\ 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/Tests.scala b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/Tests.scala
index d5538d3b9..ee61b23ef 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
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..11150a701 100644
--- a/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsSimple.scala
+++ b/transpiler/src/test/scala/org/polystat/py2eo/transpiler/TestsSimple.scala
@@ -1,43 +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}
+object TestsSimple extends Commons {
+ @Parameters def parameters: ju.Collection[Array[jl.String]] = collect("simple-tests", filterEnabled = true)
+}
@RunWith(value = classOf[Parameterized])
class TestsSimple(path: jl.String) extends Commons {
- @Test def testDef(): Unit = {
- useCageHolder(new File(path))
- }
-}
-
-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)
- 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
- }
-}
+ @Test def testDef(): Unit = useCageHolder(new File(path))
+}
\ No newline at end of file