Skip to content

Commit 1524c44

Browse files
committed
Extend tests with emcc support.
1 parent ffc5039 commit 1524c44

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

.github/workflows/macos.yml

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
- name: Checkout
2323
uses: actions/checkout@v4
2424

25+
- uses: mymindstorm/setup-emsdk@v14
26+
2527
- name: install premake5
2628
uses: Jarod42/install-premake5@v5
2729

.github/workflows/ubuntu.yml

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
- name: Checkout
2323
uses: actions/checkout@v4
2424

25+
- uses: mymindstorm/setup-emsdk@v14
26+
2527
- name: install premake5
2628
uses: Jarod42/install-premake5@v5
2729

.github/workflows/windows.yml

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
- name: Checkout
2323
uses: actions/checkout@v4
2424

25+
- uses: mymindstorm/setup-emsdk@v14
26+
2527
- name: install premake5
2628
uses: Jarod42/install-premake5@v5
2729

tests/run_tests.py

+24-7
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ def exit_test(self, build_dir = "build"):
8181
# call premake in the test
8282
def premake(self):
8383
if override_compiler:
84-
self.assertEqual(subprocess.call(["premake5", "--scripts=../../..", "--cc=" + override_compiler, "ninja"]), 0, "looks like premake failed")
84+
args = ["premake5", "--scripts=../../..", "--cc=" + override_compiler, "ninja"]
85+
if override_compiler == "emcc":
86+
args += ["--os=emscripten"]
87+
self.assertEqual(subprocess.call(args), 0, "looks like premake failed")
8588
else:
8689
self.assertEqual(subprocess.call(["premake5", "--scripts=../../..", "ninja"]), 0, "looks like premake failed")
8790

@@ -106,7 +109,7 @@ def out_name(self, path, ext = None, prefix = None):
106109

107110
# check if executable exist
108111
def out_exist(self, path):
109-
print("Looking for {} in {}", path, os.listdir(os.path.dirname(path)))
112+
print(f"Looking for {path} in {os.listdir(os.path.dirname(path))}")
110113
sys.stdout.flush()
111114
self.assertTrue(
112115
os.path.exists(path) or
@@ -116,9 +119,10 @@ def out_exist(self, path):
116119
os.path.exists(self.out_name(path, ".a", "lib")) or
117120
os.path.exists(self.out_name(path, ".dll")) or
118121
os.path.exists(self.out_name(path, ".so", "lib")) or
119-
os.path.exists(self.out_name(path, ".dylib", "lib"))
122+
os.path.exists(self.out_name(path, ".dylib", "lib")) or
123+
os.path.exists(self.out_name(path, ".wasm"))
120124
)
121-
print("Found {}", path)
125+
print(f"Found {path}")
122126
sys.stdout.flush()
123127
# check if executable doesn't exist
124128
def out_not_exist(self, path):
@@ -130,7 +134,8 @@ def out_not_exist(self, path):
130134
os.path.exists(self.out_name(path, ".a", "lib")) or
131135
os.path.exists(self.out_name(path, ".dll")) or
132136
os.path.exists(self.out_name(path, ".so", "lib")) or
133-
os.path.exists(self.out_name(path, ".dylib", "lib"))
137+
os.path.exists(self.out_name(path, ".dylib", "lib")) or
138+
os.path.exists(self.out_name(path, ".wasm"))
134139
)
135140

136141
# check if executable exist
@@ -179,8 +184,9 @@ def check_basics(self, out_debug, out_release, build_dir = "build"):
179184
self.out_exist(out_release)
180185

181186
# run executables to check if they are valid
182-
self.exe(out_debug)
183-
self.exe(out_release)
187+
if override_compiler != "emcc":
188+
self.exe(out_debug)
189+
self.exe(out_release)
184190

185191
# ----------------------------------------------------- console app tests
186192
class TestConsoleApp(Helper):
@@ -218,12 +224,18 @@ def test_withapp(self):
218224
class TestSharedLib(Helper):
219225
# test simple app
220226
def test_simple(self):
227+
# Skip shared library tests on Emscripten since this is an advanced feature not supported by Premake yet.
228+
if override_compiler == "emcc":
229+
return
221230
self.enter_test("shared_lib/simple")
222231
self.check_basics("build/bin_debug/ninjatestprj", "build/bin_release/ninjatestprj")
223232
self.exit_test()
224233

225234
# test shared lib with app
226235
def test_withapp(self):
236+
# Skip shared library tests on Emscripten since this is an advanced feature not supported by Premake yet.
237+
if override_compiler == "emcc":
238+
return
227239
self.enter_test("shared_lib/withapp")
228240
self.check_basics("build/bin_debug/ninjatestprj_app", "build/bin_release/ninjatestprj_app")
229241
self.out_exist("build/bin_debug/ninjatestprj_lib_test1")
@@ -251,3 +263,8 @@ def test_simple(self):
251263
print("-------------------------- found gcc on windows")
252264
override_compiler = "gcc"
253265
unittest.main()
266+
267+
if which("emcc"):
268+
print("-------------------------- found emcc")
269+
override_compiler = "emcc"
270+
unittest.main()

0 commit comments

Comments
 (0)