Skip to content

Commit

Permalink
feat: new ./bin/testplane (#892)
Browse files Browse the repository at this point in the history
* feat: new ./bin/testplane

* ci: add rebranding branch
  • Loading branch information
miripiruni authored Apr 1, 2024
1 parent 4523c88 commit e6c9490
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Node.js CI

on:
push:
branches: [master]
branches: [master, rebranding]
pull_request:
branches: [master]
branches: [master, rebranding]

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion bin/hermione
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node
'use strict';

var cli = require('../build/src/cli').run();
var cli = require('../build/src/cli').run({ cliName: 'hermione' });
4 changes: 4 additions & 0 deletions bin/testplane
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node
'use strict';

var cli = require('../build/src/cli').run();
3 changes: 2 additions & 1 deletion package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"test"
],
"bin": {
"hermione": "./bin/hermione"
"hermione": "./bin/hermione",
"testplane": "./bin/testplane"
},
"license": "MIT",
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ process.on("unhandledRejection", (reason, p) => {
}
});

exports.run = () => {
const program = new Command();
exports.run = (opts = {}) => {
const program = new Command(opts.cliName || "testplane");

program.version(pkg.version).allowUnknownOption().option("-c, --config <path>", "path to configuration file");

const configPath = preparseOption(program, "config");
hermione = Hermione.create(configPath);

program
.on("--help", () => logger.log(info.configOverriding))
.on("--help", () => logger.log(info.configOverriding(opts)))
.option("-b, --browser <browser>", "run tests only in specified browser", collect)
.option("-s, --set <set>", "run tests only in the specified set", collect)
.option("-r, --require <module>", "require module", collect)
Expand Down
20 changes: 12 additions & 8 deletions src/cli/info.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
"use strict";

exports.configOverriding = ` Overriding config
exports.configOverriding = (opts = {}) => {
const cliName = opts.cliName || "testplane";

return ` Overriding config
To override any config option use full option path converted to --kebab-case
Examples:
hermione --system-debug true
hermione --base-url http://example.com
hermione --browsers-firefox-sessions-per-browser 10
${cliName} --system-debug true
${cliName} --base-url http://example.com
${cliName} --browsers-firefox-sessions-per-browser 10
You can also use environment variables converted to snake_case with
hermione_ prefix
${cliName}_ prefix
Examples:
hermione_system_debug=true hermione
hermione_base_url=http://example.com hermione
hermione_browsers_firefox_sessions_per_browser=10 hermione
${cliName}_system_debug=true ${cliName}
${cliName}_base_url=http://example.com ${cliName}
${cliName}_browsers_firefox_sessions_per_browser=10 ${cliName}
If both cli option and environment variable are used, cli option takes precedence
`;
};
24 changes: 20 additions & 4 deletions test/src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,27 @@ describe("cli", () => {

afterEach(() => sandbox.restore());

it('should show information about config overriding on "--help"', async () => {
await run_("--help");
describe("config overriding", () => {
it('should show information about config overriding on "--help"', async () => {
await run_("--help");

assert.calledOnce(logger.log);
assert.calledWith(logger.log, info.configOverriding);
assert.calledOnce(logger.log);
assert.calledWith(logger.log, info.configOverriding());
});

it("should show information about testplane by default", async () => {
const defaultResult = info.configOverriding();

assert.isTrue(defaultResult.includes("testplane"));
assert.isFalse(defaultResult.includes("hermione"));
});

it("should show information about hermione", async () => {
const result = info.configOverriding({ cliName: "hermione" });

assert.isTrue(result.includes("hermione"));
assert.isFalse(result.includes("testplane"));
});
});

it("should create Hermione instance", async () => {
Expand Down

0 comments on commit e6c9490

Please sign in to comment.