Skip to content

Commit 4092aa7

Browse files
fuzzie360claude
andcommitted
test: Make BrowserStack project name configurable, add --dry-run
The dashboard groups builds by projectName, so it needs to be settable without editing the runner: --project=NAME or $BROWSERSTACK_PROJECT, defaulting to gpu.js as before. --dry-run prints the resolved W3C capabilities per target and exits without opening a session, which makes it possible to check what is actually being sent (project, build, tunnel binding, realMobile) without spending Automate minutes. The access key is masked in that output. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent a16aef3 commit 4092aa7

1 file changed

Lines changed: 30 additions & 3 deletions

File tree

‎test/browserstack/run.js‎

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@
1212
* --suite=smoke|qunit smoke (default) runs test/browserstack/smoke.html,
1313
* qunit runs the full test/all.html suite
1414
* --browsers=real-devices|desktop|all
15+
* --project=NAME BrowserStack project to group builds under
16+
* (default gpu.js, or $BROWSERSTACK_PROJECT)
1517
* --only=TEXT keep only targets whose name contains TEXT
1618
* --concurrency=N parallel sessions (default 5, the free-plan limit)
1719
* --timeout=SECONDS per-session budget (default 300)
1820
* --filter=TEXT QUnit filter, only meaningful with --suite=qunit
21+
* --dry-run print the resolved capabilities and exit without
22+
* opening any session
1923
*/
2024

2125
'use strict';
@@ -51,10 +55,12 @@ function parseArgs(argv) {
5155
const args = {
5256
suite: 'smoke',
5357
browsers: 'real-devices',
58+
project: process.env.BROWSERSTACK_PROJECT || 'gpu.js',
5459
only: '',
5560
concurrency: 5,
5661
timeout: 300,
57-
filter: ''
62+
filter: '',
63+
'dry-run': false
5864
};
5965
argv.forEach(arg => {
6066
const match = /^--([^=]+)=?(.*)$/.exec(arg);
@@ -63,6 +69,8 @@ function parseArgs(argv) {
6369
const value = match[2];
6470
if (key === 'concurrency' || key === 'timeout') {
6571
args[key] = parseInt(value, 10);
72+
} else if (key === 'dry-run') {
73+
args[key] = true;
6674
} else if (key in args) {
6775
args[key] = value;
6876
} else {
@@ -135,7 +143,7 @@ function buildCapabilities(target, context) {
135143
const source = target.capabilities;
136144
const caps = {};
137145
const bstack = {
138-
projectName: 'gpu.js',
146+
projectName: context.projectName,
139147
buildName: context.buildName,
140148
sessionName: target.name,
141149
local: 'true',
@@ -293,11 +301,30 @@ async function main() {
293301
console.log(`build: ${buildName}`);
294302
console.log(`targets: ${targets.length} (${args.browsers}), concurrency ${args.concurrency}\n`);
295303

304+
if (args['dry-run']) {
305+
targets.forEach(target => {
306+
const caps = buildCapabilities(target, {
307+
user, key, localIdentifier, buildName, projectName: args.project
308+
});
309+
// never print the access key, even locally
310+
const shown = JSON.parse(JSON.stringify(caps));
311+
shown['bstack:options'].accessKey = '***';
312+
console.log(`--- ${target.name}\n${JSON.stringify(shown, null, 2)}\n`);
313+
});
314+
server.close();
315+
return;
316+
}
317+
296318
console.log('starting BrowserStack Local tunnel...');
297319
const tunnel = await startTunnel(key, localIdentifier);
298320
console.log('tunnel up\n');
299321

300-
const context = { user, key, localIdentifier, buildName, url, suite: args.suite, timeout: args.timeout };
322+
const context = {
323+
user, key, localIdentifier, buildName, url,
324+
projectName: args.project,
325+
suite: args.suite,
326+
timeout: args.timeout
327+
};
301328
let results;
302329
try {
303330
results = await runPool(targets, args.concurrency, async target => {

0 commit comments

Comments
 (0)