Skip to content

Commit fb0abc4

Browse files
JasonAtClockworkJason Larabie
andauthored
Update Unreal SDK tests to work on Mac (#4861)
# Description of Changes - Updated the Unreal SDK test harness to allow Unreal Editor to work with MacOS - Updated the Unreal SDK test handler to work with Nil as it's a special case # API and ABI breaking changes N/A # Expected complexity level and risk 1 - Small changes to the Unreal SDK tests # Testing - [x] Ran full suite of tests on Mac for Unreal SDK - [x] Ran full suite of tests on Windows + Linux for Unreal SDK to confirm no regression --------- Co-authored-by: Jason Larabie <jasonlarabie@Mac.lan>
1 parent 23eafea commit fb0abc4

2 files changed

Lines changed: 46 additions & 11 deletions

File tree

sdks/unreal/tests/TestClient/Source/TestClient/Private/Tests/TestHandler.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
#include "Tests/TestCounter.h"
55
#include "Tests/CommonTestFunctions.h"
66

7+
#ifdef Nil
8+
#define SPACETIMEDB_NIL_MACRO_SAVED
9+
#pragma push_macro("Nil")
10+
#undef Nil
11+
#endif
12+
713
/* Implementation for every primitive ---------------------------------- */
814
#define DEFINE_UFUNC(Suffix, Expected, RowStructType) \
915
void UInsertPrimitiveHandler::OnInsertOne##Suffix(const FEventContext& Context, const RowStructType& Value) \
@@ -1712,3 +1718,7 @@ void UUuidActionsHandler::OnInsertCallUuidV7(const FEventContext& Context, const
17121718
Counter->MarkFailure(TEXT("InsertCallUuidV7"), ErrorMessage);
17131719
}
17141720
}
1721+
#ifdef SPACETIMEDB_NIL_MACRO_SAVED
1722+
#pragma pop_macro("Nil")
1723+
#undef SPACETIMEDB_NIL_MACRO_SAVED
1724+
#endif

sdks/unreal/tests/sdk_unreal_harness.rs

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,34 @@ fn normalize_path(path: PathBuf) -> String {
2323
path.display().to_string().replace('\\', "/")
2424
}
2525

26+
fn env_override_path(var: &str) -> Option<String> {
27+
env::var(var)
28+
.ok()
29+
.filter(|value| !value.trim().is_empty())
30+
.map(|value| value.replace('\\', "/"))
31+
}
32+
33+
fn host_unreal_platform() -> &'static str {
34+
if cfg!(target_os = "windows") {
35+
"Win64"
36+
} else if cfg!(target_os = "macos") {
37+
"Mac"
38+
} else {
39+
"Linux"
40+
}
41+
}
42+
2643
/// Returns full path to Unreal Editor executable
2744
fn ue_editor_exe() -> String {
45+
if let Some(path) = env_override_path("UE_EDITOR_PATH") {
46+
return path;
47+
}
48+
2849
let root = ue_root();
2950
let path = if cfg!(target_os = "windows") {
3051
root.join("Engine/Binaries/Win64/UnrealEditor.exe")
52+
} else if cfg!(target_os = "macos") {
53+
root.join("Engine/Binaries/Mac/UnrealEditor.app/Contents/MacOS/UnrealEditor")
3154
} else {
3255
root.join("Engine/Binaries/Linux/UnrealEditor")
3356
};
@@ -36,9 +59,15 @@ fn ue_editor_exe() -> String {
3659

3760
/// Returns full path to Unreal Build script (Build.bat or Build.sh)
3861
fn ue_build_script() -> String {
62+
if let Some(path) = env_override_path("UE_BUILD_SCRIPT_PATH") {
63+
return path;
64+
}
65+
3966
let root = ue_root();
4067
let path = if cfg!(target_os = "windows") {
4168
root.join("Engine/Build/BatchFiles/Build.bat")
69+
} else if cfg!(target_os = "macos") {
70+
root.join("Engine/Build/BatchFiles/Mac/Build.sh")
4271
} else {
4372
root.join("Engine/Build/BatchFiles/Linux/Build.sh")
4473
};
@@ -71,17 +100,13 @@ pub fn make_test_with_suite(suite: &TestSuite, test_name: &str) -> Test {
71100
assert_existing_file("uproject", &uproject_path);
72101

73102
// Headless compile (no cook)
74-
let compile_command = if cfg!(target_os = "windows") {
75-
format!(
76-
"\"{}\" {}Editor Win64 Development \"{}\" -waitmutex -skipbuildengine",
77-
build_script, suite.unreal_module, uproject_path
78-
)
79-
} else {
80-
format!(
81-
"\"{}\" {}Editor Linux Development \"{}\" -skipbuildengine",
82-
build_script, suite.unreal_module, uproject_path
83-
)
84-
};
103+
let compile_command = format!(
104+
"\"{}\" {}Editor {} Development -Project=\"{}\" -waitmutex -skipbuildengine",
105+
build_script,
106+
suite.unreal_module,
107+
host_unreal_platform(),
108+
uproject_path
109+
);
85110

86111
// Run automation test
87112
let run_command = format!(

0 commit comments

Comments
 (0)