Skip to content

Commit cc8223f

Browse files
authored
Remove redundant setting of noExitRuntime in test code. NFC (#13137)
Tests that set a main loop to make an async call don't need to set this explicitly.
1 parent 4cdb029 commit cc8223f

19 files changed

+25
-33
lines changed

tests/canvas_focus.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ int main()
3030
// Focus, then send an event, same as if the user clicked on it for focus.
3131
Module.canvas.focus();
3232
document.activeElement.dispatchEvent(event);
33-
noExitRuntime = true;
3433
});
34+
emscripten_exit_with_live_runtime();
35+
return 0;
3536
}

tests/emscripten_hide_mouse.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ int main()
1818
emscripten_hide_mouse();
1919
EMSCRIPTEN_RESULT ret = emscripten_set_click_callback("#canvas", 0, 1, mouse_callback);
2020
assert(ret == 0);
21-
EM_ASM(noExitRuntime = true);
21+
emscripten_exit_with_live_runtime();
22+
return 0;
2223
}

tests/emscripten_set_interval.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ void tick(void *userData)
3232
int main()
3333
{
3434
intervalId = emscripten_set_interval(tick, 100, (void*)1);
35-
EM_ASM(noExitRuntime = 1);
35+
emscripten_exit_with_live_runtime();
36+
return 0;
3637
}

tests/emscripten_set_timeout.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <emscripten/emscripten.h>
12
#include <emscripten/html5.h>
23
#include <emscripten/em_asm.h>
34
#include <assert.h>
@@ -44,5 +45,5 @@ void func1(void *userData)
4445
int main()
4546
{
4647
emscripten_set_timeout(func1, 100, (void*)1);
47-
EM_ASM(noExitRuntime = 1);
48+
emscripten_exit_with_live_runtime();
4849
}

tests/emscripten_set_timeout_loop.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <emscripten/emscripten.h>
12
#include <emscripten/html5.h>
23
#include <emscripten/em_asm.h>
34
#include <assert.h>
@@ -30,5 +31,6 @@ EM_BOOL tick(double time, void *userData)
3031
int main()
3132
{
3233
emscripten_set_timeout_loop(tick, 100, (void*)1);
33-
EM_ASM(noExitRuntime = 1);
34+
emscripten_exit_with_live_runtime();
35+
return 0;
3436
}

tests/gl_in_mainthread_after_pthread.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ void PollThreadExit(void *)
116116

117117
int main()
118118
{
119-
EM_ASM(noExitRuntime = true;);
120119
CreateThread();
121120
emscripten_async_call(PollThreadExit, 0, 1000);
122121
return 0;

tests/gl_in_pthread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ void *mymain(void*)
109109
int main()
110110
{
111111
#ifdef TEST_CHAINED_WEBGL_CONTEXT_PASSING
112-
EM_ASM(noExitRuntime = true;);
113112
pthread_attr_t attr;
114113
pthread_attr_init(&attr);
115114
#ifndef TRANSFER_TO_CHAINED_THREAD_FROM_MAIN_THREAD
@@ -124,6 +123,7 @@ int main()
124123
#endif
125124
exit(0);
126125
}
126+
emscripten_exit_with_live_runtime();
127127
#else
128128
mymain(0);
129129
#endif

tests/gl_only_in_pthread.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ int main()
9898
#endif
9999
return 0;
100100
}
101-
EM_ASM(noExitRuntime = true;);
102101
CreateThread();
103102
emscripten_async_call(PollThreadExit, 0, 100);
104103
return 0;

tests/html5_callbacks_on_calling_thread.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void *threadMain(void *arg)
5353
emscripten_current_thread_process_queued_calls();
5454
}
5555
#else
56-
EM_ASM(noExitRuntime = true);
56+
emscripten_exit_with_live_runtime();
5757
#endif
5858
return 0;
5959
}
@@ -66,5 +66,5 @@ int main()
6666
int rc = pthread_create(&thread, NULL, threadMain, 0);
6767
assert(rc == 0);
6868

69-
EM_ASM(noExitRuntime = true);
69+
emscripten_exit_with_live_runtime();
7070
}

tests/html5_event_callback_in_two_threads.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,5 @@ int main()
112112

113113
printf("Please press the Enter key.\n");
114114

115-
EM_ASM(noExitRuntime = true);
115+
emscripten_exit_with_live_runtime();
116116
}

tests/pthread/emscripten_thread_sleep.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@ int main()
4040
Sleep(5000);
4141
pthread_t thread;
4242
pthread_create(&thread, NULL, thread_main, NULL);
43-
EM_ASM(noExitRuntime=true);
43+
emscripten_exit_with_live_runtime();
44+
return 0;
4445
}

