@travetto/test
Advanced tools
Comparing version 3.4.3 to 4.0.0-rc.0
@@ -0,1 +1,2 @@ | ||
/// <reference path="./src/trv.d.ts" /> | ||
export * from './src/decorator/suite'; | ||
@@ -2,0 +3,0 @@ export * from './src/decorator/test'; |
{ | ||
"name": "@travetto/test", | ||
"version": "3.4.3", | ||
"version": "4.0.0-rc.0", | ||
"description": "Declarative test framework", | ||
@@ -30,11 +30,11 @@ "keywords": [ | ||
"dependencies": { | ||
"@travetto/base": "^3.4.2", | ||
"@travetto/registry": "^3.4.2", | ||
"@travetto/terminal": "^3.4.0", | ||
"@travetto/worker": "^3.4.2", | ||
"@travetto/yaml": "^3.4.2" | ||
"@travetto/base": "^4.0.0-rc.0", | ||
"@travetto/registry": "^4.0.0-rc.0", | ||
"@travetto/terminal": "^4.0.0-rc.0", | ||
"@travetto/worker": "^4.0.0-rc.0", | ||
"@travetto/yaml": "^4.0.0-rc.0" | ||
}, | ||
"peerDependencies": { | ||
"@travetto/cli": "^3.4.7", | ||
"@travetto/transformer": "^3.4.2" | ||
"@travetto/cli": "^4.0.0-rc.0", | ||
"@travetto/transformer": "^4.0.0-rc.0" | ||
}, | ||
@@ -41,0 +41,0 @@ "peerDependenciesMeta": { |
@@ -30,3 +30,3 @@ <!-- This file was generated by @travetto/doc and should not be modified directly --> | ||
```typescript | ||
import assert from 'assert'; | ||
import assert from 'node:assert'; | ||
@@ -62,3 +62,3 @@ import { Suite, Test } from '@travetto/test'; | ||
```typescript | ||
import assert from 'assert'; | ||
import assert from 'node:assert'; | ||
@@ -86,9 +86,9 @@ import { Suite, Test } from '@travetto/test'; | ||
const Ⲑ_check_1 = tslib_1.__importStar(require("@travetto/test/src/assert/check.js")); | ||
const Ⲑ_root_index_1 = tslib_1.__importStar(require("@travetto/manifest/src/root-index.js")); | ||
const Ⲑ_runtime_1 = tslib_1.__importStar(require("@travetto/manifest/src/runtime.js")); | ||
const Ⲑ_decorator_1 = tslib_1.__importStar(require("@travetto/registry/src/decorator.js")); | ||
var ᚕf = "@travetto/test/doc/assert-example.js"; | ||
const assert_1 = tslib_1.__importDefault(require("assert")); | ||
const node_assert_1 = tslib_1.__importDefault(require("node:assert")); | ||
const test_1 = require("@travetto/test"); | ||
let SimpleTest = class SimpleTest { | ||
static Ⲑinit = Ⲑ_root_index_1.RootIndex.registerFunction(SimpleTest, ᚕf, 1887908328, { test: { hash: 102834457 } }, false, false); | ||
static Ⲑinit = Ⲑ_runtime_1.RuntimeIndex.registerFunction(SimpleTest, ᚕf, 1887908328, { test: { hash: 102834457 } }, false, false); | ||
async test() { | ||
@@ -137,3 +137,3 @@ if (Ⲑ_util_1.RunnerUtil.tryDebugger) | ||
```typescript | ||
import assert from 'assert'; | ||
import assert from 'node:assert'; | ||
@@ -164,3 +164,3 @@ import { Suite, Test } from '@travetto/test'; | ||
```typescript | ||
import assert from 'assert'; | ||
import assert from 'node:assert'; | ||
@@ -194,3 +194,3 @@ import { Suite, Test } from '@travetto/test'; | ||
```typescript | ||
import assert from 'assert'; | ||
import assert from 'node:assert'; | ||
@@ -197,0 +197,0 @@ import { Suite, Test } from '@travetto/test'; |
@@ -1,2 +0,2 @@ | ||
import { EventEmitter } from 'events'; | ||
import { EventEmitter } from 'node:events'; | ||
@@ -3,0 +3,0 @@ import { Assertion, TestConfig } from '../model/test'; |
@@ -1,4 +0,4 @@ | ||
import assert from 'assert'; | ||
import assert from 'node:assert'; | ||
import { RootIndex } from '@travetto/manifest'; | ||
import { RuntimeIndex } from '@travetto/manifest'; | ||
import { ObjectUtil, AppError, ClassInstance, Class } from '@travetto/base'; | ||
@@ -33,3 +33,3 @@ | ||
static check(assertion: CaptureAssert, positive: boolean, ...args: unknown[]): void { | ||
assertion.file = RootIndex.getSourceFile(assertion.file); | ||
assertion.file = RuntimeIndex.getSourceFile(assertion.file); | ||
@@ -231,3 +231,3 @@ let fn = assertion.operator; | ||
assertion.file = RootIndex.getSourceFile(assertion.file); | ||
assertion.file = RuntimeIndex.getSourceFile(assertion.file); | ||
@@ -266,3 +266,3 @@ try { | ||
assertion.file = RootIndex.getSourceFile(assertion.file); | ||
assertion.file = RuntimeIndex.getSourceFile(assertion.file); | ||
@@ -269,0 +269,0 @@ try { |
@@ -1,4 +0,4 @@ | ||
import util from 'util'; | ||
import util from 'node:util'; | ||
import { path, RootIndex } from '@travetto/manifest'; | ||
import { path, RuntimeIndex, RuntimeContext } from '@travetto/manifest'; | ||
import { Class, ClassInstance, ObjectUtil } from '@travetto/base'; | ||
@@ -44,3 +44,3 @@ | ||
static getPositionOfError(err: Error, filename: string): { file: string, line: number } { | ||
const cwd = RootIndex.mainModule.sourcePath; | ||
const cwd = RuntimeIndex.mainModule.sourcePath; | ||
const lines = path.toPosix(err.stack ?? new Error().stack!) | ||
@@ -98,3 +98,3 @@ .split('\n') | ||
const core = { file, classId: suite.classId, methodName, module: RootIndex.manifest.mainModule }; | ||
const core = { file, classId: suite.classId, methodName, module: RuntimeContext.main.name }; | ||
const coreAll = { ...core, description: msg, lines: { start: line, end: line, codeStart: line } }; | ||
@@ -101,0 +101,0 @@ |
@@ -1,18 +0,18 @@ | ||
import { GlobalTerminal } from '@travetto/terminal'; | ||
import { StyleUtil } from '@travetto/terminal'; | ||
export const CONSOLE_ENHANCER = GlobalTerminal.palette({ | ||
assertDescription: 'lightGray', | ||
testDescription: 'white', | ||
success: 'green', | ||
failure: 'red', | ||
assertNumber: 'brightCyan', | ||
testNumber: 'dodgerBlue', | ||
assertFile: 'lightGreen', | ||
assertLine: 'lightYellow', | ||
objectInspect: 'magenta', | ||
suiteName: 'yellow', | ||
testName: 'cyan', | ||
total: 'white' | ||
export const CONSOLE_ENHANCER = StyleUtil.getPalette({ | ||
assertDescription: '#d3d3d3', // light gray | ||
testDescription: '#e5e5e5', // White | ||
success: '#00cd00', // Green | ||
failure: '#cd0000', // Red | ||
assertNumber: '#00ffff', // Bright cyan | ||
testNumber: '#1e90ff', // dodger blue | ||
assertFile: '#90e90', // lightGreen | ||
assertLine: '#ffffe0', // light yellow | ||
objectInspect: '#cd00cd', // Magenta | ||
suiteName: '#cdcd00', // Yellow | ||
testName: '#00cdcd', // Cyan | ||
total: '#e5e5e5', // White | ||
}); | ||
export type TestResultsEnhancer = typeof CONSOLE_ENHANCER; |
@@ -1,2 +0,2 @@ | ||
import { existsSync } from 'fs'; | ||
import { existsSync } from 'node:fs'; | ||
@@ -3,0 +3,0 @@ import { Class } from '@travetto/base'; |
@@ -1,2 +0,2 @@ | ||
import { Writable } from 'stream'; | ||
import { Writable } from 'node:stream'; | ||
@@ -3,0 +3,0 @@ import { TestEvent } from '../../model/event'; |
@@ -1,2 +0,2 @@ | ||
import { Writable } from 'stream'; | ||
import { Writable } from 'node:stream'; | ||
@@ -3,0 +3,0 @@ import { TestEvent } from '../../model/event'; |
@@ -1,3 +0,4 @@ | ||
import { GlobalTerminal, TermStyleInput, Terminal } from '@travetto/terminal'; | ||
import { ManualAsyncIterator } from '@travetto/worker'; | ||
import { Util } from '@travetto/base'; | ||
import { StyleUtil, Terminal, TerminalUtil } from '@travetto/terminal'; | ||
import { WorkQueue } from '@travetto/worker'; | ||
@@ -18,31 +19,8 @@ import { TestEvent } from '../../model/event'; | ||
static makeProgressBar(term: Terminal, total: number): (t: TestResult, idx: number) => string { | ||
let failed = 0; | ||
const palette: TermStyleInput[] = [ | ||
{ text: 'white', background: 'darkGreen' }, | ||
{ text: 'white', background: 'darkRed' } | ||
]; | ||
const styles = palette.map(s => GlobalTerminal.colorer(s)); | ||
return (t: TestResult, idx: number): string => { | ||
if (t.status === 'failed') { | ||
failed += 1; | ||
} | ||
const i = idx + 1; | ||
const digits = total.toString().length; | ||
const paddedI = `${i}`.padStart(digits); | ||
const paddedFailed = `${failed}`.padStart(digits); | ||
const line = `Tests ${paddedI}/${total} [${paddedFailed} failed] -- ${t.classId}`.padEnd(term.width); | ||
const pos = Math.trunc(line.length * (i / total)); | ||
const colorer = styles[Math.min(failed, styles.length - 1)]; | ||
return `${colorer(line.substring(0, pos))}${line.substring(pos)}`; | ||
}; | ||
} | ||
#terminal: Terminal; | ||
#results = new ManualAsyncIterator<TestResult>(); | ||
#results = new WorkQueue<TestResult>(); | ||
#progress: Promise<unknown> | undefined; | ||
#consumer: TapEmitter; | ||
constructor(terminal: Terminal = new Terminal({ output: process.stderr })) { | ||
constructor(terminal: Terminal = new Terminal(process.stderr)) { | ||
this.#terminal = terminal; | ||
@@ -55,5 +33,15 @@ this.#consumer = new TapEmitter(this.#terminal); | ||
this.#progress = this.#terminal.streamToPosition(this.#results, | ||
TapStreamedEmitter.makeProgressBar(this.#terminal, state.testCount ?? 0), | ||
{ position: 'bottom', minDelay: 100 } | ||
let failed = 0; | ||
const succ = StyleUtil.getStyle({ text: '#e5e5e5', background: '#026020' }); // White on dark green | ||
const fail = StyleUtil.getStyle({ text: '#e5e5e5', background: '#8b0000' }); // White on dark red | ||
this.#progress = this.#terminal.streamToBottom( | ||
Util.mapAsyncItr( | ||
this.#results, | ||
(value, idx) => { | ||
failed += (value.status === 'failed' ? 1 : 0); | ||
return { value: `Tests %idx/%total [${failed} failed] -- ${value.classId}`, total: state.testCount, idx }; | ||
}, | ||
TerminalUtil.progressBarUpdater(this.#terminal, { style: () => ({ complete: failed ? fail : succ }) }) | ||
), | ||
{ minDelay: 100 } | ||
); | ||
@@ -60,0 +48,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import { RootIndex } from '@travetto/manifest'; | ||
import { GlobalTerminal, Terminal } from '@travetto/terminal'; | ||
import { RuntimeIndex } from '@travetto/manifest'; | ||
import { Terminal } from '@travetto/terminal'; | ||
import { ObjectUtil, TimeUtil } from '@travetto/base'; | ||
@@ -23,3 +23,3 @@ import { YamlUtil } from '@travetto/yaml'; | ||
constructor( | ||
terminal = new Terminal({ output: process.stdout }), | ||
terminal = new Terminal(), | ||
enhancer: TestResultsEnhancer = CONSOLE_ENHANCER | ||
@@ -32,3 +32,3 @@ ) { | ||
log(message: string): void { | ||
this.#terminal.writeLines(message); | ||
this.#terminal.writer.writeLine(message).commit(); | ||
} | ||
@@ -48,3 +48,3 @@ | ||
logMeta(obj: Record<string, unknown>): void { | ||
const lineLength = GlobalTerminal.width - 5; | ||
const lineLength = this.#terminal.width - 5; | ||
let body = YamlUtil.serialize(obj, { wordwrap: lineLength }); | ||
@@ -77,3 +77,3 @@ body = body.split('\n').map(x => ` ${x}`).join('\n'); | ||
this.#enhancer.assertDescription(text), | ||
`${this.#enhancer.assertFile(asrt.file.replace(RootIndex.mainModule.sourcePath, '.'))}:${this.#enhancer.assertLine(asrt.line)}` | ||
`${this.#enhancer.assertFile(asrt.file.replace(RuntimeIndex.mainModule.sourcePath, '.'))}:${this.#enhancer.assertLine(asrt.line)}` | ||
].join(' '); | ||
@@ -80,0 +80,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { Writable } from 'stream'; | ||
import { Writable } from 'node:stream'; | ||
@@ -3,0 +3,0 @@ import { YamlUtil } from '@travetto/yaml'; |
@@ -1,2 +0,2 @@ | ||
import { RootIndex } from '@travetto/manifest'; | ||
import { RuntimeIndex } from '@travetto/manifest'; | ||
import { Class, ClassInstance } from '@travetto/base'; | ||
@@ -30,3 +30,3 @@ | ||
const cfg = { description: descriptionString, ...extra }; | ||
if (RootIndex.getFunctionMetadata(target)?.abstract) { | ||
if (RuntimeIndex.getFunctionMetadata(target)?.abstract) { | ||
cfg.skip = true; | ||
@@ -33,0 +33,0 @@ } |
import { ClassInstance } from '@travetto/base'; | ||
import { RootIndex } from '@travetto/manifest'; | ||
import { RuntimeIndex } from '@travetto/manifest'; | ||
@@ -35,3 +35,3 @@ import { SuiteRegistry } from '../registry/suite'; | ||
...extra, | ||
file: RootIndex.getFunctionMetadata(inst.constructor)!.source, | ||
file: RuntimeIndex.getFunctionMetadata(inst.constructor)!.source, | ||
description: descriptionString | ||
@@ -38,0 +38,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
import util from 'util'; | ||
import util from 'node:util'; | ||
@@ -3,0 +3,0 @@ import { ConsoleEvent, ConsoleManager } from '@travetto/base'; |
@@ -1,5 +0,6 @@ | ||
import timers from 'timers/promises'; | ||
import timers from 'node:timers/promises'; | ||
import { AssertionError } from 'node:assert'; | ||
import { path, RootIndex } from '@travetto/manifest'; | ||
import { TimeUtil, Util } from '@travetto/base'; | ||
import { path, RuntimeIndex, RuntimeContext } from '@travetto/manifest'; | ||
import { Env, Util } from '@travetto/base'; | ||
import { Barrier, ExecutionError } from '@travetto/worker'; | ||
@@ -18,3 +19,3 @@ | ||
const TEST_TIMEOUT = TimeUtil.getEnvTime('TRV_TEST_TIMEOUT', '5s'); | ||
const TEST_TIMEOUT = Env.TRV_TEST_TIMEOUT.time ?? 5000; | ||
@@ -72,6 +73,6 @@ /** | ||
const name = path.basename(file); | ||
const classId = RootIndex.getId(file, name); | ||
const classId = RuntimeIndex.getId(file, name); | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
const suite = { class: { name }, classId, duration: 0, lines: { start: 1, end: 1 }, file, } as SuiteConfig & SuiteResult; | ||
err.message = err.message.replaceAll(RootIndex.mainModule.sourcePath, '.'); | ||
err.message = err.message.replaceAll(RuntimeIndex.mainModule.sourcePath, '.'); | ||
const res = AssertUtil.generateSuiteError(suite, 'require', err); | ||
@@ -114,3 +115,3 @@ consumer.onEvent({ type: 'suite', phase: 'before', suite }); | ||
methodName: test.methodName, | ||
module: RootIndex.manifest.mainModule, | ||
module: RuntimeContext.main.name, | ||
description: test.description, | ||
@@ -146,6 +147,10 @@ classId: test.classId, | ||
if (error) { | ||
if (error instanceof ExecutionError) { // Errors that are not expected | ||
if (error instanceof AssertionError) { | ||
// Pass | ||
} else if (error instanceof ExecutionError) { // Errors that are not expected | ||
AssertCheck.checkUnhandled(test, error); | ||
} else if (test.shouldThrow) { // Errors that are | ||
error = AssertCheck.checkError(test.shouldThrow!, error); // Rewrite error | ||
} else if (error instanceof Error) { | ||
AssertCheck.checkUnhandled(test, error); | ||
} | ||
@@ -261,3 +266,3 @@ } | ||
const entry = RootIndex.getEntry(file)!; | ||
const entry = RuntimeIndex.getEntry(file)!; | ||
@@ -264,0 +269,0 @@ try { |
import { Barrier } from '@travetto/worker'; | ||
import { TimeUtil } from '@travetto/base'; | ||
import { Env } from '@travetto/base'; | ||
@@ -11,3 +11,3 @@ import { TestConsumer } from '../consumer/types'; | ||
const TEST_PHASE_TIMEOUT = TimeUtil.getEnvTime('TRV_TEST_PHASE_TIMEOUT', '15s'); | ||
const TEST_PHASE_TIMEOUT = Env.TRV_TEST_PHASE_TIMEOUT.time ?? 15000; | ||
@@ -14,0 +14,0 @@ /** |
import { path } from '@travetto/manifest'; | ||
import { TimeUtil } from '@travetto/base'; | ||
import { WorkPool, IterableWorkSet } from '@travetto/worker'; | ||
import { WorkPool } from '@travetto/worker'; | ||
@@ -37,13 +37,13 @@ import { buildStandardTestManager } from '../worker/standard'; | ||
const manager = buildStandardTestManager; | ||
const pool = new WorkPool(manager(consumer), { | ||
idleTimeoutMillis: TimeUtil.timeToMs('10s'), | ||
min: 1, | ||
max: this.#state.concurrency | ||
}); | ||
const testCount = await RunnerUtil.getTestCount(this.#state.args); | ||
await consumer.onStart({ testCount }); | ||
await pool.process(new IterableWorkSet(files)); | ||
await WorkPool.run( | ||
() => buildStandardTestManager(consumer), | ||
files, | ||
{ | ||
idleTimeoutMillis: TimeUtil.timeToMs('10s'), | ||
min: 1, | ||
max: this.#state.concurrency, | ||
}); | ||
return consumer.summarizeAsBoolean(); | ||
@@ -50,0 +50,0 @@ } |
@@ -1,6 +0,7 @@ | ||
import { createReadStream } from 'fs'; | ||
import readline from 'readline'; | ||
import { createReadStream } from 'node:fs'; | ||
import readline from 'node:readline'; | ||
import timers from 'node:timers/promises'; | ||
import { ExecUtil, ShutdownManager, TimeUtil } from '@travetto/base'; | ||
import { IndexedFile, RootIndex } from '@travetto/manifest'; | ||
import { Env, ExecUtil, ShutdownManager } from '@travetto/base'; | ||
import { IndexedFile, RuntimeIndex } from '@travetto/manifest'; | ||
@@ -15,3 +16,3 @@ /** | ||
static registerCleanup(scope: string): void { | ||
ShutdownManager.onShutdown(`test.${scope}.bufferOutput`, () => TimeUtil.wait(50)); | ||
ShutdownManager.onGracefulShutdown(() => timers.setTimeout(50), `test.${scope}.bufferOutput`); | ||
} | ||
@@ -41,3 +42,3 @@ | ||
static async getTestFiles(globs?: RegExp[]): Promise<IndexedFile[]> { | ||
const files = RootIndex.find({ | ||
const files = RuntimeIndex.find({ | ||
module: m => m.roles.includes('test') || m.roles.includes('std'), | ||
@@ -63,3 +64,9 @@ folder: f => f === 'test', | ||
static async getTestCount(patterns: string[]): Promise<number> { | ||
const proc = ExecUtil.spawn('npx', ['trv', 'test:count', ...patterns], { stdio: 'pipe', catchAsResult: true, env: { FORCE_COLOR: '0', NO_COLOR: '1' } }); | ||
const proc = ExecUtil.spawn('npx', ['trv', 'test:count', ...patterns], | ||
{ | ||
stdio: 'pipe', | ||
catchAsResult: true, | ||
env: { ...Env.FORCE_COLOR.export(0), ...Env.NO_COLOR.export(true) } | ||
} | ||
); | ||
const countRes = await proc.result; | ||
@@ -76,4 +83,4 @@ if (!countRes.valid) { | ||
static get tryDebugger(): boolean { | ||
return process.env.TRV_TEST_BREAK_ENTRY === '1'; | ||
return Env.TRV_TEST_BREAK_ENTRY.isTrue; | ||
} | ||
} |
import { RootRegistry, MethodSource } from '@travetto/registry'; | ||
import { WorkPool, IterableWorkSet, ManualAsyncIterator } from '@travetto/worker'; | ||
import { RootIndex } from '@travetto/manifest'; | ||
import { WorkPool, WorkQueue } from '@travetto/worker'; | ||
import { RuntimeIndex } from '@travetto/manifest'; | ||
import { ObjectUtil } from '@travetto/base'; | ||
@@ -30,4 +30,3 @@ | ||
const itr = new ManualAsyncIterator<string>(); | ||
const src = new IterableWorkSet(itr); | ||
const itr = new WorkQueue<string>(); | ||
@@ -38,11 +37,6 @@ await SuiteRegistry.init(); | ||
const consumer = new CumulativeSummaryConsumer(await TestConsumerRegistry.getInstance(format)); | ||
const pool = new WorkPool(buildStandardTestManager(consumer), { | ||
idleTimeoutMillis: 120000, | ||
min: 2, | ||
max: WorkPool.DEFAULT_SIZE | ||
}); | ||
new MethodSource(RootRegistry).on(e => { | ||
const [cls, method] = (e.prev ?? e.curr ?? []); | ||
if (!cls || RootIndex.getFunctionMetadata(cls)?.abstract) { | ||
if (!cls || RuntimeIndex.getFunctionMetadata(cls)?.abstract) { | ||
return; | ||
@@ -65,3 +59,3 @@ } | ||
classId: cls?.Ⲑid, | ||
file: RootIndex.getFunctionMetadata(cls)?.source | ||
file: RuntimeIndex.getFunctionMetadata(cls)?.source | ||
}); | ||
@@ -78,2 +72,3 @@ } | ||
if (isRunEvent(ev)) { | ||
console.debug('Manually triggered', ev); | ||
itr.add([ev.file, ev.class, ev.method].filter(x => !!x).join('#'), true); | ||
@@ -92,4 +87,12 @@ } | ||
await pool.process(src); | ||
await WorkPool.run( | ||
() => buildStandardTestManager(consumer), | ||
itr, | ||
{ | ||
idleTimeoutMillis: 120000, | ||
min: 2, | ||
max: WorkPool.DEFAULT_SIZE | ||
} | ||
); | ||
} | ||
} |
import { Class, ConcreteClass } from '@travetto/base'; | ||
import { RootIndex } from '@travetto/manifest'; | ||
import { RuntimeIndex, RuntimeContext } from '@travetto/manifest'; | ||
import { MetadataRegistry } from '@travetto/registry'; | ||
@@ -17,3 +17,3 @@ | ||
getValidClasses(): Class[] { | ||
return this.getClasses().filter(c => !RootIndex.getFunctionMetadata(c)?.abstract); | ||
return this.getClasses().filter(c => !RuntimeIndex.getFunctionMetadata(c)?.abstract); | ||
} | ||
@@ -24,5 +24,5 @@ | ||
class: cls, | ||
module: RootIndex.manifest.mainModule, | ||
module: RuntimeContext.main.name, | ||
classId: cls.Ⲑid, | ||
file: RootIndex.getFunctionMetadata(cls)!.source, | ||
file: RuntimeIndex.getFunctionMetadata(cls)!.source, | ||
tests: [], | ||
@@ -39,4 +39,4 @@ beforeAll: [], | ||
class: cls, | ||
module: RootIndex.manifest.mainModule, | ||
file: RootIndex.getFunctionMetadata(cls)!.source, | ||
module: RuntimeContext.main.name, | ||
file: RuntimeIndex.getFunctionMetadata(cls)!.source, | ||
methodName: fn.name | ||
@@ -97,3 +97,3 @@ }; | ||
const line = parseInt(clsName, 10); | ||
const suites = this.getValidClasses().filter(cls => RootIndex.getFunctionMetadata(cls)!.source === file).map(x => this.get(x)).filter(x => !x.skip); | ||
const suites = this.getValidClasses().filter(cls => RuntimeIndex.getFunctionMetadata(cls)!.source === file).map(x => this.get(x)).filter(x => !x.skip); | ||
const suite = suites.find(x => x.lines && (line >= x.lines.start && line <= x.lines.end)); | ||
@@ -120,3 +120,3 @@ | ||
.map(x => this.get(x)) | ||
.filter(x => !RootIndex.getFunctionMetadata(x.class)?.abstract); // Do not run abstract suites | ||
.filter(x => !RuntimeIndex.getFunctionMetadata(x.class)?.abstract); // Do not run abstract suites | ||
return { suites }; | ||
@@ -123,0 +123,0 @@ } |
@@ -1,5 +0,6 @@ | ||
import { createWriteStream } from 'fs'; | ||
import { createWriteStream } from 'node:fs'; | ||
import timers from 'node:timers/promises'; | ||
import { ManifestFileUtil, RootIndex } from '@travetto/manifest'; | ||
import { ConsoleManager, TimeUtil } from '@travetto/base'; | ||
import { ManifestFileUtil, RuntimeIndex } from '@travetto/manifest'; | ||
import { ConsoleManager, Env, TimeUtil } from '@travetto/base'; | ||
import { ChildCommChannel } from '@travetto/worker'; | ||
@@ -35,4 +36,4 @@ | ||
async activate(): Promise<void> { | ||
if (/\b@travetto[/]test\b/.test(process.env.DEBUG ?? '')) { | ||
const stdout = createWriteStream(ManifestFileUtil.toolPath(RootIndex, `test-worker.${process.pid}.log`), { flags: 'a' }); | ||
if (/\b@travetto[/]test\b/.test(Env.DEBUG.val ?? '')) { | ||
const stdout = createWriteStream(ManifestFileUtil.toolPath(RuntimeIndex, `test-worker.${process.pid}.log`), { flags: 'a' }); | ||
const c = new console.Console({ stdout, inspectOptions: { depth: 4, colors: false } }); | ||
@@ -52,3 +53,3 @@ ConsoleManager.set({ onLog: (ev) => c[ev.level](process.pid, ...ev.args) }); | ||
await TimeUtil.wait('10m'); | ||
await timers.setTimeout(TimeUtil.timeToMs('10m')); | ||
} | ||
@@ -55,0 +56,0 @@ |
@@ -1,3 +0,3 @@ | ||
import { RootIndex } from '@travetto/manifest'; | ||
import { ExecUtil } from '@travetto/base'; | ||
import { RuntimeIndex } from '@travetto/manifest'; | ||
import { Env, ExecUtil } from '@travetto/base'; | ||
import { ParentCommChannel, Worker } from '@travetto/worker'; | ||
@@ -24,7 +24,7 @@ | ||
*/ | ||
export function buildStandardTestManager(consumer: TestConsumer): () => Worker<string> { | ||
export function buildStandardTestManager(consumer: TestConsumer): Worker<string> { | ||
/** | ||
* Spawn a child | ||
*/ | ||
return () => ({ | ||
return { | ||
id: i += 1, | ||
@@ -39,12 +39,15 @@ active: true, | ||
const { module } = RootIndex.getEntry(event.file!)!; | ||
const cwd = RootIndex.getModule(module)!.sourcePath; | ||
const { module } = RuntimeIndex.getEntry(event.file!)!; | ||
const cwd = RuntimeIndex.getModule(module)!.sourcePath; | ||
const channel = new ParentCommChannel<TestEvent & { error?: Error }>( | ||
ExecUtil.fork( | ||
RootIndex.resolveFileImport('@travetto/cli/support/entry.trv'), | ||
RuntimeIndex.resolveFileImport('@travetto/cli/support/entry.trv'), | ||
['test:child'], | ||
{ | ||
cwd, | ||
env: { TRV_MANIFEST: RootIndex.getModule(module)!.outputPath, TRV_QUIET: '1' }, | ||
env: { | ||
...Env.TRV_MANIFEST.export(RuntimeIndex.getModule(module)!.outputPath), | ||
...Env.TRV_QUIET.export(true) | ||
}, | ||
stdio: ['ignore', 'ignore', 2, 'ipc'] | ||
@@ -85,3 +88,3 @@ } | ||
}, | ||
}); | ||
}; | ||
} |
@@ -1,14 +0,7 @@ | ||
import { ShutdownManager, TimeUtil } from '@travetto/base'; | ||
import timers from 'node:timers/promises'; | ||
import { Env } from '@travetto/base'; | ||
import type { RunState } from '../../src/execute/types'; | ||
declare global { | ||
// eslint-disable-next-line @typescript-eslint/no-namespace | ||
namespace NodeJS { | ||
interface ProcessEnv { | ||
TRV_TEST_DELAY?: '2s'; | ||
} | ||
} | ||
} | ||
/** | ||
@@ -24,13 +17,11 @@ * Run tests given the input state | ||
if (process.env.TRV_TEST_DELAY) { | ||
await TimeUtil.wait(process.env.TRV_TEST_DELAY); | ||
} | ||
await timers.setTimeout(Env.TRV_TEST_DELAY.time ?? 0); | ||
try { | ||
const res = await new Runner(opts).run(); | ||
return ShutdownManager.exit(res ? 0 : 1); | ||
process.exitCode = res ? 0 : 1; | ||
} catch (err) { | ||
console.error('Test Worker Failed', { error: err }); | ||
return ShutdownManager.exit(1); | ||
process.exitCode = 1; | ||
} | ||
} |
@@ -1,4 +0,4 @@ | ||
import { EventEmitter } from 'events'; | ||
import { EventEmitter } from 'node:events'; | ||
import { defineEnv, ShutdownManager } from '@travetto/base'; | ||
import { Env, ExecUtil } from '@travetto/base'; | ||
import { CliCommand } from '@travetto/cli'; | ||
@@ -11,11 +11,12 @@ | ||
EventEmitter.defaultMaxListeners = 1000; | ||
process.env.FORCE_COLOR = '0'; | ||
defineEnv({ envName: 'test' }); | ||
Env.TRV_ROLE.set('test'); | ||
Env.TRV_ENV.set('test'); | ||
Env.DEBUG.set(false); | ||
Env.FORCE_COLOR.set(false); | ||
Env.TRV_LOG_PLAIN.set(true); | ||
Env.TRV_LOG_TIME.clear(); | ||
} | ||
async main(): Promise<void> { | ||
if (process.send) { | ||
// Shutdown when ipc bridge is closed | ||
process.on('disconnect', () => ShutdownManager.execute()); | ||
} | ||
ExecUtil.exitOnDisconnect(); | ||
const { TestChildWorker } = await import('../src/worker/child.js'); | ||
@@ -22,0 +23,0 @@ return new TestChildWorker().activate(); |
import { CliCommand } from '@travetto/cli'; | ||
import { RootIndex } from '@travetto/manifest'; | ||
import { defineEnv } from '@travetto/base'; | ||
import { RuntimeIndex } from '@travetto/manifest'; | ||
import { Env } from '@travetto/base'; | ||
@@ -12,3 +12,4 @@ import { SuiteRegistry } from '../src/registry/suite'; | ||
preMain(): void { | ||
defineEnv({ debug: false, envName: 'test' }); | ||
Env.TRV_ROLE.set('test'); | ||
Env.DEBUG.set(false); | ||
} | ||
@@ -34,3 +35,3 @@ | ||
.map(c => SuiteRegistry.get(c)) | ||
.filter(c => !RootIndex.getFunctionMetadata(c.class)?.abstract) | ||
.filter(c => !RuntimeIndex.getFunctionMetadata(c.class)?.abstract) | ||
.reduce((acc, c) => acc + (c.tests?.length ?? 0), 0); | ||
@@ -37,0 +38,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { defineEnv } from '@travetto/base'; | ||
import { Env } from '@travetto/base'; | ||
import { CliCommand } from '@travetto/cli'; | ||
@@ -14,3 +14,6 @@ | ||
preMain(): void { | ||
defineEnv({ envName: 'test' }); | ||
Env.TRV_ROLE.set('test'); | ||
Env.TRV_ENV.set('test'); | ||
Env.TRV_LOG_PLAIN.set(true); | ||
Env.TRV_LOG_TIME.clear(); | ||
} | ||
@@ -17,0 +20,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { defineEnv } from '@travetto/base'; | ||
import { Env, ExecUtil } from '@travetto/base'; | ||
import { CliCommand, CliUtil } from '@travetto/cli'; | ||
@@ -16,3 +16,4 @@ | ||
preMain(): void { | ||
defineEnv({ envName: 'test', dynamic: true }); | ||
Env.TRV_ROLE.set('test'); | ||
Env.TRV_DYNAMIC.set(true); | ||
} | ||
@@ -25,6 +26,3 @@ | ||
// Quit on parent disconnect | ||
if (process.send) { | ||
process.on('disconnect', () => process.exit(0)); | ||
} | ||
ExecUtil.exitOnDisconnect(); | ||
@@ -31,0 +29,0 @@ try { |
@@ -1,6 +0,6 @@ | ||
import { EventEmitter } from 'events'; | ||
import fs from 'fs/promises'; | ||
import { EventEmitter } from 'node:events'; | ||
import fs from 'node:fs/promises'; | ||
import { path } from '@travetto/manifest'; | ||
import { defineEnv } from '@travetto/base'; | ||
import { Env } from '@travetto/base'; | ||
import { CliCommandShape, CliCommand, CliValidationError } from '@travetto/cli'; | ||
@@ -27,3 +27,7 @@ import { WorkPool } from '@travetto/worker'; | ||
EventEmitter.defaultMaxListeners = 1000; | ||
defineEnv({ envName: 'test' }); | ||
Env.TRV_ROLE.set('test'); | ||
Env.TRV_ENV.set('test'); | ||
Env.DEBUG.set(false); | ||
Env.TRV_LOG_PLAIN.set(true); | ||
Env.TRV_LOG_TIME.clear(); | ||
} | ||
@@ -30,0 +34,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
114559
53
2994
1
+ Added@travetto/base@4.1.2(transitive)
+ Added@travetto/cli@4.1.2(transitive)
+ Added@travetto/manifest@4.1.0(transitive)
+ Added@travetto/registry@4.1.2(transitive)
+ Added@travetto/schema@4.1.1(transitive)
+ Added@travetto/terminal@4.1.1(transitive)
+ Added@travetto/transformer@4.1.2(transitive)
+ Added@travetto/worker@4.1.1(transitive)
+ Added@travetto/yaml@4.1.1(transitive)
+ Added@types/debug@4.1.12(transitive)
+ Added@types/ms@0.7.34(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedms@2.1.3(transitive)
+ Addedsupports-color@7.2.0(transitive)
- Removed@travetto/base@3.4.2(transitive)
- Removed@travetto/cli@3.4.10(transitive)
- Removed@travetto/manifest@3.4.0(transitive)
- Removed@travetto/registry@3.4.2(transitive)
- Removed@travetto/schema@3.4.5(transitive)
- Removed@travetto/terminal@3.4.0(transitive)
- Removed@travetto/transformer@3.4.3(transitive)
- Removed@travetto/worker@3.4.2(transitive)
- Removed@travetto/yaml@3.4.2(transitive)
- Removed@types/source-map-support@0.5.10(transitive)
- Removedbuffer-from@1.1.2(transitive)
- Removedsource-map@0.6.1(transitive)
- Removedsource-map-support@0.5.21(transitive)
Updated@travetto/base@^4.0.0-rc.0
Updated@travetto/worker@^4.0.0-rc.0
Updated@travetto/yaml@^4.0.0-rc.0