Skip to content

Commit

Permalink
Merge pull request #48 from Just-Feeshy/main
Browse files Browse the repository at this point in the history
Implement almost full support for MacOS
  • Loading branch information
SomeRanDev authored May 12, 2024
2 parents 06c60a1 + e9b1547 commit ddaaf54
Show file tree
Hide file tree
Showing 65 changed files with 4,292 additions and 5 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

on:
push:
branches:
Expand Down Expand Up @@ -58,3 +59,23 @@ jobs:

- name: Run Tests
run: haxe Test.hxml

build_macos:
runs-on: macos-12
name: Test on macOS (Clang)
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: krdlab/setup-haxe@v1
with:
haxe-version: 4.3.0

- name: Install & Check Haxe
run: haxe -version

- name: Install Reflaxe
run: haxelib git reflaxe https://github.com/SomeRanDev/reflaxe.git

- name: Run Tests
run: haxe Test.hxml
28 changes: 23 additions & 5 deletions test/unit_testing/src/TestRunner.hx
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,24 @@ Makes it so only this test is ran. This option can be added multiple times to pe

Sys.println("\n===========\nTesting C++ Compilation\n===========\n");

if(systemName != "Windows" && systemName != "Linux") {
if(systemName != "Windows" && systemName != "Linux" && systemName != "Mac") {
Sys.println("C++ compilation test not supported for `" + systemName + "`");
return;
}

var shoudNotCompileMac = true;
for(arg in Sys.args()) {
if(arg.split("=")[0] == "test") {
shoudNotCompileMac = false;
break;
}
}

if(systemName == "Mac" && shoudNotCompileMac) {
Sys.println("C++ all test compilation not supported on Mac yet.");
return;
}

final failedTests = [];
for(t in tests) {
if(!processCppCompile(t, systemName, originalCwd)) {
Expand Down Expand Up @@ -308,14 +321,16 @@ function onProcessFail(process: sys.io.Process, hxml: String, ec: Int, stdoutCon
function compareOutputFolders(testDir: String): Bool {
final outFolder = haxe.io.Path.join([testDir, OUT_DIR]);
final intendedFolderSys = haxe.io.Path.join([testDir, INTENDED_DIR + "-" + systemName()]);

trace("Intended folder: " + intendedFolderSys);
final intendedFolder = if(sys.FileSystem.exists(intendedFolderSys)) {
intendedFolderSys;
} else {
haxe.io.Path.join([testDir, INTENDED_DIR]);
}

if(!sys.FileSystem.exists(intendedFolder)) {
printFailed("Intended folder does not exist?");
printFailed("Intended folder does not exist? Looking for: " + intendedFolder);
return false;
}

Expand Down Expand Up @@ -440,23 +455,27 @@ function processCppCompile(t: String, systemName: String, originalCwd: String):
Sys.println("cd " + testDir);
Sys.setCwd(testDir);

var backup_command;
final compileCommand = if(systemName == "Windows") {
// /W3 /WX /EHsc
"cl ../" + OUT_DIR + "/src/*.cpp /I ../" + OUT_DIR + "/include /std:c++17 /Fe:test_out.exe /W3 /WX /EHsc";
} else if(systemName == "Linux") {
// -W3 -Werror
"g++ -std=c++17 ../" + OUT_DIR + "/src/*.cpp -I ../" + OUT_DIR + "/include -o test_out -Wall -Werror -Wnon-virtual-dtor";
} else {
}else if(systemName == "Mac") {
"clang++ -std=c++17 ../" + OUT_DIR + "/src/*.cpp -I ../" + OUT_DIR + "/include -o test_out -Wall -Werror -Wnon-virtual-dtor -isysroot $(xcrun --show-sdk-path) -Wno-parentheses-equality";
}else {
throw "Unsupported system";
}

Sys.println(compileCommand);
Sys.println("");

final compileProcess = new sys.io.Process(compileCommand);

final stdoutContent = compileProcess.stdout.readAll().toString();
final stderrContent = compileProcess.stderr.readAll().toString();
final ec = compileProcess.exitCode();
compileProcess.close();

if(ec != 0) {
Sys.println("C++ compilation failed...");
Expand Down Expand Up @@ -494,4 +513,3 @@ function processCppCompile(t: String, systemName: String, originalCwd: String):

return result;
}

62 changes: 62 additions & 0 deletions test/unit_testing/tests/Sys/intended-Mac/_GeneratedFiles.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
src/haxe_io_Output.cpp
src/haxe_io_Bytes.cpp
src/haxe_exceptions_PosException.cpp
src/haxe_exceptions_NotImplementedException.cpp
src/haxe_Log.cpp
src/haxe_Exception.cpp
src/haxe_CallStack.cpp
src/cxx_io_NativeOutput.cpp
src/_main_.cpp
src/Sys.cpp
src/StringBuf.cpp
src/Main.cpp
include/haxe_iterators_MapKeyValueIterator.h
include/haxe_iterators_ArrayKeyValueIterator.h
include/haxe_iterators_ArrayIterator.h
include/haxe_io_Output.h
include/haxe_io_Error.h
include/haxe_io_Encoding.h
include/haxe_io_BytesData.h
include/haxe_io_Bytes.h
include/haxe_exceptions_PosException.h
include/haxe_exceptions_NotImplementedException.h
include/haxe_ds_StringMap.h
include/haxe_PosInfos.h
include/haxe_Log.h
include/haxe_Exception.h
include/haxe_Constraints.h
include/haxe_CallStack.h
include/dynamic/Dynamic_haxe_iterators_MapKeyValueIterator.h
include/dynamic/Dynamic_haxe_iterators_ArrayKeyValueIterator.h
include/dynamic/Dynamic_haxe_iterators_ArrayIterator.h
include/dynamic/Dynamic_haxe_io_Output.h
include/dynamic/Dynamic_haxe_io_Bytes.h
include/dynamic/Dynamic_haxe_exceptions_PosException.h
include/dynamic/Dynamic_haxe_exceptions_NotImplementedException.h
include/dynamic/Dynamic_haxe_ds_StringMap.h
include/dynamic/Dynamic_haxe_Log.h
include/dynamic/Dynamic_haxe_Exception.h
include/dynamic/Dynamic_haxe_Constraints.h
include/dynamic/Dynamic_haxe_CallStack.h
include/dynamic/Dynamic_cxx_io_NativeOutput.h
include/dynamic/Dynamic_Sys.h
include/dynamic/Dynamic_StringBuf.h
include/dynamic/Dynamic_Std.h
include/dynamic/Dynamic_Main.h
include/dynamic/Dynamic_HxString.h
include/dynamic/Dynamic_HxArray.h
include/dynamic/Dynamic.h
include/cxx_io_NativeOutput.h
include/cxx_DynamicToString.h
include/_TypeUtils.h
include/_HaxeUtils.h
include/_AnonUtils.h
include/_AnonStructs.h
include/Sys.h
include/StringBuf.h
include/StdTypes.h
include/Std.h
include/Map.h
include/Main.h
include/HxString.h
include/HxArray.h
Loading

0 comments on commit ddaaf54

Please sign in to comment.