Skip to content

Commit

Permalink
Merge remote-tracking branch 'home/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
SizaSL committed Aug 22, 2021
2 parents 550e07a + 2d2d7b2 commit de7d8ce
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

## [3.7.0] - 2021-08-21

Feature Added: CppUTest Framework Support with tests

## [3.6.27] - 2021-08-09

NPM update
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# C++ TestMate

## A **Catch2**, **GoogleTest**, **doctest** and **GoogleBenchmark** Explorer for VSCode
## A **Catch2**, **GoogleTest**, **CppUTest**, **doctest** and **GoogleBenchmark** Explorer for VSCode

[![Visual Studio Marketplace](https://img.shields.io/vscode-marketplace/v/matepek.vscode-catch2-test-adapter.svg)](https://marketplace.visualstudio.com/items?itemName=matepek.vscode-catch2-test-adapter)
[![GitHub issues](https://img.shields.io/github/issues/matepek/vscode-catch2-test-adapter?color=green)](https://github.com/matepek/vscode-catch2-test-adapter/issues)
[![Visual Studio Marketplace](https://img.shields.io/vscode-marketplace/d/matepek.vscode-catch2-test-adapter.svg)](https://marketplace.visualstudio.com/items?itemName=matepek.vscode-catch2-test-adapter)
[![Gitter](https://badges.gitter.im/CppTestMate/community.svg)](https://gitter.im/CppTestMate/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

This extension allows you to run your [Catch2](https://github.com/catchorg/Catch2),
[Google Test](https://github.com/google/googletest)
and [DOCtest](https://github.com/onqtam/doctest)
[Google Test](https://github.com/google/googletest), [CppUTest](https://github.com/cpputest/cpputest) and [DOCtest](https://github.com/onqtam/doctest)
tests using the [Test Explorer for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-test-explorer).
It also have basic support for [Google Benchmark](https://github.com/google/benchmark).

Expand Down
5 changes: 5 additions & 0 deletions documents/configuration/test.advancedExecutables.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ If it is an object it can contains the following properties:
| `gtest` | Object with framework specific settings. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#framework-specific-settings) |
| `doctest` | Object with framework specific settings. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#framework-specific-settings) |
| `gbenchmark` | Object with framework specific settings. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#framework-specific-settings) |
| `cpputest` | Object with framework specific settings. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#framework-specific-settings) |

The `pattern` (or the `executables` used as string or an array of strings)
can contain [_search-pattern_](https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options).
Expand Down Expand Up @@ -246,6 +247,10 @@ For example:

- `Catch v2.11.1` + `/Catch v(\d+)\.(\d+)\.(\d+)\s?/` -> `[2, 11, 1]`

In case of `cpputest` the helpRegex can be as following.

- `[-g|sg|xg|xsg groupName]... [-n|sn|xn|xsn testName]...`

### ignoreTestEnumerationStdErr

As the name says test enumeraton will ignore std::err output.
Expand Down
2 changes: 1 addition & 1 deletion src/framework/CppUTestRunnable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class CppUTestRunnable extends AbstractRunnable {
}

private getTestGrouping(): TestGrouping {
// TODO: Reconsider grouping
// TODO: Consider grouping based on passed/failed
if (this.properties.testGrouping) {
return this.properties.testGrouping;
} else {
Expand Down
4 changes: 3 additions & 1 deletion src/framework/CppUTestTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export class CppUTestTest extends AbstractTest {
if (lines.length > 1 && failedTest !== null) {
const filePath = failedTest[2].split('/').pop();
const lineNumber = Number(failedTest[3]) - 1;
eventBuilder.appendDecorator(filePath, lineNumber, [lines[3], lines[4]]);
const expected = lines.find(value => /^\texpected/.test(value));
const actual = lines.find(value => /^\tbut was/.test(value));
eventBuilder.appendDecorator(filePath, lineNumber, [expected ? expected : '', actual ? actual : '']);
}

const event = eventBuilder.build(output.replace(/\): error: /g, '): error: \n'));
Expand Down
45 changes: 42 additions & 3 deletions test/framework/CppUTestTest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ describe(path.basename(__filename), function () {
'TEST(UtestShell, PassedCheckEqualWillIncreaseTheAmountOfChecks)',
'/workspaces/cpputest-4.0/tests/CppUTest/UtestTest.cpp:90: error: Failure in TEST(UtestShell, PassedCheckEqualWillIncreaseTheAmountOfChecks)',
'LONGS_EQUAL(10, fixture.getCheckCount()) failed',
'expected <10 (0xa)>',
'but was < 1 (0x1)>',
'\texpected <10 (0xa)>',
'\tbut was < 1 (0x1)>',
' - 47 ms',
].join(EOL);

Expand All @@ -43,7 +43,7 @@ describe(path.basename(__filename), function () {
decorations: [
{
file: 'UtestTest.cpp',
hover: 'expected <10 (0xa)>\nbut was < 1 (0x1)>',
hover: '\texpected <10 (0xa)>\n\tbut was < 1 (0x1)>',
line: 89,
message: '⬅ expected <10 (0xa)>; but was < 1 (0x1)>',
},
Expand All @@ -57,6 +57,45 @@ describe(path.basename(__filename), function () {
assert.deepStrictEqual(cpputest.lastRunEvent, expected);
});

it('parses another failed test', function () {
const output = [
'TEST(read_rssi, min_rssi_with_min_gain)',
'/workspaces/cpputest-4.0/tests/CppUTest/test_read_rssi.cpp:176: error: Failure in TEST(read_rssi, min_rssi_with_min_gain)',
'\texpected <-1984>',
'\tbut was <-1987>',
'difference starts at position 4 at: < -1987 >',
' ^',
'',
'- 47 ms',
].join(EOL);

const ev = cpputest.parseAndProcessTestCase('runid', output, 42, null, '');

const expected: TestRunEvent = {
testRunId: 'runid',
type: 'test',
test: cpputest.id,
message: output,
state: 'failed',
description: '(47ms)',
tooltip: 'Name: TestCase.TestName\n⏱Duration: 47ms',
decorations: [
{
file: 'test_read_rssi.cpp',
hover: '\texpected <-1984>\n\tbut was <-1987>',
line: 175,
message: '⬅ expected <-1984>; but was <-1987>',
},
],
};

assert.strictEqual(cpputest.description, ev.description);
assert.strictEqual(cpputest.tooltip, ev.tooltip);
assert.strictEqual(cpputest.lastRunMilisec, 47);
assert.deepStrictEqual(ev, expected);
assert.deepStrictEqual(cpputest.lastRunEvent, expected);
});

it('parses passed test', function () {
const output = ['TEST(UtestShell, compareDoubles) - 30 ms'].join(EOL);

Expand Down

0 comments on commit de7d8ce

Please sign in to comment.