@@ -34,6 +34,33 @@ webside.
3434 * Add a ` [prefix] ` to start of the PR title to signify the subsystem or area
3535 that the PR targets. e.g. ` [test] Update foo test ` or ` [ports] Fix zlib port `
3636
37+ ### Writing Tests
38+
39+ See [ Emscripten Test Suite] [ test_suite ] for information on how to get started
40+ running tests.
41+
42+ Almost all PRs should be accompanied by some kind of test.
43+
44+ * For bug fixes, try to update an existing test rather than adding a new one.
45+ * The majority of tests live in ` test_other.py ` and ` test_core.py ` . The
46+ difference between these is that tests in ` test_core.py ` are testing under
47+ many different combinations of settings, and so each test added there is
48+ the equivalent of adding ~ 10 new tests to ` test_other.py ` .
49+ * Prefer black box testing where possible (i.e. test the compiler using its
50+ public command line interface).
51+ * For C/C++ tests longer than a few lines, prefer separate source files over
52+ inline C/C++ within python.
53+ * C/C++ should use ` assert ` internally to check expectations and should return
54+ 0 from their ` main ` function.
55+ * For regression tests, try to minimize and understand the reproducer so that
56+ a minimal test can be created.
57+ * For simple tests, always prefer C over C++ since it comes with less baggage
58+ (i.e. it minimizes the scope of the system under test) and can be compiled
59+ very fast.
60+ * When testing changes to system libraries, remember to rebuild the libraries
61+ you touch (e.g. using ` ./embuilder ` ) before running tests (or use `emcc
62+ --clear-cache` as a blunt implement for forcing a rebuild of all libraries).
63+
3764## Coding Style
3865
3966### C/C++ Code
@@ -365,3 +392,4 @@ decide collectively to abandon the deprecation, or to delay it.
365392[ update_libunwind_emscripten ] : https://github.com/emscripten-core/emscripten/blob/main/system/lib/update_libunwind.py
366393[ update_musl_emscripten ] : https://github.com/emscripten-core/emscripten/blob/main/system/lib/update_musl.py
367394[ global_github_search ] : https://github.com/search?q=%2F%28%3F-i%29%5CbMY_SETTING%5Cb%2F+-org%3Aemscripten-core+-path%3Aemcc.*+-path%3Asettings.*+-path%3Asettings_reference.*&type=code
395+ [ test_suite ] : https://emscripten.org/docs/getting_started/test-suite.html
0 commit comments