Skip to content

[tests] Enable sys, threads, eventloop cppia tests #11922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin
File renamed without changes.
1 change: 0 additions & 1 deletion tests/misc/eventLoop/build-cpp.hxml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
--main Main
--dce full
-cpp cpp
86 changes: 55 additions & 31 deletions tests/runci/targets/Cpp.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = null;

static public function getCppDependencies() {
if (gotCppDependencies) return;
Expand Down Expand Up @@ -43,59 +45,81 @@ class Cpp {
runCommand(bin, args);
}

static public function runCppia(script:String, ?args:Array<String>, ?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<String>, testCompiled:Bool, testCppia:Bool) {
getCppDependencies();

final isLinuxArm64 = systemName == 'Linux' && Linux.arch == Arm64;

final archFlag = switch systemName {
case 'Windows':
'HXCPP_M32';
case 'Linux' if(Linux.arch == Arm64):
'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"]);
}
}
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 @@ -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
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]));
}
}
6 changes: 4 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,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]);
}
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", ["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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tests/sys/src/TestSys.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
14 changes: 12 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 @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down
Loading