diff --git a/Makefile b/Makefile index 1e4915a6d2ebed..b18facf08eba85 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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. @@ -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 diff --git a/test/tools/test-js2c.py b/test/tools/test-js2c.py new file mode 100644 index 00000000000000..204562117086e4 --- /dev/null +++ b/test/tools/test-js2c.py @@ -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() diff --git a/tools/js2c.py b/tools/js2c.py index 0189dd76291916..1346b2a87046d3 100755 --- a/tools/js2c.py +++ b/tools/js2c.py @@ -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]