Skip to content

Commit

Permalink
[wct-local] Added javaArgs to plugin options. (#3445)
Browse files Browse the repository at this point in the history
* Add support for selenium-java-args fixes https://github.com/Polymer/web-component-tester/issues/676
* Update package.json
* Update plugin.ts
* Update selenium.ts
* Update selenium-standalone.d.ts
* [wct-local] Added CHANGELOG item for javaArgs option.
  • Loading branch information
usergenic authored Jul 8, 2019
1 parent 0282ab0 commit 97bbc48
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/wct-local/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

<!-- ## Unreleased -->
## Unreleased
- Added `javaArgs` to plugin options.
<!-- Add unreleased changes here. -->

## [v2.1.4] - 2019-06-05
Expand Down
3 changes: 3 additions & 0 deletions packages/wct-local/custom_typings/selenium-standalone.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ declare module 'selenium-standalone' {
* child_process.spawn.
*/
seleniumArgs?: string[];

/** seleniumJavaArgs */
javaArgs?: string[];

/** set the javaPath manually, otherwise we use `which` */
javaPath?: string;
Expand Down
6 changes: 6 additions & 0 deletions packages/wct-local/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
"metavar": "ARG",
"list": true
},
"javaArgs": {
"help": "Add java args to selenium-java-args",
"full": "selenium-java-args",
"metavar": "ARG",
"list": true
},
"skipSeleniumInstall": {
"help": "Skip trying to install selenium.",
"full": "skip-selenium-install",
Expand Down
4 changes: 3 additions & 1 deletion packages/wct-local/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as selenium from './selenium';

interface PluginOptions {
seleniumArgs?: string[];
javaArgs?: string[];
skipSeleniumInstall?: boolean;
browsers: string[];
browserOptions?: {};
Expand All @@ -36,6 +37,7 @@ const plugin: wct.PluginInterface =
// to kick in if someone has specified browsers via another plugin.
const onConfigure = async () => {
pluginOptions.seleniumArgs = pluginOptions.seleniumArgs || [];
pluginOptions.javaArgs = pluginOptions.javaArgs || [];
pluginOptions.skipSeleniumInstall =
pluginOptions.skipSeleniumInstall || false;

Expand Down Expand Up @@ -90,7 +92,7 @@ const plugin: wct.PluginInterface =
if (pluginOptions.skipSeleniumInstall) {
start = selenium.startSeleniumServer;
}
const port = await start(wct, pluginOptions.seleniumArgs);
const port = await start(wct, pluginOptions.seleniumArgs, pluginOptions.javaArgs);
updatePort(eachCapabilities, port);
};
wct.hook('prepare', function(done: (err?: unknown) => void) {
Expand Down
11 changes: 6 additions & 5 deletions packages/wct-local/src/selenium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,27 @@ export async function checkSeleniumEnvironment(): Promise<void> {
}

export async function startSeleniumServer(
wct: wct.Context, args: string[]): Promise<number> {
wct: wct.Context, args: string[], javaArgs: string[]): Promise<number> {
wct.emit('log:info', 'Starting Selenium server for local browsers');
await checkSeleniumEnvironment();

const opts = {args: args, install: false};
const opts = {args: args, javaArgs: javaArgs, install: false};
return seleniumStart(wct, opts);
}

export async function installAndStartSeleniumServer(
wct: wct.Context, args: string[]): Promise<number> {
wct: wct.Context, args: string[], javaArgs: string[]): Promise<number> {
wct.emit(
'log:info', 'Installing and starting Selenium server for local browsers');
await checkSeleniumEnvironment();

const opts = {args: args, install: true};
const opts = {args: args, javaArgs: javaArgs, install: true};
return seleniumStart(wct, opts);
}

async function seleniumStart(
wct: wct.Context,
opts: {args: string[], install: boolean}): Promise<number> {
opts: {args: string[], javaArgs: string[], install: boolean}): Promise<number> {
const port = await promisify(freeport)();

// See below.
Expand All @@ -78,6 +78,7 @@ async function seleniumStart(

const config: selenium.StartOpts = SELENIUM_OVERRIDES || {};
config.seleniumArgs = ['-port', port.toString()].concat(opts.args);
config.javaArgs = opts.javaArgs || [];
// Bookkeeping once the process starts.
config.spawnCb = function(server: child_process.ChildProcess) {
// Make sure that we interrupt the selenium server ASAP.
Expand Down

0 comments on commit 97bbc48

Please sign in to comment.