Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 3d3f61c

Browse files
[[ cpptest ]] Allow emscripten tests to write to a log file
1 parent 463801f commit 3d3f61c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

libcpptest/src/gtest_main.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,23 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
1717
#include "gtest/gtest.h"
1818
#include "MCTapListener.h"
1919

20+
#ifdef __EMSCRIPTEN__
21+
#include <emscripten.h>
22+
#endif
23+
2024
int main(int argc, char **argv) {
25+
26+
#ifdef __EMSCRIPTEN__
27+
// Mount and cd into a nodefs filesystem so that emscripten tests
28+
// have the same access to the filesystem as native tests. In
29+
// particular, they can write to a log file.
30+
EM_ASM(
31+
FS.mkdir('root');
32+
FS.mount(NODEFS, { root: '/' }, 'root');
33+
FS.chdir('root/' + process.cwd());
34+
);
35+
#endif
36+
2137
testing::InitGoogleTest(&argc, argv);
2238

2339
for (int i = 0; i < argc; i++) {

0 commit comments

Comments
 (0)