diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 00000000000..ba077a4031a --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +bin diff --git a/tests/unit/compile-cppia-host.hxml b/tests/compile-cppia-host.hxml similarity index 100% rename from tests/unit/compile-cppia-host.hxml rename to tests/compile-cppia-host.hxml diff --git a/tests/misc/eventLoop/build-cpp.hxml b/tests/misc/eventLoop/build-cpp.hxml index 744567b2e37..5ed715f3945 100644 --- a/tests/misc/eventLoop/build-cpp.hxml +++ b/tests/misc/eventLoop/build-cpp.hxml @@ -1,3 +1,2 @@ --main Main --dce full --cpp cpp diff --git a/tests/runci/targets/Cpp.hx b/tests/runci/targets/Cpp.hx index c56246f563a..740c7959f12 100644 --- a/tests/runci/targets/Cpp.hx +++ b/tests/runci/targets/Cpp.hx @@ -7,6 +7,8 @@ import runci.Config.*; class Cpp { static public var gotCppDependencies = false; static final miscCppDir = getMiscSubDir('cpp'); + static final isLinuxArm64 = systemName == 'Linux' && Linux.arch == Arm64; + static var cppiaHost:Null = null; static public function getCppDependencies() { if (gotCppDependencies) return; @@ -43,11 +45,17 @@ class Cpp { runCommand(bin, args); } + static public function runCppia(script:String, ?args:Array, ?run):Void { + if (args == null) args = []; + if (run == null) run = runCommand; + run(cppiaHost, [script].concat(args)); + if (!isLinuxArm64) // FIXME + run(cppiaHost, ["-jit", script].concat(args)); + } + static public function run(args:Array, testCompiled:Bool, testCppia:Bool) { getCppDependencies(); - final isLinuxArm64 = systemName == 'Linux' && Linux.arch == Arm64; - final archFlag = switch systemName { case 'Windows': 'HXCPP_M32'; @@ -55,47 +63,63 @@ class Cpp { 'HXCPP_LINUX_ARM64'; case _: 'HXCPP_M64'; - } + }; if (testCompiled) { - runCommand("rm", ["-rf", "cpp"]); runCommand("haxe", ["compile-cpp.hxml", "-D", archFlag].concat(args)); runCpp("bin/cpp/TestMain-debug", []); + + changeDirectory(sysDir); + runCommand("haxe", ["-D", archFlag, "--each", "compile-cpp.hxml"].concat(args)); + runSysTest(FileSystem.fullPath("bin/cpp/Main-debug")); + + if (!isLinuxArm64) { // FIXME + changeDirectory(threadsDir); + runCommand("haxe", ["-D", archFlag, "build.hxml", "-cpp", "bin/cpp"]); + runCpp("bin/cpp/Main"); + } + + changeDirectory(getMiscSubDir("eventLoop")); + runCommand("haxe", ["build-cpp.hxml", "-cpp", "bin/cpp"]); + // TODO: check output like misc tests do + runCpp("bin/cpp/Main"); + + if (Sys.systemName() == "Mac") { + changeDirectory(getMiscSubDir("cppObjc")); + runCommand("haxe", ["-D", archFlag, "build.hxml"]); + runCpp("bin/TestObjc-debug"); + } + + changeDirectory(miscCppDir); + runCommand("haxe", ["run.hxml"]); } if (testCppia) { + changeDirectory(cwd); runCommand("haxe", ["compile-cppia-host.hxml", "-D", archFlag].concat(args)); + cppiaHost = FileSystem.fullPath("bin/cppia/Host-debug"); + Sys.putEnv("CPPIA_HOST", cppiaHost); + + changeDirectory(unitDir); runCommand("haxe", ["compile-cppia.hxml"].concat(args)); - runCpp("bin/cppia/Host-debug", ["bin/unit.cppia"]); + runCppia("bin/unit.cppia"); - if (!isLinuxArm64) // FIXME - runCpp("bin/cppia/Host-debug", ["bin/unit.cppia", "-jit"]); + changeDirectory(sysDir); + runCommand("haxe", ["compile-cppia.hxml"].concat(args)); + runCppia("bin/cppia/Main.cppia", runSysTest); + + if (!isLinuxArm64) { // FIXME + changeDirectory(threadsDir); + runCommand("haxe", ["-D", archFlag, "build.hxml", "-cppia", "export/cppia/threads.cppia"]); + runCppia("export/cppia/threads.cppia"); + } + + changeDirectory(getMiscSubDir("eventLoop")); + runCommand("haxe", ["build-cpp.hxml", "-cppia", "bin/cppia/Main.cppia"]); + // TODO: check output like misc tests do + runCppia("bin/cppia/Main.cppia"); } Display.maybeRunDisplayTests(Cpp); - - changeDirectory(sysDir); - runCommand("haxe", ["-D", archFlag, "--each", "compile-cpp.hxml"].concat(args)); - runSysTest(FileSystem.fullPath("bin/cpp/Main-debug")); - - if (!isLinuxArm64) { // FIXME - changeDirectory(threadsDir); - runCommand("haxe", ["-D", archFlag, "build.hxml", "-cpp", "export/cpp"]); - runCpp("export/cpp/Main"); - } - - changeDirectory(getMiscSubDir("eventLoop")); - runCommand("haxe", ["build-cpp.hxml"]); - // TODO: check output like misc tests do - runCpp("cpp/Main"); - - if (Sys.systemName() == "Mac") { - changeDirectory(getMiscSubDir("cppObjc")); - runCommand("haxe", ["-D", archFlag, "build.hxml"]); - runCpp("bin/TestObjc-debug"); - } - - changeDirectory(miscCppDir); - runCommand("haxe", ["run.hxml"]); } } 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 98cf3323299..bd2a177a52c 100644 --- a/tests/sys/compile.hxml +++ b/tests/sys/compile.hxml @@ -4,6 +4,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 394d0997ebb..5a10496fc14 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 0374b25e2ad..0254b283903 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 44b4d216b14..0ed65377325 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 791c83e99cc..63293d8003e 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,7 @@ class TestArguments extends utest.Test { #end function testArgs() { - var args = Sys.args(); + var args = Sys.args() #if cppia .slice(1) #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 876f1617e12..75025904009 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", ["compile-each.hxml", "--run", "TestArguments"].concat(args)); #elseif cpp + #if cppia + run(Sys.getEnv("CPPIA_HOST"), [bin].concat(args)); + #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", ["compile-each.hxml", "--run", "ExitCode"].concat(args)); #elseif cpp + #if cppia + run(Sys.getEnv("CPPIA_HOST"), [bin].concat(args)); + #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 ed62ff17a89..80b6a07c36b 100644 --- a/tests/sys/src/TestSys.hx +++ b/tests/sys/src/TestSys.hx @@ -106,12 +106,12 @@ class TestSys extends TestCommandBase { #elseif neko Assert.isTrue(StringTools.endsWith(p, "sys.n")); #elseif cpp - switch (Sys.systemName()) { - case "Windows": - Assert.isTrue(StringTools.endsWith(p, "Main-debug.exe")); - case _: - Assert.isTrue(StringTools.endsWith(p, "Main-debug")); - } + #if cppia + // Assert.isTrue(StringTools.endsWith(p, "Main.cppia")); + Assert.isTrue(StringTools.endsWith(p, "Host-debug" + (Sys.systemName() == "Windows" ? ".exe" : ""))); + #else + Assert.isTrue(StringTools.endsWith(p, "Main-debug" + (Sys.systemName() == "Windows" ? ".exe" : ""))); + #end #elseif jvm Assert.isTrue(StringTools.endsWith(p, "sys.jar")); #elseif python diff --git a/tests/sys/src/TestUnicode.hx b/tests/sys/src/TestUnicode.hx index fd98c1f2582..e9490f7ea77 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 0e88a19b4f5..d42fadf4dc9 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"; @@ -76,6 +82,8 @@ class UtilityProcess { var proc = #if (macro || interp) new Process("haxe", ["compile-each.hxml", "-p", options.execPath, "--run", options.execName].concat(args)); + #elseif cppia + new Process(Sys.getEnv("CPPIA_HOST"), [execFull].concat(args)); #elseif cpp new Process(execFull, args); #elseif java @@ -125,6 +133,8 @@ class UtilityProcess { final exitCode = #if (macro || interp) Sys.command("haxe", ["compile-each.hxml", "-p", options.execPath, "--run", options.execName].concat(args)); + #elseif cppia + Sys.command(Sys.getEnv("CPPIA_HOST"), [execFull].concat(args)); #elseif cpp Sys.command(execFull, args); #elseif java @@ -149,7 +159,7 @@ class UtilityProcess { } public static function main():Void { - var args = Sys.args(); + var args = Sys.args() #if cppia .slice(1) #end; function sequenceIndex(d:String, mode:String):String return switch UnicodeSequences.valid[Std.parseInt(d)] { case Only(ref): UnicodeSequences.codepointsToString(ref);