Skip to content

Commit

Permalink
Cleanup package.json (emscripten-core#7536)
Browse files Browse the repository at this point in the history
This is part of a larger change to remove the two checked in
node_modules trees that we have in the emscripten and rely instead
on developers running `npm install` after cloning/syncing.

- Switch ws dependency to devDevpendency since its only used
  for testing
- Add private:true since we are not (yet) publishing emscripten as
  a node package.
- Remove running on npm install from sockets test;  We can rely on
  developers doing this before running the tests.
- Don't try to run npm install in test_sockets.py.  Assume that
  developers to used "git clone" will also run npm install
  • Loading branch information
sbc100 authored Dec 7, 2018
1 parent 32932f8 commit b011232
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 14 deletions.
42 changes: 42 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "emscripten",
"version": "1.13.0",
"dependencies": {
"private": true,
"devDependencies": {
"ws": "~0.4.28"
}
}
4 changes: 2 additions & 2 deletions tests/sockets/test_sockets_echo_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ int main() {
sprintf(buffer, "%s:%u", inet_ntoa(adr_inet.sin_addr), (unsigned)ntohs(adr_inet.sin_port));
// TODO: This is not the correct result: We should have a auto-bound address
char *correct = "0.0.0.0:0";
printf("got (expected) socket: %s (%s), size %d (%d)\n", buffer, correct, strlen(buffer), strlen(correct));
printf("got (expected) socket: %s (%s), size %lu (%lu)\n", buffer, correct, strlen(buffer), strlen(correct));
assert(strlen(buffer) == strlen(correct));
assert(strcmp(buffer, correct) == 0);
}
Expand All @@ -228,7 +228,7 @@ int main() {
sprintf(buffer, "%s:%u", inet_ntoa(adr_inet.sin_addr), (unsigned)ntohs(adr_inet.sin_port));
char correct[1000];
sprintf(correct, "127.0.0.1:%u", SOCKK);
printf("got (expected) socket: %s (%s), size %d (%d)\n", buffer, correct, strlen(buffer), strlen(correct));
printf("got (expected) socket: %s (%s), size %lu (%lu)\n", buffer, correct, strlen(buffer), strlen(correct));
assert(strlen(buffer) == strlen(correct));
assert(strcmp(buffer, correct) == 0);
}
Expand Down
14 changes: 5 additions & 9 deletions tests/test_sockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from tools import shared
from tools.shared import PYTHON, EMCC, NODE_JS, path_from_root, Popen, PIPE, WINDOWS, run_process, run_js, JS_ENGINES, CLANG_CC

node_ws_module_installed = False
npm_checked = False

NPM = os.path.join(os.path.dirname(NODE_JS[0]), 'npm.cmd' if WINDOWS else 'npm')

Expand Down Expand Up @@ -102,15 +102,11 @@ def __init__(self, filename, args, listen_port):
def __enter__(self):
# assuming this is only used for WebSocket tests at the moment, validate that
# the ws module is installed
child = run_process(NODE_JS + ['-e', 'require("ws");'], check=False)
global node_ws_module_installed
# Attempt to automatically install ws module for Node.js.
if child.returncode != 0 and not node_ws_module_installed:
node_ws_module_installed = True
run_process([NPM, 'install', path_from_root('tests', 'sockets', 'ws')], cwd=os.path.dirname(EMCC))
# Did installation succeed?
global npm_checked
if not npm_checked:
child = run_process(NODE_JS + ['-e', 'require("ws");'], check=False)
assert child.returncode == 0, 'ws module for Node.js not installed, and automatic installation failed! Please run \'npm install\' from %s' % shared.__rootpath__
assert child.returncode == 0, '"ws" node module not found. you may need to run npm install'
npm_checked = True

# compile the server
proc = run_process([PYTHON, EMCC, path_from_root('tests', self.filename), '-o', 'server.js', '-DSOCKK=%d' % self.listen_port] + self.args)
Expand Down

0 comments on commit b011232

Please sign in to comment.