Skip to content
Merged
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
94 changes: 64 additions & 30 deletions tests/runci/targets/Cpp.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -40,44 +51,67 @@ class Cpp {
runCommand(bin, args);
}

static public function runCppia(script:String, ?host:String, ?run:(String, Array<String>) -> Void):Void {
if (run == null) run = runCommand;
var cmd:String;
var args:Array<String>;
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<String>, 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);
}
}
}
18 changes: 18 additions & 0 deletions tests/sys/compile-cppia.hxml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions tests/sys/compile.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/sys/gen_test_res.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 2 additions & 0 deletions tests/sys/run.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions tests/sys/src/ExitCode.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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]));
}
}
10 changes: 8 additions & 2 deletions tests/sys/src/TestArguments.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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
Comment thread
Simn marked this conversation as resolved.
for (i in 0...expectedArgs.length) {
Assert.equals(expectedArgs[i], args[i]);
}
Expand Down
8 changes: 8 additions & 0 deletions tests/sys/src/TestCommandBase.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion tests/sys/src/TestSys.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion tests/sys/src/TestUnicode.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
18 changes: 16 additions & 2 deletions tests/sys/src/UtilityProcess.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
Expand All @@ -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";
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down
Loading