-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # transpiler/src/test/scala/org/polystat/py2eo/transpiler/Tests.scala
- Loading branch information
Showing
9 changed files
with
176 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
+package preface | ||
+alias pyint preface.pyint | ||
+alias return preface.return | ||
+alias cage org.eolang.cage | ||
|
||
[] > xTypeError | ||
pyint 11 > x__id__ | ||
[] > apply | ||
[stackUp] > @ | ||
cage result > pResult | ||
[] > result | ||
xTypeError > x__class__ | ||
stackUp.forward (return pResult) > @ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
+package preface | ||
|
||
[] > xiter | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
transpiler/src/test/scala/org/polystat/py2eo/transpiler/Tests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package org.polystat.py2eo.transpiler | ||
|
||
import org.junit.{Ignore, Test} | ||
import org.polystat.py2eo.parser.Statement | ||
import org.polystat.py2eo.transpiler.Common.dfsFiles | ||
|
||
import java.io.File | ||
import java.nio.file.{Files, StandardCopyOption} | ||
import java.util.stream.Collectors | ||
import scala.:: | ||
import scala.concurrent.ExecutionContext.Implicits.global | ||
import scala.concurrent.duration.Duration | ||
import scala.concurrent.{Await, Future} | ||
import scala.jdk.javaapi.CollectionConverters.asScala | ||
import scala.language.postfixOps | ||
import scala.sys.process.{Process, ProcessLogger} | ||
|
||
|
||
class Tests extends Commons { | ||
@Ignore | ||
@Test def genUnsupportedDjango() : Unit = { | ||
val root = new File("/tmp") | ||
val django = new File("/tmp/django") | ||
if (!django.exists()) { | ||
// assert(0 == Process("git clone file:///home/bogus/pythonProjects/django", root).!) | ||
assert(0 == Process("git clone -b 4.0 https://github.com/django/django", root).!) | ||
} | ||
val test = dfsFiles(django).filter(f => f.getName.endsWith(".py")) | ||
val futures = test.map(test => | ||
Future { | ||
def db(s : Statement.T, str : String) = () // debugPrinter(test)(_, _) | ||
val name = test.getName | ||
println(s"parsing $name") | ||
val eoText = try { | ||
Transpile.transpile(db)( | ||
chopExtension(name), | ||
Transpile.Parameters(wrapInAFunction = false), | ||
readFile(test) | ||
) | ||
} catch { | ||
case e : Throwable => | ||
println(s"failed to transpile $name: ${e.toString}") | ||
throw e | ||
} | ||
writeFile(test, "genUnsupportedEO", ".eo", eoText) | ||
} | ||
) | ||
for (f <- futures) Await.result(f, Duration.Inf) | ||
} | ||
|
||
@Ignore | ||
@Test def checkSyntaxForDjango() : Unit = { | ||
val django = new File("/tmp/django") | ||
val eopaths = Files.walk(django.toPath).filter(f => f.endsWith("genUnsupportedEO")) | ||
val futures = eopaths.map(path => | ||
Future { | ||
val from = new File(testsPrefix + "/django-pom.xml").toPath | ||
val to = new File(path.toString + "/pom.xml").toPath | ||
println(s"$from -> $to") | ||
Files.copy(from, to, StandardCopyOption.REPLACE_EXISTING) | ||
assert(0 == Process( | ||
s"cp -a '$testsPrefix/../../../../../../main/eo/preface/' ${path.toString}" | ||
).! | ||
) | ||
assert(0 == Process("mvn clean test", path.toFile).!) | ||
assert(0 == Process(s"rm -rf ${path.toString}").!) | ||
// val stdout = new StringBuilder | ||
// val stderr = new StringBuilder | ||
// val exitCode = Process("mvn clean test", path.toFile) ! ProcessLogger(stdout append _, stderr append _) | ||
// if (0 != exitCode) { | ||
// println(s"for path $to stdout is \n $stdout\n stderr is \n $stderr\n") | ||
// } else { | ||
// assert(0 == Process(s"rm -rf ${path.toString}").!) | ||
// } | ||
} | ||
) | ||
futures.forEach(f => Await.result(f, Duration.Inf)) | ||
} | ||
} |