diff --git a/tests/runci/targets/Cpp.hx b/tests/runci/targets/Cpp.hx index fe02584cf1a..7aa2da7cd69 100644 --- a/tests/runci/targets/Cpp.hx +++ b/tests/runci/targets/Cpp.hx @@ -6,6 +6,8 @@ import runci.Config.*; class Cpp { static public var gotCppDependencies = false; + static final isLinuxArm64 = systemName == 'Linux' && System.arch == Arm64; + static var testCppia = false; static public function getCppDependencies() { if (gotCppDependencies) return; @@ -25,10 +27,19 @@ class Cpp { infoMsg('hxcpp has already been installed in $path.'); } catch(e:Dynamic) { haxelibInstallGit("HaxeFoundation", "hxcpp", true); - final oldDir = Sys.getCwd(); - changeDirectory(getHaxelibPath("hxcpp") + "tools/hxcpp/"); - runCommand("haxe", ["-D", "source-header=''", "compile.hxml"]); - changeDirectory(oldDir); + runCommand("haxe", [ + "--cwd", getHaxelibPath("hxcpp") + "tools/hxcpp/", + "-D", "source-header=''", + "compile.hxml" + ]); + if (testCppia) { + final hxmlSuffix = if (System.arch == Arm64) "-arm64" else ""; + runCommand("haxe", [ + "--cwd", getHaxelibPath("hxcpp") + "project/", + "-D", "source-header=''", + 'compile-cppia${hxmlSuffix}.hxml' + ]); + } } gotCppDependencies = true; @@ -40,44 +51,67 @@ class Cpp { runCommand(bin, args); } + static public function runCppia(script:String, ?host:String, ?run:(String, Array) -> Void):Void { + if (run == null) run = runCommand; + var cmd:String; + var args:Array; + if (host == null) { + cmd = "haxelib"; + args = ["run", "hxcpp"]; + } else { + cmd = host; + args = []; + } + run(cmd, args.concat([script])); + if (!isLinuxArm64) { // FIXME + Sys.putEnv("CPPIA_IS_JIT", "1"); + run(cmd, args.concat([script, "-jit"])); + Sys.putEnv("CPPIA_IS_JIT", null); + } + } + static public function run(args:Array, testCompiled:Bool, testCppia:Bool) { + Cpp.testCppia = testCppia; + getCppDependencies(); if (testCompiled) { - runCommand("rm", ["-rf", "cpp"]); runCommand("haxe", ["compile-cpp.hxml"].concat(args)); runCpp("bin/cpp/TestMain-debug", []); - } - - if (testCppia) { - runCommand("haxe", ["compile-cppia-host.hxml"].concat(args)); - runCommand("haxe", ["compile-cppia.hxml"].concat(args)); - runCpp("bin/cppia/Host-debug", ["bin/unit.cppia"]); - if (!(systemName == 'Linux' && System.arch == Arm64)) // FIXME - runCpp("bin/cppia/Host-debug", ["bin/unit.cppia", "-jit"]); - } + changeDirectory(sysDir); + runCommand("haxe", ["--each", "compile-cpp.hxml"].concat(args)); + runSysTest(FileSystem.fullPath("bin/cpp/Main-debug")); - changeDirectory(sysDir); - runCommand("haxe", ["--each", "compile-cpp.hxml"].concat(args)); - runSysTest(FileSystem.fullPath("bin/cpp/Main-debug")); + changeDirectory(threadsDir); + runCommand("haxe", ["build.hxml", "-cpp", "export/cpp"]); + runCpp("export/cpp/Main"); - changeDirectory(threadsDir); - runCommand("haxe", ["build.hxml", "-cpp", "export/cpp"]); - runCpp("export/cpp/Main"); + changeDirectory(getMiscSubDir("cross", "eventLoop")); + runCommand("haxe", ["build-cpp.hxml"]); + // TODO: check output like misc tests do + runCpp("cpp/Main"); - changeDirectory(getMiscSubDir("cross", "eventLoop")); - runCommand("haxe", ["build-cpp.hxml"]); - // TODO: check output like misc tests do - runCpp("cpp/Main"); + if (Sys.systemName() == "Mac") { + changeDirectory(getMiscSubDir("cpp", "cppObjc")); + runCommand("haxe", ["build.hxml"]); + runCpp("bin/TestObjc-debug"); + } - if (Sys.systemName() == "Mac") { - changeDirectory(getMiscSubDir("cpp", "cppObjc")); - runCommand("haxe", ["build.hxml"]); - runCpp("bin/TestObjc-debug"); + changeDirectory(getMiscSubDir("")); + runCommand("haxe", ["run-base.hxml", "--run", "Main", "cpp"]); } - changeDirectory(getMiscSubDir("")); - runCommand("haxe", ["run-base.hxml", "--run", "Main", "cpp"]); + if (testCppia) { + changeDirectory(unitDir); + + runCommand("haxe", ["compile-cppia-host.hxml"].concat(args)); + runCommand("haxe", ["compile-cppia.hxml"].concat(args)); + runCppia("bin/unit.cppia", FileSystem.fullPath("bin/cppia/Host-debug")); + + changeDirectory(sysDir); + runCommand("haxe", ["compile-cppia.hxml"].concat(args)); + runCppia("bin/cppia/Main.cppia", runSysTest); + } } } diff --git a/tests/sys/compile-cppia.hxml b/tests/sys/compile-cppia.hxml new file mode 100644 index 00000000000..d91007209ec --- /dev/null +++ b/tests/sys/compile-cppia.hxml @@ -0,0 +1,18 @@ +compile-each.hxml +--main Main +-cppia bin/cppia/Main.cppia + +--next +compile-each.hxml +--main TestArguments +-cppia bin/cppia/TestArguments.cppia + +--next +compile-each.hxml +--main ExitCode +-cppia bin/cppia/ExitCode.cppia + +--next +compile-each.hxml +--main UtilityProcess +-cppia bin/cppia/UtilityProcess.cppia diff --git a/tests/sys/compile.hxml b/tests/sys/compile.hxml index 18808003411..9db2fcdfdff 100644 --- a/tests/sys/compile.hxml +++ b/tests/sys/compile.hxml @@ -3,6 +3,7 @@ --next compile-neko.hxml --next compile-python.hxml --next compile-cpp.hxml +--next compile-cppia.hxml --next compile-jvm.hxml --next compile-php.hxml --next compile-hl.hxml diff --git a/tests/sys/gen_test_res.py b/tests/sys/gen_test_res.py index 4cd288a1ab3..fac084673bd 100755 --- a/tests/sys/gen_test_res.py +++ b/tests/sys/gen_test_res.py @@ -79,6 +79,7 @@ for target, name in [ ("../../bin/cpp/UtilityProcess-debug", "bin-cpp-debug"), ("../../bin/cpp/UtilityProcess", "bin-cpp"), + ("../../bin/cppia/UtilityProcess.cppia", "bin-cppia"), ("../../bin/hl/UtilityProcess.hl", "bin-hl"), ("../../bin/hlc/utilityProcess/UtilityProcess.exe", "bin-hlc"), ("../../bin/lua/UtilityProcess.lua", "bin-lua"), diff --git a/tests/sys/run.hxml b/tests/sys/run.hxml index d3f0f8193ec..c189cdd9efa 100644 --- a/tests/sys/run.hxml +++ b/tests/sys/run.hxml @@ -13,6 +13,7 @@ compile.hxml --cmd echo Neko && export EXISTS=1 && neko bin/neko/sys.n --cmd echo Python && export EXISTS=1 && python3 bin/python/sys.py --cmd echo Cpp && export EXISTS=1 && bin/cpp/Main-debug +--cmd echo Cppia && export EXISTS=1 && haxelib run hxcpp bin/cppia/Main.cppia --cmd echo Java && export EXISTS=1 && java -jar bin/java/Main-Debug.jar --cmd echo Php && export EXISTS=1 && php bin/php/Main/index.php --cmd echo Hl && export EXISTS=1 && hl bin/hl/sys.hl @@ -25,6 +26,7 @@ compile.hxml # --cmd echo Neko && set EXISTS=1 && neko bin\neko\sys.n # --cmd echo Python && set EXISTS=1 && python3 bin\python\sys.py # --cmd echo Cpp && set EXISTS=1 && bin\cpp\Main-debug.exe +# --cmd echo Cppia && set EXISTS=1 && haxelib run hxcpp bin/cppia/Main.cppia # --cmd echo Java && set EXISTS=1 && java -jar bin\java\Main-Debug.jar # --cmd echo Php && set EXISTS=1 && php -c ..\PHP.ini bin\php\Main\index.php # --cmd echo Hl && set EXISTS=1 && hl bin/hl/sys.hl diff --git a/tests/sys/src/ExitCode.hx b/tests/sys/src/ExitCode.hx index 074961bcb90..e555eb33497 100644 --- a/tests/sys/src/ExitCode.hx +++ b/tests/sys/src/ExitCode.hx @@ -18,7 +18,9 @@ class ExitCode { "bin/hl/ExitCode.hl"; #end #elseif cpp - #if debug + #if cppia + "bin/cppia/ExitCode.cppia"; + #elseif debug "bin/cpp/ExitCode-debug"; #else "bin/cpp/ExitCode"; @@ -84,6 +86,6 @@ class ExitCode { } static function main():Void { - Sys.exit(Std.parseInt(Sys.args()[0])); + Sys.exit(Std.parseInt(Sys.args()[#if cppia 1 #else 0 #end])); } } diff --git a/tests/sys/src/TestArguments.hx b/tests/sys/src/TestArguments.hx index 0ecc862038c..2afe7b906f9 100644 --- a/tests/sys/src/TestArguments.hx +++ b/tests/sys/src/TestArguments.hx @@ -78,7 +78,9 @@ class TestArguments extends utest.Test { "bin/hl/TestArguments.hl"; #end #elseif cpp - #if debug + #if cppia + "bin/cppia/TestArguments.cppia"; + #elseif debug "bin/cpp/TestArguments-debug"; #else "bin/cpp/TestArguments"; @@ -98,7 +100,11 @@ class TestArguments extends utest.Test { #end function testArgs() { - var args = Sys.args(); + final args = Sys.args(); + #if cppia + args.shift(); + args.remove("-jit"); + #end for (i in 0...expectedArgs.length) { Assert.equals(expectedArgs[i], args[i]); } diff --git a/tests/sys/src/TestCommandBase.hx b/tests/sys/src/TestCommandBase.hx index 9a8ade8a0e1..738c89e89f6 100644 --- a/tests/sys/src/TestCommandBase.hx +++ b/tests/sys/src/TestCommandBase.hx @@ -20,7 +20,11 @@ class TestCommandBase extends utest.Test { #if (macro || interp) run("haxe", ["--hxb-lib", bin, "--run", "TestArguments"].concat(args)); #elseif cpp + #if cppia + run("haxelib", ["run", "hxcpp", bin].concat(args).concat(Sys.getEnv("CPPIA_IS_JIT") == null ? [] : ["-jit"])); + #else run(bin, args); + #end #elseif java run(Path.join([java.lang.System.getProperty("java.home"), "bin", "java"]), ["-jar", bin].concat(args)); #elseif python @@ -110,7 +114,11 @@ class TestCommandBase extends utest.Test { #if (macro || interp) run("haxe", ["--hxb-lib", bin, "--run", "ExitCode"].concat(args)); #elseif cpp + #if cppia + run("haxelib", ["run", "hxcpp", bin].concat(args).concat(Sys.getEnv("CPPIA_IS_JIT") == null ? [] : ["-jit"])); + #else run(bin, args); + #end #elseif java run(Path.join([java.lang.System.getProperty("java.home"), "bin", "java"]), ["-jar", bin].concat(args)); #elseif python diff --git a/tests/sys/src/TestSys.hx b/tests/sys/src/TestSys.hx index 062463a045b..0e4a056d8ef 100644 --- a/tests/sys/src/TestSys.hx +++ b/tests/sys/src/TestSys.hx @@ -107,7 +107,12 @@ class TestSys extends TestCommandBase { #elseif neko "sys.n" #elseif cpp - "Main-debug" + (Sys.systemName() == "Windows" ? ".exe" : "") + #if cppia + //"Main.cppia" + "Cppia" + (Sys.systemName() == "Windows" ? ".exe" : "") + #else + "Main-debug" + (Sys.systemName() == "Windows" ? ".exe" : "") + #end #elseif jvm "sys.jar" #elseif python diff --git a/tests/sys/src/TestUnicode.hx b/tests/sys/src/TestUnicode.hx index fd2829ebc95..b1835b9e136 100644 --- a/tests/sys/src/TestUnicode.hx +++ b/tests/sys/src/TestUnicode.hx @@ -11,7 +11,9 @@ import UtilityProcess.runUtility; class TestUnicode extends utest.Test { static var BIN_SYMLINK = #if cpp - #if debug + #if cppia + "bin-cppia"; + #elseif debug "bin-cpp-debug"; #else "bin-cpp"; diff --git a/tests/sys/src/UtilityProcess.hx b/tests/sys/src/UtilityProcess.hx index 58289044136..1c05b6b4072 100644 --- a/tests/sys/src/UtilityProcess.hx +++ b/tests/sys/src/UtilityProcess.hx @@ -9,7 +9,11 @@ import sys.io.Process; class UtilityProcess { public static var BIN_PATH = #if cpp + #if cppia + Path.join(["bin", "cppia"]); + #else Path.join(["bin", "cpp"]); + #end #elseif hl #if hlc Path.join(["bin", "hlc/utilityProcess"]); @@ -35,7 +39,9 @@ class UtilityProcess { #end public static var BIN_NAME = #if cpp - #if debug + #if cppia + "UtilityProcess.cppia"; + #elseif debug "UtilityProcess-debug"; #else "UtilityProcess"; @@ -73,6 +79,8 @@ class UtilityProcess { var proc = #if (macro || interp) new Process("haxe", ["--hxb-lib", execFull, "--run", Path.withoutExtension(BIN_NAME)].concat(args)); + #elseif cppia + new Process("haxelib", ["run", "hxcpp", execFull].concat(args).concat(Sys.getEnv("CPPIA_IS_JIT") == null ? [] : ["-jit"])); #elseif cpp new Process(execFull, args); #elseif java @@ -119,6 +127,8 @@ class UtilityProcess { final exitCode = #if (macro || interp) Sys.command("haxe", ["--hxb-lib", execFull, "--run", BIN_NAME.substr(0, -4)].concat(args)); + #elseif cppia + Sys.command("haxelib", ["run", "hxcpp", execFull].concat(args).concat(Sys.getEnv("CPPIA_IS_JIT") == null ? [] : ["-jit"])); #elseif cpp Sys.command(execFull, args); #elseif java @@ -143,7 +153,11 @@ class UtilityProcess { } public static function main():Void { - var args = Sys.args(); + final args = Sys.args(); + #if cppia + args.shift(); + args.remove("-jit"); + #end function sequenceIndex(d:String, mode:String):String return switch UnicodeSequences.valid[Std.parseInt(d)] { case Only(ref): UnicodeSequences.codepointsToString(ref);