Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
5784da8
added counter handling
AndrewG0R Apr 5, 2022
77505c8
added running tests via CI
AndrewG0R Apr 8, 2022
2dad159
added counting test
AndrewG0R Apr 12, 2022
d3d0771
fix CI
AndrewG0R Apr 12, 2022
2622280
fix CI
AndrewG0R Apr 12, 2022
e5ce716
fix CI
AndrewG0R Apr 12, 2022
3fe4bbf
fix CI
AndrewG0R Apr 12, 2022
684374b
fix CI
AndrewG0R Apr 12, 2022
c74e768
fix CI
AndrewG0R Apr 12, 2022
7113cb1
fix CI
AndrewG0R Apr 12, 2022
0843fc5
fix CI
AndrewG0R Apr 13, 2022
9b8acea
fix CI
AndrewG0R Apr 13, 2022
9ca447e
fix CI
AndrewG0R Apr 15, 2022
6a3e570
fix CI
AndrewG0R Apr 15, 2022
c32f5de
fix CI
AndrewG0R Apr 21, 2022
9b7e9b7
fix CI
AndrewG0R Apr 21, 2022
06d9690
Merge pull request #7 from AndrewG0R/master
AndrewG0R Apr 26, 2022
eeec5ff
added handling for yaml fields
AndrewG0R Apr 26, 2022
44a08c2
fixed gitlab_ci
AndrewG0R Apr 26, 2022
ca476b3
fix CI
AndrewG0R Apr 26, 2022
8e465ee
renamed Tests
AndrewG0R Apr 26, 2022
2aa2a7d
CI processing support
AndrewG0R Apr 27, 2022
b6f51ef
renamed files for CI
AndrewG0R Apr 27, 2022
b71e484
removed logging
AndrewG0R Apr 27, 2022
ca208cd
Update github-ci.yml
AndrewG0R Apr 28, 2022
e33c43b
Merge branch 'polystat:master' into counter
AndrewG0R May 5, 2022
a435944
Update Counter.scala
AndrewG0R May 5, 2022
4217cd1
get string from pb
AndrewG0R May 6, 2022
57e5922
add redirect of error
AndrewG0R May 6, 2022
8e6141a
add redirect of error
AndrewG0R May 6, 2022
221f49e
added output
AndrewG0R May 11, 2022
4f3b7b8
fixed CI
AndrewG0R May 11, 2022
53bd127
fixed CI stages
AndrewG0R May 11, 2022
49724eb
fixed CI stages
AndrewG0R May 11, 2022
83efa77
fixed CI stages
AndrewG0R May 11, 2022
243386c
fixed CI stages
AndrewG0R May 11, 2022
28d4187
fixed CI stages
AndrewG0R May 11, 2022
2d094c9
fixed CI stages
AndrewG0R May 11, 2022
77d0a84
fixed EO version in runEO
AndrewG0R May 12, 2022
4a94c1d
removed junk code
AndrewG0R May 12, 2022
470d755
removed junk code
AndrewG0R May 12, 2022
cd4bb0c
fixed arguments naming
AndrewG0R May 12, 2022
7988ec3
fix CI
AndrewG0R May 12, 2022
0c7b8d2
fix CI
AndrewG0R May 12, 2022
933e4b7
added cpython
AndrewG0R May 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/counter.yaml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 7 additions & 7 deletions .github/workflows/github-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ jobs:

polystatIntegration:
strategy:
matrix:
os: [ ubuntu-latest ]
matrix:
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
needs: test
steps:
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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/
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<argument>${project.build.directory}/scalastyle_2.13-1.5.1-assembly.jar</argument>
<argument>-c</argument>
<argument>${project.basedir}/scalastyle_config.xml</argument>
<argument>${project.basedir}/transpiler</argument>
<argument>${project.basedir}/transpiler/src/main</argument>
<argument>${project.basedir}/parser</argument>
</arguments>
</configuration>
Expand Down
46 changes: 10 additions & 36 deletions runEO/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,51 +13,25 @@
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/eo-test/04-pull/org/eolang/</outputDirectory>
<resources>
<resource>
<directory>${basedir}/../transpiler/src/main/eo</directory>
<include>**.eo</include>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eolang</groupId>
<artifactId>eo-maven-plugin</artifactId>
<version>${eolang.version}</version>
<executions>
<execution>
<id>compile</id>
<execution>
<id>compile</id>
<goals>
<goal>register</goal>
<goal>assemble</goal>
<goal>transpile</goal>
</goals>
<configuration>
<sourcesDir>${project.baseDir}/../../</sourcesDir>
<includeSources>
<glob>transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/*/genCageEO/*.eo</glob>
</includeSources>
<targetDir>${project.basedir}/target/eo-test</targetDir>
<addSourcesRoot>false</addSourcesRoot>
<addTestSourcesRoot>true</addTestSourcesRoot>
<generatedDir>${project.basedir}/target/generated-test-sources</generatedDir>
</configuration>
<configuration>
<sourcesDir>${project.basedir}</sourcesDir>
<targetDir>${project.basedir}/target/eo-test</targetDir>
<addSourcesRoot>false</addSourcesRoot>
<addTestSourcesRoot>true</addTestSourcesRoot>
<generatedDir>${project.basedir}/target/generated-test-sources</generatedDir>
</configuration>
</execution>
</executions>
</plugin>
Expand All @@ -76,4 +50,4 @@
<version>5.8.1</version>
</dependency>
</dependencies>
</project>
</project>
33 changes: 33 additions & 0 deletions transpiler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<maven.compiler.target>14</maven.compiler.target>
<encoding>UTF-8</encoding>
<scala.version>2.13.6</scala.version>
<ignoreFail>false</ignoreFail>

</properties>

<dependencies>
Expand Down Expand Up @@ -50,6 +52,37 @@
</dependency>
</dependencies>


<profiles>
<profile>
<id>singleTest</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- If you have classpath issue like NoDefClassError,... -->
<!-- useManifestOnlyJar>false</useManifestOnlyJar -->
<includes>
<include>**/Counter**</include>
</includes>
<excludes>
<exclude>**/Test*.*</exclude>
<exclude>**/*Suite.*</exclude>
</excludes>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -75,6 +75,6 @@ object Main {
val output = new FileWriter(outName)
output.write(what)
output.close()
outName
new File(outName)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
Loading