@w-lfpup/jackrabbit 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/build_and_test.yml +18 -0
- package/.prettierignore +3 -0
- package/.prettierrc +5 -0
- package/LICENSE +29 -0
- package/README.md +33 -0
- package/cli/dist/cli.d.ts +3 -0
- package/cli/dist/cli.js +8 -0
- package/cli/dist/cli_types.d.ts +7 -0
- package/cli/dist/cli_types.js +1 -0
- package/cli/dist/config.d.ts +5 -0
- package/cli/dist/config.js +27 -0
- package/cli/dist/importer.d.ts +7 -0
- package/cli/dist/importer.js +16 -0
- package/cli/dist/logger.d.ts +7 -0
- package/cli/dist/logger.js +88 -0
- package/cli/dist/mod.d.ts +6 -0
- package/cli/dist/mod.js +4 -0
- package/cli/package.json +8 -0
- package/cli/src/cli.ts +17 -0
- package/cli/src/cli_types.ts +9 -0
- package/cli/src/config.ts +36 -0
- package/cli/src/importer.ts +25 -0
- package/cli/src/logger.ts +126 -0
- package/cli/src/mod.ts +7 -0
- package/cli/tsconfig.json +7 -0
- package/cli/tsconfig.tsbuildinfo +1 -0
- package/core/dist/jackrabbit_types.d.ts +56 -0
- package/core/dist/jackrabbit_types.js +1 -0
- package/core/dist/mod.d.ts +2 -0
- package/core/dist/mod.js +1 -0
- package/core/dist/run_steps.d.ts +3 -0
- package/core/dist/run_steps.js +95 -0
- package/core/package.json +8 -0
- package/core/src/jackrabbit_types.ts +75 -0
- package/core/src/mod.ts +9 -0
- package/core/src/run_steps.ts +138 -0
- package/core/tsconfig.json +7 -0
- package/core/tsconfig.tsbuildinfo +1 -0
- package/examples/hello_world/goodbye_world.ts +15 -0
- package/examples/hello_world/hello_world.ts +9 -0
- package/examples/hello_world/mod.ts +4 -0
- package/examples/package.json +3 -0
- package/nodejs_cli/dist/mod.d.ts +2 -0
- package/nodejs_cli/dist/mod.js +20 -0
- package/nodejs_cli/package.json +8 -0
- package/nodejs_cli/src/mod.ts +25 -0
- package/nodejs_cli/tsconfig.json +7 -0
- package/nodejs_cli/tsconfig.tsbuildinfo +1 -0
- package/package.json +29 -0
- package/test_guide.md +114 -0
- package/tests/dist/mod.d.ts +9 -0
- package/tests/dist/mod.js +30 -0
- package/tests/dist/test_fail.test.d.ts +9 -0
- package/tests/dist/test_fail.test.js +23 -0
- package/tests/dist/test_logger.d.ts +7 -0
- package/tests/dist/test_logger.js +19 -0
- package/tests/dist/test_pass.test.d.ts +9 -0
- package/tests/dist/test_pass.test.js +23 -0
- package/tests/package.json +8 -0
- package/tests/src/mod.ts +39 -0
- package/tests/src/test_fail.test.ts +28 -0
- package/tests/src/test_logger.ts +28 -0
- package/tests/src/test_pass.test.ts +28 -0
- package/tests/tsconfig.json +7 -0
- package/tests/tsconfig.tsbuildinfo +1 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: Build and Test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["main"]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: ["main"]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build_and_test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v5
|
|
14
|
+
- uses: actions/setup-node@v4
|
|
15
|
+
- name: Install
|
|
16
|
+
run: npm ci
|
|
17
|
+
- name: Test
|
|
18
|
+
run: npm run test
|
package/.prettierignore
ADDED
package/.prettierrc
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021, Taylor Vann
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Jackrabbit-js
|
|
2
|
+
|
|
3
|
+
Write tests without dependencies (including jackrabbit itself).
|
|
4
|
+
|
|
5
|
+
## Tests
|
|
6
|
+
|
|
7
|
+
Read [this guide](./test_guide.md) to create jackrabbit tests.
|
|
8
|
+
|
|
9
|
+
## Nodejs
|
|
10
|
+
|
|
11
|
+
### Install
|
|
12
|
+
|
|
13
|
+
Install jackrabbit with npm.
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install --save-dev @w-lfpup/jackrabbit
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or Install jackrabbit directly from github.
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm install --save-dev https://github.com/w-lfpup/jackrabbit-js
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Run Test Collections
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npx jackrabbit --file ./path/to/test/collection.ts
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
`Jackrabbit-js` is released under the BSD 3-Clause License.
|
package/cli/dist/cli.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { startRun } from "../../core/dist/mod.js";
|
|
2
|
+
import { Logger } from "./logger.js";
|
|
3
|
+
export async function run(config, importer, logger = new Logger()) {
|
|
4
|
+
for (const file of config.files) {
|
|
5
|
+
const testModules = await importer.load(file);
|
|
6
|
+
await startRun(logger, testModules);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const reactions = {
|
|
2
|
+
"--file": fileConfig,
|
|
3
|
+
"-f": fileConfig,
|
|
4
|
+
};
|
|
5
|
+
function fileConfig(config, file) {
|
|
6
|
+
if (file === undefined)
|
|
7
|
+
return;
|
|
8
|
+
config.files.push(file);
|
|
9
|
+
}
|
|
10
|
+
function iterateArgs(config, args) {
|
|
11
|
+
let index = 0;
|
|
12
|
+
while (index < args.length) {
|
|
13
|
+
const flag = args[index];
|
|
14
|
+
const reaction = reactions[flag];
|
|
15
|
+
if (reaction === undefined) {
|
|
16
|
+
throw new Error(`unrecognized argument: ${flag}`);
|
|
17
|
+
}
|
|
18
|
+
reaction(config, args[index + 1]);
|
|
19
|
+
index += 2;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export class Config {
|
|
23
|
+
files = [];
|
|
24
|
+
constructor(args) {
|
|
25
|
+
iterateArgs(this, args);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export class Importer {
|
|
2
|
+
#cwd;
|
|
3
|
+
constructor(cwd) {
|
|
4
|
+
this.#cwd = cwd;
|
|
5
|
+
}
|
|
6
|
+
async load(uri) {
|
|
7
|
+
let uri_updated = uri;
|
|
8
|
+
let absolute = uri.startsWith("/");
|
|
9
|
+
if (!absolute) {
|
|
10
|
+
uri_updated = this.#cwd + "/" + uri;
|
|
11
|
+
}
|
|
12
|
+
const { testModules } = await import(uri_updated);
|
|
13
|
+
// verify here
|
|
14
|
+
return testModules;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LoggerAction, LoggerInterface, TestModule } from "../../core/dist/mod.js";
|
|
2
|
+
export declare class Logger implements LoggerInterface {
|
|
3
|
+
#private;
|
|
4
|
+
get failed(): boolean;
|
|
5
|
+
get cancelled(): boolean;
|
|
6
|
+
log(testModules: TestModule[], action: LoggerAction): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export class Logger {
|
|
2
|
+
#assertions = new Map();
|
|
3
|
+
#data = {
|
|
4
|
+
cancelled: false,
|
|
5
|
+
failed: false,
|
|
6
|
+
startTime: -1,
|
|
7
|
+
testTime: 0,
|
|
8
|
+
};
|
|
9
|
+
get failed() {
|
|
10
|
+
return this.#data.failed;
|
|
11
|
+
}
|
|
12
|
+
get cancelled() {
|
|
13
|
+
return this.#data.cancelled;
|
|
14
|
+
}
|
|
15
|
+
log(testModules, action) {
|
|
16
|
+
if ("start_run" === action.type) {
|
|
17
|
+
this.#data.startTime = action.time;
|
|
18
|
+
}
|
|
19
|
+
if ("cancel_run" === action.type) {
|
|
20
|
+
this.#data.cancelled = true;
|
|
21
|
+
logAssertions(testModules, this.#assertions);
|
|
22
|
+
logResults(this.#data, action.time);
|
|
23
|
+
}
|
|
24
|
+
// add to fails
|
|
25
|
+
if ("end_test" === action.type && action?.assertions) {
|
|
26
|
+
if (Array.isArray(action.assertions) && action.assertions.length === 0)
|
|
27
|
+
return;
|
|
28
|
+
this.#data.testTime += action.endTime - action.startTime;
|
|
29
|
+
this.#data.failed = true;
|
|
30
|
+
let assertions = this.#assertions.get(action.moduleId);
|
|
31
|
+
if (assertions) {
|
|
32
|
+
assertions.set(action.testId, action);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this.#assertions.set(action.moduleId, new Map([[action.testId, action]]));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if ("end_run" === action.type) {
|
|
39
|
+
logAssertions(testModules, this.#assertions);
|
|
40
|
+
logResults(this.#data, action.time);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function logAssertions(testModules, fails) {
|
|
45
|
+
for (let [moduleID, module] of testModules.entries()) {
|
|
46
|
+
let failedTests = fails.get(moduleID);
|
|
47
|
+
if (undefined === failedTests)
|
|
48
|
+
continue;
|
|
49
|
+
const { tests, options } = module;
|
|
50
|
+
console.log(`${options?.title ?? `module index: ${moduleID}`}`);
|
|
51
|
+
let numFailedTests = fails.get(moduleID)?.size ?? 0;
|
|
52
|
+
console.log(`${numFailedTests}/${tests.length} tests failed`);
|
|
53
|
+
for (let [index, test] of tests.entries()) {
|
|
54
|
+
let action = failedTests.get(index);
|
|
55
|
+
if (!action || action.type !== "end_test")
|
|
56
|
+
continue;
|
|
57
|
+
console.log(`\t${test.name}\n\t\t${action.assertions}`);
|
|
58
|
+
}
|
|
59
|
+
console.log("\n");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function logResults(data, time) {
|
|
63
|
+
let status_with_color = data.failed
|
|
64
|
+
? yellow("\u{2717} failed")
|
|
65
|
+
: blue("\u{2714} passed");
|
|
66
|
+
if (data.cancelled) {
|
|
67
|
+
status_with_color = gray("\u{2717} cancelled");
|
|
68
|
+
}
|
|
69
|
+
const overhead = time - data.startTime;
|
|
70
|
+
console.log(`Results:
|
|
71
|
+
${status_with_color}
|
|
72
|
+
duration: ${data.testTime.toFixed(4)} mS
|
|
73
|
+
overhead: ${overhead.toFixed(4)} mS`);
|
|
74
|
+
}
|
|
75
|
+
// 39 - default foreground color
|
|
76
|
+
// 49 - default background color
|
|
77
|
+
function blue(text) {
|
|
78
|
+
return `\x1b[44m\x1b[97m${text}\x1b[0m`;
|
|
79
|
+
}
|
|
80
|
+
function yellow(text) {
|
|
81
|
+
return `\x1b[43m\x1b[97m${text}\x1b[0m`;
|
|
82
|
+
}
|
|
83
|
+
function gray(text) {
|
|
84
|
+
return `\x1b[100m\x1b[97m${text}\x1b[0m`;
|
|
85
|
+
}
|
|
86
|
+
function logTestModule(moduleID, title) {
|
|
87
|
+
console.log(`module: ${title ?? `module index: ${moduleID}`}`);
|
|
88
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { ConfigInterface } from "./cli_types.ts";
|
|
2
|
+
export type { ImporterInterface } from "./cli_types.ts";
|
|
3
|
+
export { Config } from "./config.js";
|
|
4
|
+
export { Importer } from "./importer.js";
|
|
5
|
+
export { Logger } from "./logger.js";
|
|
6
|
+
export { run } from "./cli.js";
|
package/cli/dist/mod.js
ADDED
package/cli/package.json
ADDED
package/cli/src/cli.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ConfigInterface, ImporterInterface } from "./cli_types.ts";
|
|
2
|
+
import type { LoggerInterface } from "../../core/dist/mod.ts";
|
|
3
|
+
|
|
4
|
+
import { startRun } from "../../core/dist/mod.js";
|
|
5
|
+
import { Logger } from "./logger.js";
|
|
6
|
+
|
|
7
|
+
export async function run(
|
|
8
|
+
config: ConfigInterface,
|
|
9
|
+
importer: ImporterInterface,
|
|
10
|
+
logger: LoggerInterface = new Logger(),
|
|
11
|
+
) {
|
|
12
|
+
for (const file of config.files) {
|
|
13
|
+
const testModules = await importer.load(file);
|
|
14
|
+
|
|
15
|
+
await startRun(logger, testModules);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ConfigInterface } from "./cli_types.ts";
|
|
2
|
+
|
|
3
|
+
type Reaction = (config: ConfigInterface, value?: string) => void;
|
|
4
|
+
type Reactions = Record<string, Reaction>;
|
|
5
|
+
|
|
6
|
+
const reactions: Reactions = {
|
|
7
|
+
"--file": fileConfig,
|
|
8
|
+
"-f": fileConfig,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function fileConfig(config: ConfigInterface, file?: string) {
|
|
12
|
+
if (file === undefined) return;
|
|
13
|
+
config.files.push(file);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function iterateArgs(config: ConfigInterface, args: string[]) {
|
|
17
|
+
let index = 0;
|
|
18
|
+
while (index < args.length) {
|
|
19
|
+
const flag = args[index];
|
|
20
|
+
const reaction = reactions[flag];
|
|
21
|
+
if (reaction === undefined) {
|
|
22
|
+
throw new Error(`unrecognized argument: ${flag}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
reaction(config, args[index + 1]);
|
|
26
|
+
index += 2;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class Config implements ConfigInterface {
|
|
31
|
+
files: string[] = [];
|
|
32
|
+
|
|
33
|
+
constructor(args: string[]) {
|
|
34
|
+
iterateArgs(this, args);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TestModule } from "../../core/dist/mod.ts";
|
|
2
|
+
import type { ImporterInterface } from "./cli_types.ts";
|
|
3
|
+
|
|
4
|
+
export class Importer implements ImporterInterface {
|
|
5
|
+
#cwd: string;
|
|
6
|
+
|
|
7
|
+
constructor(cwd: string) {
|
|
8
|
+
this.#cwd = cwd;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async load(uri: string): Promise<TestModule[]> {
|
|
12
|
+
let uri_updated = uri;
|
|
13
|
+
|
|
14
|
+
let absolute = uri.startsWith("/");
|
|
15
|
+
if (!absolute) {
|
|
16
|
+
uri_updated = this.#cwd + "/" + uri;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const { testModules } = await import(uri_updated);
|
|
20
|
+
|
|
21
|
+
// verify here
|
|
22
|
+
|
|
23
|
+
return testModules;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
LoggerAction,
|
|
3
|
+
LoggerInterface,
|
|
4
|
+
TestModule,
|
|
5
|
+
} from "../../core/dist/mod.js";
|
|
6
|
+
|
|
7
|
+
interface LoggerData {
|
|
8
|
+
cancelled: boolean;
|
|
9
|
+
failed: boolean;
|
|
10
|
+
startTime: number;
|
|
11
|
+
testTime: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class Logger implements LoggerInterface {
|
|
15
|
+
#assertions: Map<number, Map<number, LoggerAction>> = new Map();
|
|
16
|
+
#data: LoggerData = {
|
|
17
|
+
cancelled: false,
|
|
18
|
+
failed: false,
|
|
19
|
+
startTime: -1,
|
|
20
|
+
testTime: 0,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
get failed() {
|
|
24
|
+
return this.#data.failed;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get cancelled() {
|
|
28
|
+
return this.#data.cancelled;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
log(testModules: TestModule[], action: LoggerAction) {
|
|
32
|
+
if ("start_run" === action.type) {
|
|
33
|
+
this.#data.startTime = action.time;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if ("cancel_run" === action.type) {
|
|
37
|
+
this.#data.cancelled = true;
|
|
38
|
+
logAssertions(testModules, this.#assertions);
|
|
39
|
+
logResults(this.#data, action.time);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// add to fails
|
|
43
|
+
if ("end_test" === action.type && action?.assertions) {
|
|
44
|
+
if (Array.isArray(action.assertions) && action.assertions.length === 0)
|
|
45
|
+
return;
|
|
46
|
+
|
|
47
|
+
this.#data.testTime += action.endTime - action.startTime;
|
|
48
|
+
this.#data.failed = true;
|
|
49
|
+
|
|
50
|
+
let assertions = this.#assertions.get(action.moduleId);
|
|
51
|
+
if (assertions) {
|
|
52
|
+
assertions.set(action.testId, action);
|
|
53
|
+
} else {
|
|
54
|
+
this.#assertions.set(
|
|
55
|
+
action.moduleId,
|
|
56
|
+
new Map([[action.testId, action]]),
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if ("end_run" === action.type) {
|
|
62
|
+
logAssertions(testModules, this.#assertions);
|
|
63
|
+
logResults(this.#data, action.time);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function logAssertions(
|
|
69
|
+
testModules: TestModule[],
|
|
70
|
+
fails: Map<number, Map<number, LoggerAction>>,
|
|
71
|
+
) {
|
|
72
|
+
for (let [moduleID, module] of testModules.entries()) {
|
|
73
|
+
let failedTests = fails.get(moduleID);
|
|
74
|
+
if (undefined === failedTests) continue;
|
|
75
|
+
|
|
76
|
+
const { tests, options } = module;
|
|
77
|
+
|
|
78
|
+
console.log(`${options?.title ?? `module index: ${moduleID}`}`);
|
|
79
|
+
|
|
80
|
+
let numFailedTests = fails.get(moduleID)?.size ?? 0;
|
|
81
|
+
console.log(`${numFailedTests}/${tests.length} tests failed`);
|
|
82
|
+
|
|
83
|
+
for (let [index, test] of tests.entries()) {
|
|
84
|
+
let action = failedTests.get(index);
|
|
85
|
+
if (!action || action.type !== "end_test") continue;
|
|
86
|
+
|
|
87
|
+
console.log(`\t${test.name}\n\t\t${action.assertions}`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
console.log("\n");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function logResults(data: LoggerData, time: number) {
|
|
95
|
+
let status_with_color = data.failed
|
|
96
|
+
? yellow("\u{2717} failed")
|
|
97
|
+
: blue("\u{2714} passed");
|
|
98
|
+
|
|
99
|
+
if (data.cancelled) {
|
|
100
|
+
status_with_color = gray("\u{2717} cancelled");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const overhead = time - data.startTime;
|
|
104
|
+
console.log(`Results:
|
|
105
|
+
${status_with_color}
|
|
106
|
+
duration: ${data.testTime.toFixed(4)} mS
|
|
107
|
+
overhead: ${overhead.toFixed(4)} mS`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// 39 - default foreground color
|
|
111
|
+
// 49 - default background color
|
|
112
|
+
function blue(text: string) {
|
|
113
|
+
return `\x1b[44m\x1b[97m${text}\x1b[0m`;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function yellow(text: string) {
|
|
117
|
+
return `\x1b[43m\x1b[97m${text}\x1b[0m`;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function gray(text: string) {
|
|
121
|
+
return `\x1b[100m\x1b[97m${text}\x1b[0m`;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function logTestModule(moduleID: number, title?: string) {
|
|
125
|
+
console.log(`module: ${title ?? `module index: ${moduleID}`}`);
|
|
126
|
+
}
|
package/cli/src/mod.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { ConfigInterface } from "./cli_types.ts";
|
|
2
|
+
export type { ImporterInterface } from "./cli_types.ts";
|
|
3
|
+
|
|
4
|
+
export { Config } from "./config.js";
|
|
5
|
+
export { Importer } from "./importer.js";
|
|
6
|
+
export { Logger } from "./logger.js";
|
|
7
|
+
export { run } from "./cli.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["./src/cli.ts","./src/cli_types.ts","./src/config.ts","./src/importer.ts","./src/logger.ts","./src/mod.ts"],"version":"5.9.3"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
interface Stringable {
|
|
2
|
+
toString: Object["toString"];
|
|
3
|
+
}
|
|
4
|
+
export type Assertions = Stringable | Stringable[] | undefined;
|
|
5
|
+
type SyncTest = () => Assertions;
|
|
6
|
+
type AsyncTest = () => Promise<Assertions>;
|
|
7
|
+
export type Test = SyncTest | AsyncTest;
|
|
8
|
+
export interface Options {
|
|
9
|
+
title?: string;
|
|
10
|
+
runAsynchronously?: boolean;
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface TestModule {
|
|
14
|
+
tests: Test[];
|
|
15
|
+
options: Options;
|
|
16
|
+
}
|
|
17
|
+
interface StartRun {
|
|
18
|
+
type: "start_run";
|
|
19
|
+
time: number;
|
|
20
|
+
}
|
|
21
|
+
interface EndRun {
|
|
22
|
+
type: "end_run";
|
|
23
|
+
time: number;
|
|
24
|
+
}
|
|
25
|
+
interface CancelRun {
|
|
26
|
+
type: "cancel_run";
|
|
27
|
+
time: number;
|
|
28
|
+
}
|
|
29
|
+
interface StartModule {
|
|
30
|
+
type: "start_module";
|
|
31
|
+
moduleId: number;
|
|
32
|
+
}
|
|
33
|
+
interface EndModule {
|
|
34
|
+
type: "end_module";
|
|
35
|
+
moduleId: number;
|
|
36
|
+
}
|
|
37
|
+
interface StartTest {
|
|
38
|
+
type: "start_test";
|
|
39
|
+
testId: number;
|
|
40
|
+
moduleId: number;
|
|
41
|
+
}
|
|
42
|
+
interface EndTest {
|
|
43
|
+
type: "end_test";
|
|
44
|
+
testId: number;
|
|
45
|
+
moduleId: number;
|
|
46
|
+
startTime: number;
|
|
47
|
+
endTime: number;
|
|
48
|
+
assertions: Assertions;
|
|
49
|
+
}
|
|
50
|
+
export type LoggerAction = StartRun | EndRun | CancelRun | StartModule | EndModule | StartTest | EndTest;
|
|
51
|
+
export interface LoggerInterface {
|
|
52
|
+
readonly failed: boolean;
|
|
53
|
+
readonly cancelled: boolean;
|
|
54
|
+
log(testModules: TestModule[], action: LoggerAction): void;
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/core/dist/mod.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { startRun, cancelRun } from "./run_steps.js";
|