diff --git a/.appveyor/workflow.yml b/.appveyor/workflow.yml new file mode 100644 index 000000000..96ec03870 --- /dev/null +++ b/.appveyor/workflow.yml @@ -0,0 +1,124 @@ +environment: + matrix: + - job_name: java-tool-and-runtime + - job_name: csharp-runtime + job_depends_on: java-tool-and-runtime + - job_name: dart-runtime + job_depends_on: java-tool-and-runtime + - job_name: go-runtime + job_depends_on: java-tool-and-runtime + - job_name: javascript-runtime + job_depends_on: java-tool-and-runtime + - job_name: php-runtime + job_depends_on: java-tool-and-runtime + - job_name: python2-runtime + job_depends_on: java-tool-and-runtime + - job_name: python3-runtime + job_depends_on: java-tool-and-runtime + +matrix: + fast_finish: false + +version: '4.9.1-SNAPSHOT+AppVeyor.{build}' +cache: + - '%USERPROFILE%\.m2' + - '%USERPROFILE%\.nuget\packages -> **\project.json' +image: Visual Studio 2019 +# not using MSBuild +build: off + +for: + - matrix: + only: + - job_name: java-tool-and-runtime + build_script: + - mvn -q -DskipTests install --batch-mode + test_script: + - cd tool-testsuite + - mvn -q test + - cd ..\runtime-testsuite + - mvn -q -Dtest=java.* test + + - matrix: + only: + - job_name: csharp-runtime + build_script: + - mvn -q -DskipTests install --batch-mode + - dotnet build runtime/CSharp/src/Antlr4.csproj -c Release + after_build: + - dotnet pack runtime/CSharp/src/Antlr4.csproj -c Release + test_script: + - cd runtime-testsuite + - mvn -q -Dtest=csharp.* test + artifacts: + - path: 'runtime\**\*.nupkg' + name: NuGet + + - matrix: + only: + - job_name: dart-runtime + install: + - cinst -y dart-sdk --version=2.8.4 + build_script: + - mvn -q -DskipTests install --batch-mode + test_script: + - cd runtime-testsuite + - mvn -q -Dtest=dart.* test -Dantlr-dart-dart="C:\tools\dart-sdk\bin\dart.exe" -Dantlr-dart-pub="C:\tools\dart-sdk\bin\pub.bat" -Dantlr-dart-dart2native="C:\tools\dart-sdk\bin\dart2native.bat" + + - matrix: + only: + - job_name: go-runtime + build_script: + - mvn -q -DskipTests install --batch-mode + test_script: + - cd runtime-testsuite + - mvn -q -Dtest=go.* test + + - matrix: + only: + - job_name: javascript-runtime + install: + - cinst nodejs.install + - node --version + - npm --version + build_script: + - cd runtime\JavaScript\ + - npm install + - npm link + - cd ..\.. + - mvn -q -DskipTests install --batch-mode + test_script: + - cd runtime-testsuite + - mvn -q -Dtest=javascript.* test -Dantlr-javascript-npm="C:\Program Files\nodejs\npm.cmd" -Dantlr-javascript-nodejs="C:\Program Files\nodejs\node.exe" + + - matrix: + only: + - job_name: php-runtime + install: + - git clone https://github.com/antlr/antlr-php-runtime.git + - mv antlr-php-runtime runtime/PHP + - cinst -y php --params "/InstallDir:C:\tools\php" + - cinst -y composer + build_script: + - mvn -q -DskipTests install --batch-mode + test_script: + - cd runtime-testsuite + - mvn -q -Dtest=php.* test -Dantlr-php-php="C:\tools\php\php.exe" + + - matrix: + only: + - job_name: python2-runtime + build_script: + - mvn -q -DskipTests install --batch-mode + test_script: + - cd runtime-testsuite + - mvn -q -Dtest=python2.* test -Dantlr-python2-python="C:\Python27\python.exe" + + - matrix: + only: + - job_name: python3-runtime + build_script: + - mvn -q -DskipTests install --batch-mode + test_script: + - cd runtime-testsuite + - mvn -q -Dtest=python3.* test -Dantlr-python3-python="C:\Python35\python.exe" diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 8bcec2bd9..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,22 +0,0 @@ -version: '4.9.1-SNAPSHOT+AppVeyor.{build}' -cache: - - '%USERPROFILE%\.m2' - - '%USERPROFILE%\.nuget\packages -> **\project.json' -image: Visual Studio 2019 -build: off -install: - - git clone https://github.com/antlr/antlr-php-runtime.git - - mv antlr-php-runtime runtime/PHP - - cinst -y php --params "/InstallDir:C:\tools\php" - - cinst -y composer - - cinst -y dart-sdk --version=2.8.4 -build_script: - - mvn -DskipTests install --batch-mode - - dotnet build runtime/CSharp/src/Antlr4.csproj -c Release -after_build: - - dotnet pack runtime/CSharp/src/Antlr4.csproj -c Release -test_script: - - mvn install -Dantlr-php-php="C:\tools\php\php.exe" -Dantlr-dart-dart="C:\tools\dart-sdk\bin\dart.exe" -Dantlr-dart-pub="C:\tools\dart-sdk\bin\pub.bat" -Dantlr-dart-dart2native="C:\tools\dart-sdk\bin\dart2native.bat" -Dantlr-python2-python="C:\Python27\python.exe" -Dantlr-python3-python="C:\Python35\python.exe" --batch-mode -artifacts: -- path: 'runtime\**\*.nupkg' - name: NuGet diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseRuntimeTest.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseRuntimeTest.java index 1604c6987..13634e203 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseRuntimeTest.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseRuntimeTest.java @@ -87,13 +87,13 @@ public abstract class BaseRuntimeTest { public void run() { heartbeat = true; while (heartbeat) { - System.out.print('.'); try { //noinspection BusyWait - Thread.sleep(5000); + Thread.sleep(10000); } catch (Exception e) { e.printStackTrace(); } + System.out.print('.'); } } }; diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseRuntimeTestSupport.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseRuntimeTestSupport.java index 49233e263..8942ede34 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseRuntimeTestSupport.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseRuntimeTestSupport.java @@ -16,6 +16,8 @@ import org.junit.runner.Description; import java.io.File; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.LinkOption; +import java.nio.file.Path; import java.util.Locale; import java.util.logging.Logger; @@ -161,14 +163,19 @@ public abstract class BaseRuntimeTestSupport implements RuntimeTestSupport { private static void eraseFile(File dir, String name) throws IOException { File file = new File(dir,name); - if(Files.isSymbolicLink(file.toPath())) + if(Files.isSymbolicLink((file.toPath()))) Files.delete(file.toPath()); - else if(file.isDirectory()) - eraseDirectory(file); - else + else if(file.isDirectory()) { + // work around issue where Files.isSymbolicLink returns false on Windows for node/antlr4 linked package + if("antlr4".equals(name)) + ; // logger.warning("antlr4 not seen as a symlink"); + else + eraseDirectory(file); + } else file.delete(); } + private static String detectedOS; public static String getOS() { diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/TestContext.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/TestContext.java index 50a3d97b5..9646c352c 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/TestContext.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/TestContext.java @@ -6,6 +6,10 @@ public abstract class TestContext { return "true".equals(String.valueOf(System.getenv("TRAVIS")).toLowerCase()); } + public static boolean isGitHubCI() { + return "true".equals(String.valueOf(System.getenv("CI")).toLowerCase()); + } + public static boolean isAppVeyorCI() { return "true".equals(String.valueOf(System.getenv("APPVEYOR")).toLowerCase()); } @@ -14,9 +18,14 @@ public abstract class TestContext { return "true".equals(String.valueOf(System.getenv("CIRCLECI")).toLowerCase()); } + public static boolean isCI() { + return isAppVeyorCI() || isCircleCI() || isGitHubCI() || isTravisCI(); + } + + @SuppressWarnings("BooleanMethodIsAlwaysInverted") public static boolean isSupportedTarget(String target) { if(isAppVeyorCI()) - return !target.matches("Swift|Node"); + return !target.matches("Swift"); else return true; } diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/javascript/BaseNodeTest.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/javascript/BaseNodeTest.java index f58bd075c..b22e632d6 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/javascript/BaseNodeTest.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/javascript/BaseNodeTest.java @@ -5,6 +5,7 @@ */ package org.antlr.v4.test.runtime.javascript; +import org.antlr.v4.runtime.misc.Utils; import org.antlr.v4.test.runtime.*; import org.stringtemplate.v4.ST; @@ -121,7 +122,7 @@ public class BaseNodeTest extends BaseRuntimeTestSupport implements RuntimeTestS public String execModule(String fileName) { try { String npmPath = locateNpm(); - if(!TestContext.isTravisCI() && !TestContext.isCircleCI()) { + if(!TestContext.isCI()) { installRuntime(npmPath); registerRuntime(npmPath); } @@ -203,7 +204,8 @@ public class BaseNodeTest extends BaseRuntimeTestSupport implements RuntimeTestS args.addAll(Arrays.asList(npmPath, "link", "antlr4")); ProcessBuilder builder = new ProcessBuilder(args.toArray(new String[0])); builder.directory(getTempTestDir()); - builder.redirectError(new File(getTempTestDir(), "error.txt")); + File errorFile = new File(getTempTestDir(), "error.txt"); + builder.redirectError(errorFile); builder.redirectOutput(new File(getTempTestDir(), "output.txt")); Process process = builder.start(); // TODO switch to jdk 8 @@ -211,8 +213,10 @@ public class BaseNodeTest extends BaseRuntimeTestSupport implements RuntimeTestS // if(!process.waitFor(30L, TimeUnit.SECONDS)) // process.destroyForcibly(); int error = process.exitValue(); - if(error!=0) - throw new IOException("'npm link antlr4' failed"); + if(error!=0) { + char[] errors = Utils.readFile(errorFile.getAbsolutePath()); + throw new IOException("'npm link antlr4' failed: " + new String(errors)); + } } private boolean canExecute(String tool) { @@ -237,6 +241,8 @@ public class BaseNodeTest extends BaseRuntimeTestSupport implements RuntimeTestS // typically /usr/local/bin/npm String prop = System.getProperty("antlr-javascript-npm"); if ( prop!=null && prop.length()!=0 ) { + if(prop.contains(" ")) + prop = "\"" + prop + "\""; return prop; } return "npm"; // everywhere @@ -246,6 +252,8 @@ public class BaseNodeTest extends BaseRuntimeTestSupport implements RuntimeTestS // typically /usr/local/bin/node String prop = System.getProperty("antlr-javascript-nodejs"); if ( prop!=null && prop.length()!=0 ) { + if(prop.contains(" ")) + prop = "\"" + prop + "\""; return prop; } if (canExecute("nodejs")) {