Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump some dependencies and fix CI #465

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/github-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
test:
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion parser/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ SOFTWARE.
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.1</version>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down

This file was deleted.

83 changes: 83 additions & 0 deletions parser/src/test/scala/org/polystat/py2eo/parser/PyParserIT.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package org.polystat.py2eo.parser

import org.junit.jupiter.api.{AfterAll, Assertions, Test}

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}
import scala.reflect.io.{Directory, File}
import scala.sys.process.Process
import scala.util.Properties

object PyParserIT {

/** Delete the directory by hand since Scala has some problems with it */
@AfterAll def cleanup(): Unit = this.directory.deleteRecursively

/** Temporary directory where to conduct tests */
private val directory = Directory.makeTemp(prefix = "org.polystat.py2eo.").toAbsolute

/** Repository with python tests */
private val repo = "https://github.com/python/cpython"

/** Blacklisted test names; do not update them */
private val blacklisted = Set(
// these are excluded because of some encoding problems in the lexer
"test_unicode_identifiers.py", "test_source_encoding.py",
"badsyntax_3131.py", "badsyntax_pep3120.py",
"module_koi8_r.py", "module_iso_8859_1.py",
// most of these are excluded because they do tests by comparing
// stack traces as strings but code before parser-printer has different
// line numbers than code after => traces are always different =>
// those tests cannot possibly pass
"test_traceback.py", "test_dis.py", "test_zipfile.py",
"test_multiprocessing_fork.py", "test_sys.py",
"test_import.yaml", "test_strtod.py", "test_trace.py",
"test_doctest.py", "test_concurrent_futures.py", "test_inspect.py",
"test_tracemalloc.py", "test_multiprocessing_spawn.py",
"test_sys_settrace.py", "test_multiprocessing_forkserver.py",
"test_compileall.py", "test_asyncio.py", "test_unittest.py",
"test_email.py", "test_tools.py", "test_atexit.py", "test_pdb.py",
"test_logging.py", "test_coroutines.py", "test_tasks.py",

"test_grammar.py", "test_headerregistry.py"
)
}

/** Parse and re-print tests from cpython repo and test them out */
final class PyParserIT {
@Test def apply(): Unit = {
val cpython = Directory(PyParserIT.directory / "cpython")
Process(s"git clone --depth=1 --branch v3.8.10 ${PyParserIT.repo} $cpython").!!

// Bypass some weird issue with the openssl version
File(cpython / "Lib" / "test" / "test_ssl.py").delete()

val tests = Directory(cpython / "Lib" / "test")
.deepFiles
.toList
.filter(_.extension == "py")
.filter(_.name.startsWith("test"))
.filterNot(file => PyParserIT.blacklisted(file.name))
.map(reprint)

tests.foreach { Await.result(_, Duration.Inf) }
println(s"Total of ${tests.length} files transpiled")

assume(Properties.isMac || Properties.isLinux)
Process("./configure", cpython.jfile).!!
Process(s"make -j ${sys.runtime.availableProcessors}", cpython.jfile).!!
Process("make test", cpython.jfile).!!
}

/** Parses and reprints the given test and calls [[Assertions.fail]] if failed to parse it */
private def reprint(test: File): Future[Unit] = Future {
Parse(test).map(PrintPython.print).fold(this.fail(test))(test writeAll _)
}

/** Prints the failed test name and calls [[Assertions.fail]] */
private def fail(test: File): Unit = {
println(s"failed on ${test.name}")
Assertions.fail()
}
}
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ SOFTWARE.
<maven.compiler.target>14</maven.compiler.target>
<java.version>14</java.version>
<encoding>UTF-8</encoding>
<scala.version>2.13.10</scala.version>
<scala.version>2.13.12</scala.version>
<antlr.version>4.9.2</antlr.version>
<junit.version>5.9.2</junit.version>
</properties>
<packaging>pom</packaging>
<name>py2eo</name>
Expand Down
2 changes: 1 addition & 1 deletion transpiler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ SOFTWARE.
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.1</version>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down