Skip to content

Commit

Permalink
rename live result interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
kainino0x committed Jul 8, 2019
1 parent 3861f01 commit 08a2a2b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
26 changes: 13 additions & 13 deletions src/framework/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { TestSpecID } from './id.js';
import { makeQueryString } from './url_query.js';

type Status = 'running' | 'pass' | 'warn' | 'fail';
interface TestLiveResult {
interface LiveTestRunResult {
spec: string;
cases: TestCaseLiveResult[];
cases: LiveTestCaseResult[];
}

export interface TestCaseLiveResult {
export interface LiveTestCaseResult {
name: string;
params: ParamsSpec | null;
status: Status;
Expand All @@ -19,13 +19,13 @@ export interface TestCaseLiveResult {
}

export class Logger {
readonly results: TestLiveResult[] = [];
readonly results: LiveTestRunResult[] = [];

constructor() {}

record(spec: TestSpecID): [GroupRecorder, TestLiveResult] {
const cases: TestCaseLiveResult[] = [];
const result: TestLiveResult = { spec: makeQueryString(spec), cases };
record(spec: TestSpecID): [GroupRecorder, LiveTestRunResult] {
const cases: LiveTestCaseResult[] = [];
const result: LiveTestRunResult = { spec: makeQueryString(spec), cases };
this.results.push(result);
return [new GroupRecorder(result), result];
}
Expand All @@ -36,27 +36,27 @@ export class Logger {
}

export class GroupRecorder {
private test: TestLiveResult;
private test: LiveTestRunResult;

constructor(test: TestLiveResult) {
constructor(test: LiveTestRunResult) {
this.test = test;
}

record(name: string, params: ParamsSpec | null): [CaseRecorder, TestCaseLiveResult] {
const result: TestCaseLiveResult = { name, params, status: 'running', timems: -1 };
record(name: string, params: ParamsSpec | null): [CaseRecorder, LiveTestCaseResult] {
const result: LiveTestCaseResult = { name, params, status: 'running', timems: -1 };
this.test.cases.push(result);
return [new CaseRecorder(result), result];
}
}

export class CaseRecorder {
private result: TestCaseLiveResult;
private result: LiveTestCaseResult;
private failed = false;
private warned = false;
private startTime = -1;
private logs: string[] = [];

constructor(result: TestCaseLiveResult) {
constructor(result: LiveTestCaseResult) {
this.result = result;
}

Expand Down
6 changes: 3 additions & 3 deletions src/framework/test_group.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { CaseRecorder, GroupRecorder, TestCaseLiveResult } from './logger.js';
import { CaseRecorder, GroupRecorder, LiveTestCaseResult } from './logger.js';
import { ParamsAny, ParamSpecIterable, paramsEquals } from './params/index.js';
import { Fixture } from './fixture.js';
import { allowedTestNameCharacters } from './allowed_characters.js';
import { TestCaseID } from './id.js';

export interface RunCase {
readonly id: TestCaseID;
run(): Promise<TestCaseLiveResult>;
run(): Promise<LiveTestCaseResult>;
}

export interface RunCaseIterable {
Expand Down Expand Up @@ -108,7 +108,7 @@ class RunCaseSpecific<F extends Fixture> implements RunCase {
this.fn = fn;
}

async run(): Promise<TestCaseLiveResult> {
async run(): Promise<LiveTestCaseResult> {
const [rec, res] = this.recorder.record(this.id.name, this.id.params);
rec.start();
try {
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/cmdline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as fs from 'fs';
import * as process from 'process';

import { TestSpecFile, TestLoader } from '../framework/loader.js';
import { Logger, TestCaseLiveResult } from '../framework/logger.js';
import { Logger, LiveTestCaseResult } from '../framework/logger.js';
import { TestSpecID } from '../framework/id.js';
import { makeQueryString } from '../framework/url_query.js';

Expand Down Expand Up @@ -48,8 +48,8 @@ for (const a of process.argv.slice(2)) {
Array.from(listing, ({ id, spec }) => spec.then((s: TestSpecFile) => ({ id, spec: s })))
);

const failed: Array<[TestSpecID, TestCaseLiveResult]> = [];
const warned: Array<[TestSpecID, TestCaseLiveResult]> = [];
const failed: Array<[TestSpecID, LiveTestCaseResult]> = [];
const warned: Array<[TestSpecID, LiveTestCaseResult]> = [];

// TODO: don't run all tests all at once
const running = [];
Expand Down

0 comments on commit 08a2a2b

Please sign in to comment.