Skip to content

Commit 878cf85

Browse files
author
Andy
authored
Merge pull request #9985 from Microsoft/fix_runtests_browser
Always use a hardcoded port
2 parents 013744b + 20ffb5f commit 878cf85

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

Gulpfile.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
5959
browser: process.env.browser || process.env.b || "IE",
6060
tests: process.env.test || process.env.tests || process.env.t,
6161
light: process.env.light || false,
62-
port: process.env.port || process.env.p || "8888",
6362
reporter: process.env.reporter || process.env.r,
6463
lint: process.env.lint || true,
6564
files: process.env.f || process.env.file || process.env.files || "",
@@ -766,7 +765,7 @@ function writeTestConfigFile(tests: string, light: boolean, taskConfigsFolder?:
766765
}
767766

768767

769-
gulp.task("runtests-browser", "Runs the tests using the built run.js file like 'gulp runtests'. Syntax is gulp runtests-browser. Additional optional parameters --tests=[regex], --port=, --browser=[chrome|IE]", ["browserify", nodeServerOutFile], (done) => {
768+
gulp.task("runtests-browser", "Runs the tests using the built run.js file like 'gulp runtests'. Syntax is gulp runtests-browser. Additional optional parameters --tests=[regex], --browser=[chrome|IE]", ["browserify", nodeServerOutFile], (done) => {
770769
cleanTestDirs((err) => {
771770
if (err) { console.error(err); done(err); process.exit(1); }
772771
host = "node";
@@ -781,9 +780,6 @@ gulp.task("runtests-browser", "Runs the tests using the built run.js file like '
781780
}
782781

783782
const args = [nodeServerOutFile];
784-
if (cmdLineOptions["port"]) {
785-
args.push(cmdLineOptions["port"]);
786-
}
787783
if (cmdLineOptions["browser"]) {
788784
args.push(cmdLineOptions["browser"]);
789785
}

Jakefile.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -847,11 +847,10 @@ task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function()
847847
exec(cmd);
848848
}, {async: true});
849849

850-
desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is jake runtests-browser. Additional optional parameters tests=[regex], port=, browser=[chrome|IE]");
850+
desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is jake runtests-browser. Additional optional parameters tests=[regex], browser=[chrome|IE]");
851851
task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFileInBrowserTest], function() {
852852
cleanTestDirs();
853853
host = "node";
854-
port = process.env.port || process.env.p || '8888';
855854
browser = process.env.browser || process.env.b || "IE";
856855
tests = process.env.test || process.env.tests || process.env.t;
857856
var light = process.env.light || false;
@@ -864,7 +863,7 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFi
864863
}
865864

866865
tests = tests ? tests : '';
867-
var cmd = host + " tests/webTestServer.js " + port + " " + browser + " " + JSON.stringify(tests);
866+
var cmd = host + " tests/webTestServer.js " + browser + " " + JSON.stringify(tests);
868867
console.log(cmd);
869868
exec(cmd);
870869
}, {async: true});

tests/webTestServer.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,34 @@ import os = require("os");
1010
/// Command line processing ///
1111

1212
if (process.argv[2] == '--help') {
13-
console.log('Runs a node server on port 8888 by default, looking for tests folder in the current directory\n');
14-
console.log('Syntax: node nodeServer.js [port] [typescriptEnlistmentDirectory] [tests] [--browser] [--verbose]\n');
15-
console.log('Examples: \n\tnode nodeServer.js 8888 .');
13+
console.log('Runs a node server on port 8888, looking for tests folder in the current directory\n');
14+
console.log('Syntax: node nodeServer.js [typescriptEnlistmentDirectory] [tests] [--browser] [--verbose]\n');
15+
console.log('Examples: \n\tnode nodeServer.js .');
1616
console.log('\tnode nodeServer.js 3000 D:/src/typescript/public --verbose IE');
1717
}
1818

1919
function switchToForwardSlashes(path: string) {
2020
return path.replace(/\\/g, "/").replace(/\/\//g, '/');
2121
}
2222

23-
var defaultPort = 8888;
24-
var port = process.argv[2] || defaultPort;
23+
var port = 8888; // harness.ts and webTestResults.html depend on this exact port number.
2524
var rootDir = switchToForwardSlashes(__dirname + '/../');
2625

2726
var browser: string;
28-
if (process.argv[3]) {
29-
browser = process.argv[3];
27+
if (process.argv[2]) {
28+
browser = process.argv[2];
3029
if (browser !== 'chrome' && browser !== 'IE') {
3130
console.log('Invalid command line arguments. Got ' + browser + ' but expected chrome, IE or nothing.');
3231
}
3332
}
3433

35-
var grep = process.argv[4];
34+
var grep = process.argv[3];
3635

3736
var verbose = false;
38-
if (process.argv[5] == '--verbose') {
37+
if (process.argv[4] == '--verbose') {
3938
verbose = true;
40-
} else if (process.argv[5] && process.argv[5] !== '--verbose') {
41-
console.log('Invalid command line arguments. Got ' + process.argv[5] + ' but expected --verbose or nothing.');
39+
} else if (process.argv[4] && process.argv[4] !== '--verbose') {
40+
console.log('Invalid command line arguments. Got ' + process.argv[4] + ' but expected --verbose or nothing.');
4241
}
4342

4443
/// Utils ///
@@ -267,7 +266,7 @@ http.createServer(function (req: http.ServerRequest, res: http.ServerResponse) {
267266
var reqPath = path.join(process.cwd(), uri);
268267
var operation = getRequestOperation(req, reqPath);
269268
handleRequestOperation(req, res, operation, reqPath);
270-
}).listen(8888);
269+
}).listen(port);
271270

272271
var browserPath: string;
273272
if ((browser && browser === 'chrome')) {

0 commit comments

Comments
 (0)