Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/parseTools.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
runInMacroContext,
pushCurrentFile,
popCurrentFile,
localFile,
warn,
srcDir,
} from './utility.mjs';
Expand Down Expand Up @@ -921,7 +922,7 @@ function makeModuleReceiveWithVar(localName, moduleName, defaultValue) {
function makeRemovedFSAssert(fsName) {
assert(ASSERTIONS);
const lower = fsName.toLowerCase();
if (JS_LIBRARIES.includes(path.resolve(path.join('lib', `lib${lower}.js`)))) return '';
if (JS_LIBRARIES.includes(localFile(path.join('lib', `lib${lower}.js`)))) return '';
return `var ${fsName} = '${fsName} is no longer included by default; build with -l${lower}.js';`;
}

Expand Down
15 changes: 15 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -16234,3 +16234,18 @@ def test_libcxx_errors(self):
# and in debug mode at least we expect to see the error message from libc++
expected = 'system_error was thrown in -fno-exceptions mode with error 6 and message "thread constructor failed"'
self.do_runf('main.cpp', expected, assert_returncode=NON_ZERO)

def test_parsetools_make_removed_fs_assert(self):
"""
This tests that parseTools.mjs `makeRemovedFSAssert()` works as intended,
if it creates a stub when a builtin library isn't included, but not when
it is.
"""

removed_fs_assert_content = "IDBFS is no longer included by default"

self.emcc(test_file('hello_world.c'), output_filename='hello_world.js')
self.assertContained(removed_fs_assert_content, read_file('hello_world.js'))

self.emcc(test_file('hello_world.c'), ['-lidbfs.js'], output_filename='hello_world.js')
self.assertNotContained(removed_fs_assert_content, read_file('hello_world.js'))