tests/pthread/test_pthread_clock_drift.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ int main()
5757
mainThreadTime = emscripten_get_now();
5858
wake(&timeReceived);
5959

60-
EM_ASM(noExitRuntime=true);
60+
emscripten_exit_with_live_runtime();
6161
}

tests/resize_offscreencanvas_from_main_thread.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ void thread_local_main_loop()
2929
emscripten_cancel_main_loop();
3030
#endif
3131

32-
EM_ASM(noExitRuntime=false);
33-
exit(0);
32+
emscripten_force_exit(0);
3433
}
3534
printf("%dx%d\n", w, h);
3635
}
@@ -59,7 +58,6 @@ void *thread_main(void *arg)
5958
emscripten_set_main_loop(thread_local_main_loop, 1, 0);
6059
#endif
6160

62-
EM_ASM(noExitRuntime=true);
6361
return 0;
6462
}
6563

@@ -106,7 +104,6 @@ int main()
106104
printf("Creating thread.\n");
107105
pthread_create(&thread, &attr, thread_main, NULL);
108106
pthread_detach(thread);
109-
EM_ASM(noExitRuntime=true);
110107

111108
// Wait for a while, then change the canvas size on the main thread.
112109
printf("Waiting for 5 seconds for good measure.\n");

tests/test_gamepad.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,6 @@ int main()
114114

115115
emscripten_set_main_loop(mainloop, 10, 0);
116116

117-
/* For the events to function, one must either call emscripten_set_main_loop or enable Module.noExitRuntime by some other means.
118-
Otherwise the application will exit after leaving main(), and the atexit handlers will clean up all event hooks (by design). */
119-
EM_ASM(noExitRuntime = true);
120-
121117
#ifdef REPORT_RESULT
122118
// Keep the page running for a moment.
123119
emscripten_async_call(report_result, 0, 5000);

tests/test_html5_core.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,13 +425,11 @@ int main()
425425
ret = (width && height) ? EMSCRIPTEN_RESULT_SUCCESS : EMSCRIPTEN_RESULT_FAILED;
426426
TEST_RESULT(emscripten_get_screen_size);
427427

428-
/* For the events to function, one must either call emscripten_set_main_loop or enable Module.noExitRuntime by some other means.
429-
Otherwise the application will exit after leaving main(), and the atexit handlers will clean up all event hooks (by design). */
430-
EM_ASM(noExitRuntime = true);
431-
432428
#ifdef REPORT_RESULT
433429
// Keep the page running for a moment.
434430
emscripten_async_call(report_result, 0, 5000);
431+
#else
432+
emscripten_exit_with_live_runtime();
435433
#endif
436434
return 0;
437435
}

tests/test_html5_mouse.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,5 @@ int main()
173173
);
174174
#endif
175175

176-
/* For the events to function, one must either call emscripten_set_main_loop or enable Module.noExitRuntime by some other means.
177-
Otherwise the application will exit after leaving main(), and the atexit handlers will clean up all event hooks (by design). */
178-
EM_ASM(noExitRuntime = true);
179176
return 0;
180177
}

tests/test_html5_pointerlockerror.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ int main()
9494
ret = emscripten_set_pointerlockerror_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, 0, 1, pointerlockerror_callback);
9595
TEST_RESULT(emscripten_set_pointerlockerror_callback);
9696

97-
/* For the events to function, one must either call emscripten_set_main_loop or enable Module.noExitRuntime by some other means.
98-
Otherwise the application will exit after leaving main(), and the atexit handlers will clean up all event hooks (by design). */
99-
EM_ASM(noExitRuntime = true);
97+
emscripten_exit_with_live_runtime();
10098
return 0;
10199
}

tests/test_keyboard_codes.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,6 @@ int main()
7979
emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, 0, 1, key_callback);
8080
emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, 0, 1, key_callback);
8181
emscripten_set_keypress_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, 0, 1, key_callback);
82-
EM_ASM(noExitRuntime = true);
82+
emscripten_exit_with_live_runtime();
83+
return 0;
8384
}

tests/test_other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2656,7 +2656,7 @@ def test_proxyfs(self):
26562656
create_test_file('proxyfs_pre.js', r'''
26572657
if (typeof Module === 'undefined') Module = {};
26582658
Module["noInitialRun"]=true;
2659-
noExitRuntime=true;
2659+
Module["noExitRuntime"]=true;
26602660
''')
26612661

26622662
create_test_file('proxyfs_embed.txt', 'test\n')

0 commit comments

Comments
 (0)