Skip to content

Commit

Permalink
Merge pull request #65 from matepek/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
matepek authored Feb 26, 2019
2 parents c752d6c + 52fc9c2 commit aa47cee
Show file tree
Hide file tree
Showing 15 changed files with 142 additions and 110 deletions.
7 changes: 6 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": ["coenraads.bracket-pair-colorizer-2", "esbenp.prettier-vscode"],
"recommendations": [
"coenraads.bracket-pair-colorizer-2",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"eg2.vscode-npm-script"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": []
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.3.21]

### Added

- `testExplorer.sort`, so I removed my logic. If you want the old ordering set this to `byLabelWithSuitesFirst`.
- tooltip: it will show more info about the suites and tests

## [2.3.20] - 2019-02-22

### Fixed
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ and [Google Test](https://github.com/google/googletest) tests using the
| `testExplorer.codeLens` | Show a CodeLens above each test or suite for running or debugging the tests. [Details](https://github.com/hbenl/vscode-test-explorer#configuration) |
| `testExplorer.onStart` | Retire or reset all test states whenever a test run is started. [Details](https://github.com/hbenl/vscode-test-explorer#configuration) |
| `testExplorer.onReload` | Retire or reset all test states whenever the test tree is reloaded. [Details](https://github.com/hbenl/vscode-test-explorer#configuration) |
| `testExplorer.sort` | Sort the tests and suites by label or location. If this is not set (or set to null), they will be shown in the order that they were received from the adapter |

**Note** that this extension is built upon the Test Explorer
so it's [configuration](https://github.com/hbenl/vscode-test-explorer#configuration) and [commands](https://github.com/hbenl/vscode-test-explorer#commands) can be used.

### catch2TestExplorer.executables

Expand Down
36 changes: 18 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"dependencies": {
"entities": "^1.1.2",
"tslib": "^1.9.3",
"vscode-test-adapter-api": "^1.3.0",
"vscode-test-adapter-api": "^1.4.0",
"vscode-test-adapter-util": "^0.6.3",
"xml2js": "^0.4.19"
},
Expand All @@ -58,12 +58,12 @@
"@types/entities": "^1.1.1",
"@types/fs-extra": "^5.0.5",
"@types/mocha": "^5.2.6",
"@types/node": "^10.12.26",
"@types/node": "^10.12.27",
"@types/request-promise": "4.1.42",
"@types/sinon": "^5.0.7",
"@types/xml2js": "^0.4.3",
"@typescript-eslint/eslint-plugin": "^1.4.0",
"@typescript-eslint/parser": "^1.4.0",
"@typescript-eslint/eslint-plugin": "^1.4.2",
"@typescript-eslint/parser": "^1.4.2",
"deep-equal": "^1.0.1",
"eslint": "^5.14.1",
"eslint-config-prettier": "^4.0.0",
Expand Down
2 changes: 2 additions & 0 deletions src/AbstractTestInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export abstract class AbstractTestInfo implements TestInfo {
public readonly type: 'test' = 'test';
public readonly id: string;
public readonly origLabel: string;
public readonly tooltip: string;

protected constructor(
protected readonly _shared: SharedVariables,
Expand All @@ -26,6 +27,7 @@ export abstract class AbstractTestInfo implements TestInfo {
) {
this.id = id ? id : generateUniqueId();
this.origLabel = label;
this.tooltip = testNameFull;
if (line && line < 0) throw Error('line smaller than zero');
}

Expand Down
9 changes: 6 additions & 3 deletions src/AbstractTestSuiteInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export abstract class AbstractTestSuiteInfo extends AbstractTestSuiteInfoBase {
public readonly execPath: string,
public readonly execOptions: c2fs.SpawnOptions,
) {
super(shared, origLabel);
super(shared, origLabel, undefined, execPath);
}

abstract reloadChildren(): Promise<void>;
Expand Down Expand Up @@ -93,11 +93,14 @@ export abstract class AbstractTestSuiteInfo extends AbstractTestSuiteInfoBase {
this.sendSkippedChildrenEvents();
}

const runInfo = new RunningTestExecutableInfo(cp.spawn(this.execPath, execParams, this.execOptions), childrenToRun);
const execOptions = Object.assign({}, this.execOptions);
execOptions.env = Object.assign({}, Object.assign(process.env, execOptions.env));

const runInfo = new RunningTestExecutableInfo(cp.spawn(this.execPath, execParams, execOptions), childrenToRun);

this._runInfo = runInfo;

this._shared.log.info('proc started:', this.origLabel, this.execPath, execParams, this.execOptions.cwd);
this._shared.log.info('proc started:', this.origLabel, this.execPath, execParams, this.execOptions);

runInfo.process.on('error', (err: Error) => {
this._shared.log.error('process error event:', err, this);
Expand Down
19 changes: 10 additions & 9 deletions src/AbstractTestSuiteInfoBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ export abstract class AbstractTestSuiteInfoBase implements TestSuiteInfo {
public children: (AbstractTestSuiteInfoBase | AbstractTestInfo)[] = [];
public file?: string;
public line?: number;

public constructor(protected readonly _shared: SharedVariables, public readonly origLabel: string, id?: string) {
public tooltip?: string;

public constructor(
protected readonly _shared: SharedVariables,
public readonly origLabel: string,
id: string | undefined,
tooltip?: string,
) {
this.label = origLabel;
this.id = id ? id : generateUniqueId();
this.tooltip = tooltip;
}

public sendSkippedChildrenEvents(): void {
Expand Down Expand Up @@ -55,13 +62,7 @@ export abstract class AbstractTestSuiteInfoBase implements TestSuiteInfo {
this.line = undefined;
}

let i = this.children.findIndex((v: AbstractTestSuiteInfoBase | AbstractTestInfo) => {
return child.origLabel.localeCompare(v.origLabel) < 0;
});

if (i == -1) i = this.children.length;

this.children.splice(i, 0, child);
this.children.push(child);
}

public findRouteToTestById(id: string): (AbstractTestSuiteInfoBase | AbstractTestInfo)[] | undefined {
Expand Down
35 changes: 28 additions & 7 deletions src/Catch2TestSuiteInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,33 @@ export class Catch2TestSuiteInfo extends AbstractTestSuiteInfo {

while (lines.length > 0 && lines[lines.length - 1].trim() === '') lines.pop();

if (lines.length == 0) throw Error('Wrong test list.');

// first line: 'Matching test cases:'
for (let i = 1; i < lines.length - 1; ) {
if (lines[i][0] != ' ') this._shared.log.error('Wrong test list output format: ' + lines.toString());

lines.shift(); // first line: 'Matching test cases:'
lines.pop(); // last line: '[0-9]+ matching test cases'

for (let i = 0; i < lines.length; ) {
if (!lines[i].startsWith(' ')) this._shared.log.error('Wrong test list output format: ' + lines.toString());

if (lines[i].startsWith(' ')) {
this._shared.log.warn('Probably too long test name: ' + lines);
this.children = [];
const test = this._createCatch2TestInfo(
undefined,
'⚠️ Check the test output message for details ⚠️',
'',
[],
'',
0,
);
this._shared.sendTestEventEmitter.fire([
{
type: 'test',
test: test,
state: 'errored',
message: '⚠️ Probably too long test name!\n🛠 Try to define: #define CATCH_CONFIG_CONSOLE_WIDTH 300)',
},
]);
return;
}
const testNameFull = lines[i++].substr(2);

let filePath = '';
Expand All @@ -101,7 +122,7 @@ export class Catch2TestSuiteInfo extends AbstractTestSuiteInfo {
if (description.startsWith('(NO DESCRIPTION)')) description = '';

let tags: string[] = [];
if (lines[i].length > 6 && lines[i][6] === '[') {
if (i < lines.length && lines[i].length > 6 && lines[i][6] === '[') {
tags = lines[i].trim().split(']');
tags.pop();
for (let j = 0; j < tags.length; ++j) tags[j] += ']';
Expand Down
2 changes: 1 addition & 1 deletion src/RootTestSuiteInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class RootTestSuiteInfo extends AbstractTestSuiteInfoBase implements vsco
private readonly _taskPool: TaskPool;

public constructor(shared: SharedVariables, workerMaxNumber: number) {
super(shared, 'Catch2 and Google tests');
super(shared, 'Catch2 and Google tests', undefined);
this._taskPool = new TaskPool(workerMaxNumber);
}

Expand Down
8 changes: 1 addition & 7 deletions src/TaskPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@ export class TaskPool {
else this._waitingTasks.push(resolve);
}).then(task);

const release = (): void => {
this._release();
};

p.then(release, release);

return p;
return p.finally(() => this._release());
}

private _runningTaskCount: number = 0;
Expand Down
16 changes: 6 additions & 10 deletions src/TaskQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,18 @@ export class TaskQueue {
public then<TResult1>(task: () => TResult1 | PromiseLike<TResult1>): Promise<TResult1> {
this._count++;

const depends: Promise<void>[] = [];
const depends: Promise<any>[] = []; //eslint-disable-line
depends[this._depends.length] = this._queue;

for (let i = 0; i < this._depends.length; ++i) {
depends[i] = this._depends[i]._queue;
}

const current = Promise.all(depends).then(task);
this._queue = Promise.all(depends)
.then(task)
.finally(() => this._count--);

const decr = (): void => {
this._count--;
};

this._queue = current.then(decr, decr);

return current;
return this._queue;
}

public dependsOn(depends: Iterable<TaskQueue>): void {
Expand All @@ -53,7 +49,7 @@ export class TaskQueue {
}

private _count: number = 0;
private _queue: Promise<void> = Promise.resolve();
private _queue: Promise<any> = Promise.resolve(); //eslint-disable-line
private readonly _depends: TaskQueue[] = [];

private _checkCircle(tq: TaskQueue): void {
Expand Down
1 change: 0 additions & 1 deletion src/TestExecutableInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ export class TestExecutableInfo implements vscode.Disposable {

let resolvedEnv: { [prop: string]: string } = {};
try {
Object.assign(resolvedEnv, process.env);
Object.assign(resolvedEnv, this._defaultEnv);

if (this._env) Object.assign(resolvedEnv, this._env);
Expand Down
6 changes: 3 additions & 3 deletions src/test/TestCatch2FrameworkLoad.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import * as vscode from 'vscode';
import * as sinon from 'sinon';
import {
TestEvent,
TestLoadFinishedEvent,
TestRunFinishedEvent,
TestRunStartedEvent,
TestSuiteEvent,
Expand Down Expand Up @@ -977,9 +976,9 @@ describe(path.basename(__filename), function() {
await adapter.load();

assert.equal(adapter.testLoadsEvents.length, 2);
root = (adapter.testLoadsEvents[adapter.testLoadsEvents.length - 1] as TestLoadFinishedEvent).suite!;
root = adapter.root;
assert.equal(root.children.length, 2);
suite1 = root.children[0] as TestSuiteInfo;
suite1 = adapter.suite1;

assert.strictEqual(suite1.children.length, 0);

Expand Down Expand Up @@ -1358,6 +1357,7 @@ describe(path.basename(__filename), function() {
});

it('run suite3 one-by-one', async function() {
this.timeout(5000);
await loadAdapter();
assert.equal(root.children.length, 3);
assert.equal(root.children[0].type, 'suite');
Expand Down
Loading

0 comments on commit aa47cee

Please sign in to comment.