@travetto/test 5.0.0-rc.1 → 5.0.0-rc.2
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/README.md +5 -5
- package/package.json +7 -7
- package/src/assert/capture.ts +3 -0
- package/src/assert/check.ts +6 -5
- package/src/assert/util.ts +5 -5
- package/src/consumer/error.ts +1 -1
- package/src/consumer/registry.ts +1 -1
- package/src/consumer/types/cumulative.ts +1 -1
- package/src/consumer/types/tap-streamed.ts +1 -1
- package/src/consumer/types/tap.ts +2 -2
- package/src/decorator/suite.ts +2 -3
- package/src/decorator/test.ts +1 -1
- package/src/execute/console.ts +1 -1
- package/src/execute/executor.ts +4 -5
- package/src/execute/phase.ts +1 -1
- package/src/execute/promise.ts +1 -1
- package/src/execute/runner.ts +3 -3
- package/src/execute/util.ts +2 -2
- package/src/execute/watcher.ts +3 -3
- package/src/fixture.ts +7 -2
- package/src/model/suite.ts +1 -1
- package/src/model/test.ts +1 -1
- package/src/registry/suite.ts +16 -16
- package/src/trv.d.ts +1 -1
- package/src/worker/child.ts +2 -2
- package/src/worker/standard.ts +1 -2
- package/support/cli.test.ts +1 -1
- package/support/cli.test_child.ts +1 -1
- package/support/cli.test_count.ts +2 -3
- package/support/cli.test_direct.ts +1 -1
- package/support/cli.test_watch.ts +1 -1
- package/support/transformer.assert.ts +2 -2
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ This module provides unit testing functionality that integrates with the framewo
|
|
|
21
21
|
**Note**: All tests should be under the `test/.*` folders. The pattern for tests is defined as a regex and not standard globbing.
|
|
22
22
|
|
|
23
23
|
## Definition
|
|
24
|
-
A test suite is a collection of individual tests. All test suites are classes with the [@Suite](https://github.com/travetto/travetto/tree/main/module/test/src/decorator/suite.ts#
|
|
24
|
+
A test suite is a collection of individual tests. All test suites are classes with the [@Suite](https://github.com/travetto/travetto/tree/main/module/test/src/decorator/suite.ts#L13) decorator. Tests are defined as methods on the suite class, using the [@Test](https://github.com/travetto/travetto/tree/main/module/test/src/decorator/test.ts#L19) decorator. All tests intrinsically support `async`/`await`.
|
|
25
25
|
|
|
26
26
|
A simple example would be:
|
|
27
27
|
|
|
@@ -81,17 +81,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
81
81
|
const tslib_1 = require("tslib");
|
|
82
82
|
const Ⲑ_util_1 = tslib_1.__importStar(require("@travetto/test/src/execute/util.js"));
|
|
83
83
|
const Ⲑ_check_1 = tslib_1.__importStar(require("@travetto/test/src/assert/check.js"));
|
|
84
|
-
const Ⲑ_runtime_1 = tslib_1.__importStar(require("@travetto/manifest/src/runtime.js"));
|
|
85
84
|
const Ⲑ_decorator_1 = tslib_1.__importStar(require("@travetto/registry/src/decorator.js"));
|
|
86
|
-
|
|
85
|
+
const Ⲑ_function_1 = tslib_1.__importStar(require("@travetto/runtime/src/function.js"));
|
|
86
|
+
var ᚕm = ["@travetto/test", "doc/assert-example"];
|
|
87
87
|
const node_assert_1 = tslib_1.__importDefault(require("node:assert"));
|
|
88
88
|
const test_1 = require("@travetto/test");
|
|
89
89
|
let SimpleTest = class SimpleTest {
|
|
90
|
-
static Ⲑinit = Ⲑ
|
|
90
|
+
static Ⲑinit = Ⲑ_function_1.register(SimpleTest, ᚕm, { hash: 1887908328, lines: [5, 12] }, { test: { hash: 102834457, lines: [8, 11] } }, false, false);
|
|
91
91
|
async test() {
|
|
92
92
|
if (Ⲑ_util_1.RunnerUtil.tryDebugger)
|
|
93
93
|
debugger;
|
|
94
|
-
Ⲑ_check_1.AssertCheck.check({
|
|
94
|
+
Ⲑ_check_1.AssertCheck.check({ module: ᚕm, line: 10, text: "{ size: 20, address: { state: 'VA' } }", operator: "deepStrictEqual" }, true, { size: 20, address: { state: 'VA' } }, {});
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
tslib_1.__decorate([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/test",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.2",
|
|
4
4
|
"description": "Declarative test framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unit-testing",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"directory": "module/test"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@travetto/
|
|
31
|
-
"@travetto/registry": "^5.0.0-rc.
|
|
32
|
-
"@travetto/terminal": "^5.0.0-rc.
|
|
33
|
-
"@travetto/worker": "^5.0.0-rc.
|
|
30
|
+
"@travetto/runtime": "^5.0.0-rc.2",
|
|
31
|
+
"@travetto/registry": "^5.0.0-rc.2",
|
|
32
|
+
"@travetto/terminal": "^5.0.0-rc.2",
|
|
33
|
+
"@travetto/worker": "^5.0.0-rc.2",
|
|
34
34
|
"yaml": "^2.4.5"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@travetto/cli": "^5.0.0-rc.
|
|
38
|
-
"@travetto/transformer": "^5.0.0-rc.
|
|
37
|
+
"@travetto/cli": "^5.0.0-rc.2",
|
|
38
|
+
"@travetto/transformer": "^5.0.0-rc.2"
|
|
39
39
|
},
|
|
40
40
|
"peerDependenciesMeta": {
|
|
41
41
|
"@travetto/transformer": {
|
package/src/assert/capture.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { RuntimeIndex } from '@travetto/runtime';
|
|
2
3
|
|
|
3
4
|
import { Assertion, TestConfig } from '../model/test';
|
|
4
5
|
|
|
5
6
|
export interface CaptureAssert extends Partial<Assertion> {
|
|
7
|
+
module: [string, string];
|
|
6
8
|
file: string;
|
|
7
9
|
line: number;
|
|
8
10
|
text: string;
|
|
@@ -28,6 +30,7 @@ class $AssertCapture {
|
|
|
28
30
|
const handler = (a: CaptureAssert): void => {
|
|
29
31
|
const assrt = {
|
|
30
32
|
...a,
|
|
33
|
+
file: RuntimeIndex.getSourceFile(a.module),
|
|
31
34
|
classId: test.classId,
|
|
32
35
|
methodName: test.methodName
|
|
33
36
|
};
|
package/src/assert/check.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
2
|
|
|
3
|
-
import { RuntimeIndex } from '@travetto/
|
|
4
|
-
import { AppError, ClassInstance, Class } from '@travetto/base';
|
|
3
|
+
import { AppError, ClassInstance, Class, RuntimeIndex } from '@travetto/runtime';
|
|
5
4
|
|
|
6
5
|
import { ThrowableError, TestConfig, Assertion } from '../model/test';
|
|
7
6
|
import { AssertCapture, CaptureAssert } from './capture';
|
|
@@ -25,7 +24,7 @@ export class AssertCheck {
|
|
|
25
24
|
*/
|
|
26
25
|
static check(assertion: CaptureAssert, positive: boolean, ...args: unknown[]): void {
|
|
27
26
|
/* eslint-disable @typescript-eslint/consistent-type-assertions */
|
|
28
|
-
assertion.file = RuntimeIndex.getSourceFile(assertion.
|
|
27
|
+
assertion.file = RuntimeIndex.getSourceFile(assertion.module);
|
|
29
28
|
|
|
30
29
|
let fn = assertion.operator;
|
|
31
30
|
assertion.operator = ASSERT_FN_OPERATOR[fn];
|
|
@@ -215,7 +214,7 @@ export class AssertCheck {
|
|
|
215
214
|
): void {
|
|
216
215
|
let missed: Error | undefined;
|
|
217
216
|
|
|
218
|
-
assertion.file = RuntimeIndex.getSourceFile(assertion.
|
|
217
|
+
assertion.file = RuntimeIndex.getSourceFile(assertion.module);
|
|
219
218
|
|
|
220
219
|
try {
|
|
221
220
|
action();
|
|
@@ -249,7 +248,7 @@ export class AssertCheck {
|
|
|
249
248
|
): Promise<void> {
|
|
250
249
|
let missed: Error | undefined;
|
|
251
250
|
|
|
252
|
-
assertion.file = RuntimeIndex.getSourceFile(assertion.
|
|
251
|
+
assertion.file = RuntimeIndex.getSourceFile(assertion.module);
|
|
253
252
|
|
|
254
253
|
try {
|
|
255
254
|
if ('then' in action) {
|
|
@@ -279,7 +278,9 @@ export class AssertCheck {
|
|
|
279
278
|
line = test.lineStart;
|
|
280
279
|
}
|
|
281
280
|
|
|
281
|
+
const entry = RuntimeIndex.getFromSource(test.file)!;
|
|
282
282
|
AssertCapture.add({
|
|
283
|
+
module: [entry.module, entry.relativeFile],
|
|
283
284
|
file: test.file,
|
|
284
285
|
line,
|
|
285
286
|
operator: 'throws',
|
package/src/assert/util.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import util from 'node:util';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { path } from '@travetto/manifest';
|
|
3
|
+
import { Runtime } from '@travetto/runtime';
|
|
5
4
|
|
|
6
5
|
import { TestConfig, Assertion, TestResult } from '../model/test';
|
|
7
6
|
import { SuiteConfig } from '../model/suite';
|
|
@@ -44,8 +43,9 @@ export class AssertUtil {
|
|
|
44
43
|
* Determine file location for a given error and the stack trace
|
|
45
44
|
*/
|
|
46
45
|
static getPositionOfError(err: Error, filename: string): { file: string, line: number } {
|
|
47
|
-
const cwd =
|
|
48
|
-
const lines =
|
|
46
|
+
const cwd = Runtime.mainSourcePath;
|
|
47
|
+
const lines = (err.stack ?? new Error().stack!)
|
|
48
|
+
.replace(/[\\/]/g, '/')
|
|
49
49
|
.split('\n')
|
|
50
50
|
// Exclude node_modules, target self
|
|
51
51
|
.filter(x => x.includes(cwd) && (!x.includes('node_modules') || x.includes('/support/')));
|
|
@@ -97,7 +97,7 @@ export class AssertUtil {
|
|
|
97
97
|
|
|
98
98
|
const msg = error.message.split(/\n/)[0];
|
|
99
99
|
|
|
100
|
-
const core = { file, classId: suite.classId, methodName, module:
|
|
100
|
+
const core = { file, classId: suite.classId, methodName, module: Runtime.main.name };
|
|
101
101
|
const coreAll = { ...core, description: msg, lineStart: line, lineEnd: line, lineBodyStart: line };
|
|
102
102
|
|
|
103
103
|
const assert: Assertion = {
|
package/src/consumer/error.ts
CHANGED
package/src/consumer/registry.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Terminal } from '@travetto/terminal';
|
|
2
|
-
import { AppError, TimeUtil,
|
|
2
|
+
import { AppError, TimeUtil, Runtime } from '@travetto/runtime';
|
|
3
3
|
import { stringify } from 'yaml';
|
|
4
4
|
|
|
5
5
|
import { TestEvent } from '../../model/event';
|
|
@@ -70,7 +70,7 @@ export class TapEmitter implements TestConsumer {
|
|
|
70
70
|
this.#enhancer.assertNumber(++subCount),
|
|
71
71
|
'-',
|
|
72
72
|
this.#enhancer.assertDescription(text),
|
|
73
|
-
`${this.#enhancer.assertFile(asrt.file.replace(
|
|
73
|
+
`${this.#enhancer.assertFile(asrt.file.replace(Runtime.mainSourcePath, '.'))}:${this.#enhancer.assertLine(asrt.line)}`
|
|
74
74
|
].join(' ');
|
|
75
75
|
|
|
76
76
|
if (asrt.error) {
|
package/src/decorator/suite.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Class, ClassInstance } from '@travetto/base';
|
|
1
|
+
import { Class, ClassInstance, describeFunction } from '@travetto/runtime';
|
|
3
2
|
|
|
4
3
|
import { SuiteRegistry } from '../registry/suite';
|
|
5
4
|
import { SuiteConfig } from '../model/suite';
|
|
@@ -27,7 +26,7 @@ export function Suite(description?: string | Partial<SuiteConfig>, ...rest: Part
|
|
|
27
26
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
28
27
|
const decorator = ((target: Class) => {
|
|
29
28
|
const cfg = { description: descriptionString, ...extra };
|
|
30
|
-
if (
|
|
29
|
+
if (describeFunction(target).abstract) {
|
|
31
30
|
cfg.skip = true;
|
|
32
31
|
}
|
|
33
32
|
SuiteRegistry.register(target, cfg);
|
package/src/decorator/test.ts
CHANGED
package/src/execute/console.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import util from 'node:util';
|
|
2
2
|
|
|
3
|
-
import { ConsoleEvent, ConsoleListener, ConsoleManager } from '@travetto/
|
|
3
|
+
import { ConsoleEvent, ConsoleListener, ConsoleManager } from '@travetto/runtime';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Console capturer. Hooks into the Console manager, and collects the
|
package/src/execute/executor.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { AssertionError } from 'node:assert';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
|
-
import { RuntimeIndex } from '@travetto/
|
|
5
|
-
import { Env, TimeUtil, RuntimeContext } from '@travetto/base';
|
|
4
|
+
import { Env, TimeUtil, Runtime, RuntimeIndex } from '@travetto/runtime';
|
|
6
5
|
import { Barrier, ExecutionError } from '@travetto/worker';
|
|
7
6
|
|
|
8
7
|
import { SuiteRegistry } from '../registry/suite';
|
|
@@ -68,10 +67,10 @@ export class TestExecutor {
|
|
|
68
67
|
*/
|
|
69
68
|
static failFile(consumer: TestConsumer, file: string, err: Error): void {
|
|
70
69
|
const name = path.basename(file);
|
|
71
|
-
const classId = RuntimeIndex.
|
|
70
|
+
const classId = `${RuntimeIndex.getEntry(file)?.id}○${name}`;
|
|
72
71
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
73
72
|
const suite = { class: { name }, classId, duration: 0, lineStart: 1, lineEnd: 1, file, } as SuiteConfig & SuiteResult;
|
|
74
|
-
err.message = err.message.replaceAll(
|
|
73
|
+
err.message = err.message.replaceAll(Runtime.mainSourcePath, '.');
|
|
75
74
|
const res = AssertUtil.generateSuiteError(suite, 'require', err);
|
|
76
75
|
consumer.onEvent({ type: 'suite', phase: 'before', suite });
|
|
77
76
|
consumer.onEvent({ type: 'test', phase: 'before', test: res.testConfig });
|
|
@@ -110,7 +109,7 @@ export class TestExecutor {
|
|
|
110
109
|
|
|
111
110
|
const result: TestResult = {
|
|
112
111
|
methodName: test.methodName,
|
|
113
|
-
module:
|
|
112
|
+
module: Runtime.main.name,
|
|
114
113
|
description: test.description,
|
|
115
114
|
classId: test.classId,
|
|
116
115
|
lineStart: test.lineStart,
|
package/src/execute/phase.ts
CHANGED
package/src/execute/promise.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHook, executionAsyncId } from 'node:async_hooks';
|
|
2
2
|
|
|
3
3
|
import { ExecutionError } from '@travetto/worker';
|
|
4
|
-
import { Util } from '@travetto/
|
|
4
|
+
import { Util } from '@travetto/runtime';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Promise watcher, to catch any unfinished promises
|
package/src/execute/runner.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
|
|
3
|
-
import { path as mp
|
|
4
|
-
import { TimeUtil,
|
|
3
|
+
import { path as mp } from '@travetto/manifest';
|
|
4
|
+
import { TimeUtil, Runtime, RuntimeIndex } from '@travetto/runtime';
|
|
5
5
|
import { WorkPool } from '@travetto/worker';
|
|
6
6
|
|
|
7
7
|
import { buildStandardTestManager } from '../worker/standard';
|
|
@@ -55,7 +55,7 @@ export class Runner {
|
|
|
55
55
|
*/
|
|
56
56
|
async runSingle(): Promise<boolean> {
|
|
57
57
|
const mod = RuntimeIndex.getEntry(path.resolve(this.#state.args[0]))!;
|
|
58
|
-
if (mod.module !==
|
|
58
|
+
if (mod.module !== Runtime.main.name) {
|
|
59
59
|
RuntimeIndex.reinitForModule(mod.module);
|
|
60
60
|
}
|
|
61
61
|
|
package/src/execute/util.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { spawn } from 'node:child_process';
|
|
|
2
2
|
import { createReadStream } from 'node:fs';
|
|
3
3
|
import readline from 'node:readline';
|
|
4
4
|
|
|
5
|
-
import { Env, ExecUtil, ShutdownManager, Util } from '@travetto/
|
|
6
|
-
import {
|
|
5
|
+
import { Env, ExecUtil, ShutdownManager, Util, RuntimeIndex } from '@travetto/runtime';
|
|
6
|
+
import type { IndexedFile } from '@travetto/manifest';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Simple Test Utilities
|
package/src/execute/watcher.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RootRegistry, MethodSource } from '@travetto/registry';
|
|
2
2
|
import { WorkPool, WorkQueue } from '@travetto/worker';
|
|
3
|
-
import {
|
|
3
|
+
import { Runtime, describeFunction } from '@travetto/runtime';
|
|
4
4
|
|
|
5
5
|
import { SuiteRegistry } from '../registry/suite';
|
|
6
6
|
import { buildStandardTestManager } from '../worker/standard';
|
|
@@ -42,7 +42,7 @@ export class TestWatcher {
|
|
|
42
42
|
|
|
43
43
|
new MethodSource(RootRegistry).on(e => {
|
|
44
44
|
const [cls, method] = (e.prev ?? e.curr ?? []);
|
|
45
|
-
if (!cls ||
|
|
45
|
+
if (!cls || describeFunction(cls).abstract) {
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
if (!method) {
|
|
@@ -60,7 +60,7 @@ export class TestWatcher {
|
|
|
60
60
|
type: 'removeTest',
|
|
61
61
|
method: method?.name,
|
|
62
62
|
classId: cls?.Ⲑid,
|
|
63
|
-
file:
|
|
63
|
+
file: Runtime.getSource(cls)
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
});
|
package/src/fixture.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { FileLoader } from '@travetto/
|
|
1
|
+
import { FileLoader, Runtime } from '@travetto/runtime';
|
|
2
2
|
|
|
3
3
|
export class TestFixtures extends FileLoader {
|
|
4
4
|
constructor(modules: string[] = []) {
|
|
5
|
-
super(
|
|
5
|
+
super(Runtime.modulePaths([
|
|
6
|
+
'@#test/fixtures',
|
|
7
|
+
'@#support/fixtures',
|
|
8
|
+
...modules.flat().map(x => `${x}#support/fixtures`),
|
|
9
|
+
'@@#support/fixtures'
|
|
10
|
+
]));
|
|
6
11
|
}
|
|
7
12
|
}
|
package/src/model/suite.ts
CHANGED
package/src/model/test.ts
CHANGED
package/src/registry/suite.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Class, ConcreteClass,
|
|
1
|
+
import { Class, ConcreteClass, Runtime, describeFunction } from '@travetto/runtime';
|
|
2
2
|
import { MetadataRegistry } from '@travetto/registry';
|
|
3
|
-
import { RuntimeIndex } from '@travetto/manifest';
|
|
4
3
|
|
|
5
4
|
import { SuiteConfig } from '../model/suite';
|
|
6
5
|
import { TestConfig } from '../model/test';
|
|
@@ -14,18 +13,18 @@ class $SuiteRegistry extends MetadataRegistry<SuiteConfig, TestConfig> {
|
|
|
14
13
|
* Find all valid tests (ignoring abstract)
|
|
15
14
|
*/
|
|
16
15
|
getValidClasses(): Class[] {
|
|
17
|
-
return this.getClasses().filter(c => !
|
|
16
|
+
return this.getClasses().filter(c => !describeFunction(c).abstract);
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
createPending(cls: Class): Partial<SuiteConfig> {
|
|
21
|
-
const
|
|
20
|
+
const lines = describeFunction(cls)?.lines;
|
|
22
21
|
return {
|
|
23
22
|
class: cls,
|
|
24
|
-
module:
|
|
23
|
+
module: Runtime.main.name,
|
|
25
24
|
classId: cls.Ⲑid,
|
|
26
|
-
file:
|
|
27
|
-
lineStart:
|
|
28
|
-
lineEnd:
|
|
25
|
+
file: Runtime.getSource(cls),
|
|
26
|
+
lineStart: lines?.[0],
|
|
27
|
+
lineEnd: lines?.[1],
|
|
29
28
|
tests: [],
|
|
30
29
|
beforeAll: [],
|
|
31
30
|
beforeEach: [],
|
|
@@ -35,14 +34,13 @@ class $SuiteRegistry extends MetadataRegistry<SuiteConfig, TestConfig> {
|
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
override createPendingField(cls: Class, fn: Function): Partial<TestConfig> {
|
|
38
|
-
const
|
|
39
|
-
const meth = meta.methods![fn.name];
|
|
37
|
+
const lines = describeFunction(cls)?.methods?.[fn.name].lines;
|
|
40
38
|
return {
|
|
41
39
|
class: cls,
|
|
42
|
-
module:
|
|
43
|
-
file:
|
|
44
|
-
lineStart:
|
|
45
|
-
lineEnd:
|
|
40
|
+
module: Runtime.main.name,
|
|
41
|
+
file: Runtime.getSource(cls),
|
|
42
|
+
lineStart: lines?.[0],
|
|
43
|
+
lineEnd: lines?.[1],
|
|
46
44
|
methodName: fn.name
|
|
47
45
|
};
|
|
48
46
|
}
|
|
@@ -98,7 +96,9 @@ class $SuiteRegistry extends MetadataRegistry<SuiteConfig, TestConfig> {
|
|
|
98
96
|
getRunParams(file: string, clsName?: string, method?: string): { suites: SuiteConfig[] } | { suite: SuiteConfig, test?: TestConfig } {
|
|
99
97
|
if (clsName && /^\d+$/.test(clsName)) { // If we only have a line number
|
|
100
98
|
const line = parseInt(clsName, 10);
|
|
101
|
-
const suites = this.getValidClasses()
|
|
99
|
+
const suites = this.getValidClasses()
|
|
100
|
+
.filter(cls => Runtime.getSource(cls) === file)
|
|
101
|
+
.map(x => this.get(x)).filter(x => !x.skip);
|
|
102
102
|
const suite = suites.find(x => line >= x.lineStart && line <= x.lineEnd);
|
|
103
103
|
|
|
104
104
|
if (suite) {
|
|
@@ -120,7 +120,7 @@ class $SuiteRegistry extends MetadataRegistry<SuiteConfig, TestConfig> {
|
|
|
120
120
|
} else {
|
|
121
121
|
const suites = this.getValidClasses()
|
|
122
122
|
.map(x => this.get(x))
|
|
123
|
-
.filter(x => !
|
|
123
|
+
.filter(x => !describeFunction(x.class).abstract); // Do not run abstract suites
|
|
124
124
|
return { suites };
|
|
125
125
|
}
|
|
126
126
|
}
|
package/src/trv.d.ts
CHANGED
package/src/worker/child.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createWriteStream } from 'node:fs';
|
|
2
2
|
|
|
3
|
-
import { ConsoleManager, Env, Util,
|
|
3
|
+
import { ConsoleManager, Env, Util, Runtime } from '@travetto/runtime';
|
|
4
4
|
import { ChildCommChannel } from '@travetto/worker';
|
|
5
5
|
|
|
6
6
|
import { ErrorUtil } from '../consumer/error';
|
|
@@ -34,7 +34,7 @@ export class TestChildWorker extends ChildCommChannel<RunEvent> {
|
|
|
34
34
|
*/
|
|
35
35
|
async activate(): Promise<void> {
|
|
36
36
|
if (/\b@travetto[/]test\b/.test(Env.DEBUG.val ?? '')) {
|
|
37
|
-
const file =
|
|
37
|
+
const file = Runtime.toolPath(`test-worker.${process.pid}.log`);
|
|
38
38
|
const stdout = createWriteStream(file, { flags: 'a' });
|
|
39
39
|
const c = new console.Console({ stdout, inspectOptions: { depth: 4, colors: false } });
|
|
40
40
|
ConsoleManager.set({ log: (ev) => c[ev.level](process.pid, ...ev.args) });
|
package/src/worker/standard.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { fork } from 'node:child_process';
|
|
2
2
|
|
|
3
|
-
import { RuntimeIndex } from '@travetto/
|
|
4
|
-
import { Env } from '@travetto/base';
|
|
3
|
+
import { Env, RuntimeIndex } from '@travetto/runtime';
|
|
5
4
|
import { ParentCommChannel } from '@travetto/worker';
|
|
6
5
|
|
|
7
6
|
import { Events, RunEvent } from './types';
|
package/support/cli.test.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { EventEmitter } from 'node:events';
|
|
|
2
2
|
import fs from 'node:fs/promises';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
|
|
5
|
-
import { Env } from '@travetto/
|
|
5
|
+
import { Env } from '@travetto/runtime';
|
|
6
6
|
import { CliCommandShape, CliCommand, CliValidationError } from '@travetto/cli';
|
|
7
7
|
import { WorkPool } from '@travetto/worker';
|
|
8
8
|
import { Max, Min } from '@travetto/schema';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CliCommand } from '@travetto/cli';
|
|
2
|
-
import {
|
|
3
|
-
import { Env } from '@travetto/base';
|
|
2
|
+
import { Env, describeFunction } from '@travetto/runtime';
|
|
4
3
|
|
|
5
4
|
import { SuiteRegistry } from '../src/registry/suite';
|
|
6
5
|
import { RunnerUtil } from '../src/execute/util';
|
|
@@ -31,7 +30,7 @@ export class TestCountCommand {
|
|
|
31
30
|
const suites = SuiteRegistry.getClasses();
|
|
32
31
|
const total = suites
|
|
33
32
|
.map(c => SuiteRegistry.get(c))
|
|
34
|
-
.filter(c => !
|
|
33
|
+
.filter(c => !describeFunction(c.class).abstract)
|
|
35
34
|
.reduce((acc, c) => acc + (c.tests?.length ?? 0), 0);
|
|
36
35
|
|
|
37
36
|
console.log(total);
|
|
@@ -159,7 +159,7 @@ export class AssertTransformer {
|
|
|
159
159
|
cmd.args = cmd.args.filter(x => x !== undefined && x !== null);
|
|
160
160
|
const check = state.factory.createCallExpression(state[AssertⲐ]!.assertCheck, undefined, state.factory.createNodeArray([
|
|
161
161
|
state.fromLiteral({
|
|
162
|
-
|
|
162
|
+
module: state.getModuleIdentifier(),
|
|
163
163
|
line: state.fromLiteral(ts.getLineAndCharacterOfPosition(state.source, node.getStart()).line + 1),
|
|
164
164
|
text: state.fromLiteral(firstText),
|
|
165
165
|
operator: state.fromLiteral(cmd.fn)
|
|
@@ -184,7 +184,7 @@ export class AssertTransformer {
|
|
|
184
184
|
undefined,
|
|
185
185
|
state.factory.createNodeArray([
|
|
186
186
|
state.fromLiteral({
|
|
187
|
-
|
|
187
|
+
module: state.getModuleIdentifier(),
|
|
188
188
|
line: state.fromLiteral(ts.getLineAndCharacterOfPosition(state.source, node.getStart()).line + 1),
|
|
189
189
|
text: state.fromLiteral(`${key} ${firstText}`),
|
|
190
190
|
operator: state.fromLiteral(`${key}`)
|