Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: allow single JS file for --link-module #28443

Closed
wants to merge 3 commits into from
Closed
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
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ jstest: build-addons build-js-native-api-tests build-node-api-tests ## Runs addo
$(CI_JS_SUITES) \
$(CI_NATIVE_SUITES)

.PHONY: tooltest
tooltest:
@$(PYTHON) test/tools/test-js2c.py

.PHONY: coverage-run-js
coverage-run-js:
$(RM) -r out/$(BUILDTYPE)/.coverage
Expand All @@ -311,6 +315,7 @@ test: all ## Runs default tests, linters, and builds docs.
$(MAKE) -s build-node-api-tests
$(MAKE) -s cctest
$(MAKE) -s jstest
$(MAKE) -s tooltest

.PHONY: test-only
test-only: all ## For a quick test, does not run linter or build docs.
Expand All @@ -319,6 +324,7 @@ test-only: all ## For a quick test, does not run linter or build docs.
$(MAKE) build-node-api-tests
$(MAKE) cctest
$(MAKE) jstest
$(MAKE) tooltest

# Used by `make coverage-test`
test-cov: all
Expand Down
14 changes: 14 additions & 0 deletions test/tools/test-js2c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import unittest
import sys, os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),
'..', '..', 'tools')))
from js2c import NormalizeFileName

class Js2ctest(unittest.TestCase):
def testNormalizeFileName(self):
self.assertEqual(NormalizeFileName('dir/mod.js'), 'mod')
self.assertEqual(NormalizeFileName('deps/mod.js'), 'internal/deps/mod')
self.assertEqual(NormalizeFileName('mod.js'), 'mod')

if __name__ == '__main__':
unittest.main()
3 changes: 2 additions & 1 deletion tools/js2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ def NormalizeFileName(filename):
split = ['internal'] + split
else: # `lib/**/*.js` so drop the 'lib' part
split = split[1:]
filename = '/'.join(split)
if len(split):
filename = '/'.join(split)
return os.path.splitext(filename)[0]


Expand Down