Enable cli description to have free args title
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
import {defaultCliArgsParser} from "./src/CliArgsParser";
|
import {CliArgsParser, getDefaultCliDescription} from "./src/CliArgsParser";
|
||||||
import {getAdapter} from "./src/Adapter";
|
import {getAdapter} from "./src/Adapter";
|
||||||
import {directRunner} from "./src/KotlinTestRunner";
|
import {directRunner} from "./src/KotlinTestRunner";
|
||||||
|
|
||||||
const kotlin_test = require('kotlin-test');
|
const kotlin_test = require('kotlin-test');
|
||||||
|
|
||||||
const parser = defaultCliArgsParser;
|
const parser = new CliArgsParser(getDefaultCliDescription());
|
||||||
|
|
||||||
const processArgs = process.argv.slice(2);
|
const processArgs = process.argv.slice(2);
|
||||||
const untypedArgs = parser.parse(processArgs);
|
const untypedArgs = parser.parse(processArgs);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export type CliDescription = {
|
|||||||
args: {
|
args: {
|
||||||
[k: string]: CliArgDescription,
|
[k: string]: CliArgDescription,
|
||||||
},
|
},
|
||||||
freeArgsTitle: string
|
freeArgsTitle: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CliArgValues = {
|
export type CliArgValues = {
|
||||||
@@ -107,7 +107,7 @@ export class CliArgsParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.free.length == 0) {
|
if (description.freeArgsTitle && result.free.length == 0) {
|
||||||
this.badArgsExit(`At least one ${description.freeArgsTitle} should be provided`)
|
this.badArgsExit(`At least one ${description.freeArgsTitle} should be provided`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,40 +115,40 @@ export class CliArgsParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultCliDescription: CliDescription = {
|
export function getDefaultCliDescription(): CliDescription {
|
||||||
version: VERSION,
|
return {
|
||||||
bin: BIN,
|
version: VERSION,
|
||||||
description: DESCRIPTION,
|
bin: BIN,
|
||||||
usage: "[-t --tests] [-e --exclude] <module_name1>, <module_name2>, ..",
|
description: DESCRIPTION,
|
||||||
args: {
|
usage: "[-t --tests] [-e --exclude] <module_name1>, <module_name2>, ..",
|
||||||
include: {
|
args: {
|
||||||
keys: ['--tests', '--include'],
|
include: {
|
||||||
help: "Tests to include. Example: MySuite.test1,MySuite.MySubSuite.*,*unix*,!*windows*",
|
keys: ['--tests', '--include'],
|
||||||
default: "*"
|
help: "Tests to include. Example: MySuite.test1,MySuite.MySubSuite.*,*unix*,!*windows*",
|
||||||
|
default: "*"
|
||||||
|
|
||||||
|
},
|
||||||
|
exclude: {
|
||||||
|
keys: ['--exclude'],
|
||||||
|
help: "Tests to exclude. Example: MySuite.test1,MySuite.MySubSuite.*,*unix*"
|
||||||
|
},
|
||||||
|
ignoredTestSuites: {
|
||||||
|
keys: ['--ignoredTestSuites'],
|
||||||
|
help: "How to deal with ignored test suites",
|
||||||
|
single: true,
|
||||||
|
values: [
|
||||||
|
IgnoredTestSuitesReporting.skip,
|
||||||
|
IgnoredTestSuitesReporting.reportAsIgnoredTest,
|
||||||
|
IgnoredTestSuitesReporting.reportAllInnerTestsAsIgnored
|
||||||
|
],
|
||||||
|
valuesHelp: [
|
||||||
|
"don't report ignored test suites",
|
||||||
|
"useful to speedup large ignored test suites",
|
||||||
|
"will cause visiting all inner tests",
|
||||||
|
],
|
||||||
|
default: IgnoredTestSuitesReporting.reportAllInnerTestsAsIgnored
|
||||||
|
}
|
||||||
},
|
},
|
||||||
exclude: {
|
freeArgsTitle: "module_name"
|
||||||
keys: ['--exclude'],
|
};
|
||||||
help: "Tests to exclude. Example: MySuite.test1,MySuite.MySubSuite.*,*unix*"
|
}
|
||||||
},
|
|
||||||
ignoredTestSuites: {
|
|
||||||
keys: ['--ignoredTestSuites'],
|
|
||||||
help: "How to deal with ignored test suites",
|
|
||||||
single: true,
|
|
||||||
values: [
|
|
||||||
IgnoredTestSuitesReporting.skip,
|
|
||||||
IgnoredTestSuitesReporting.reportAsIgnoredTest,
|
|
||||||
IgnoredTestSuitesReporting.reportAllInnerTestsAsIgnored
|
|
||||||
],
|
|
||||||
valuesHelp: [
|
|
||||||
"don't report ignored test suites",
|
|
||||||
"useful to speedup large ignored test suites",
|
|
||||||
"will cause visiting all inner tests",
|
|
||||||
],
|
|
||||||
default: IgnoredTestSuitesReporting.reportAllInnerTestsAsIgnored
|
|
||||||
}
|
|
||||||
},
|
|
||||||
freeArgsTitle: "module_name"
|
|
||||||
};
|
|
||||||
|
|
||||||
export const defaultCliArgsParser: CliArgsParser = new CliArgsParser(defaultCliDescription);
|
|
||||||
|
|||||||
Reference in New Issue
Block a user