Skip to content

Commit

Permalink
Increase support for non-QtTest TAP files #2
Browse files Browse the repository at this point in the history
  • Loading branch information
pcolby committed Feb 11, 2024
1 parent ac6582c commit 45ac521
Show file tree
Hide file tree
Showing 12 changed files with 615 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/expected/default.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
| Test result | Passed | Failed | Skipped | Test name |
|:------------------------|-------:|-------:|--------:|:-------------------------|
| :heavy_check_mark: pass | 2618 | 0 | 182 | TestAbstractCommand |
| :heavy_check_mark: pass | 2800 | 0 | 182 | TestAbstractCommand |
| :heavy_check_mark: pass | 1092 | 0 | 0 | TestAbstractPokitService |
| :heavy_check_mark: pass | 126 | 0 | 0 | TestCalibrateCommand |
| :heavy_check_mark: pass | 420 | 0 | 0 | TestCalibrationService |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/expected/path.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
| Test result | Passed | Failed | Skipped | Test name |
|:------------------------|-------:|-------:|--------:|:-------------------------|
| :heavy_check_mark: pass | 90 | 0 | 26 | TestAbstractCommand |
| :heavy_check_mark: pass | 116 | 0 | 26 | TestAbstractCommand |
| :heavy_check_mark: pass | 52 | 0 | 0 | TestAbstractPokitService |
| :heavy_check_mark: pass | 6 | 0 | 0 | TestCalibrateCommand |
| :heavy_check_mark: pass | 20 | 0 | 0 | TestCalibrationService |
Expand Down
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [1.1.0] (2024-02-11)

### Changed

- Increased support for non-QtTest (but still valid) TAP files ([#12][])

### Fixed

- Total 'pass' count was incorrectly deducting 'skip' count.

## [1.0.1] (2023-03-29)

Expand All @@ -20,7 +28,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support for summarising [Qt Test] [TAP] files.
- Automated tests on all supported GitHub-hosted runners (`macos-*`, `ubuntu-*` and `windows-*`).

[unreleased]: https://github.com/pcolby/tap-summary/compare/v1.0.1...HEAD
[unreleased]: https://github.com/pcolby/tap-summary/compare/v1.1.0...HEAD
[1.1.0]: https://github.com/pcolby/tap-summary/releases/tag/v1.1.0
[1.0.1]: https://github.com/pcolby/tap-summary/releases/tag/v1.0.1
[1.0.0]: https://github.com/pcolby/tap-summary/releases/tag/v1.0.0

Expand Down
40 changes: 28 additions & 12 deletions summary.gawk
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,40 @@ BEGIN {
maxNameLength = 0
}

FNR==2 {
testName = $2
# Reset the test name at the beginning of each TAP file.
BEGINFILE {
testName=""
}

# If we have test results, and no test name yet, default to the current TAP file name.
/^(not )?ok .*/ && !testName {
setTestName(FILENAME)
}

# QtTest sets the test name on the second line of the TAP file.
FNR==2 && NF==2 && $1=="#" {
setTestName($2)
}

function setTestName(name) {
testName=name
if (length(testName) > maxNameLength)
maxNameLength = length(testName)
if (!(testName in tests)) {
tests[testName]["skip"] = 0
tests[testName]["pass"] = 0
tests[testName]["fail"] = 0
}
}

/^ok .*[^\\]#\s*SKIP/{
# Handle skipped tests.
/^ok .*[^\\]#\s*SKIP/ {
tests[testName]["skip"]++
}

/^#\s*(pass|fail)\s+[0-9]+$/ {
tests[testName][$2] += $3
# Handle passed (but not skipped) tests.
/^ok / && !/^ok .*[^\\]#\s*SKIP/ {
tests[testName]["pass"]++
}

# Handle failed tests.
/^not ok / {
tests[testName]["fail"]++
}

END {
Expand All @@ -45,8 +62,7 @@ END {
printf "| %-18s %4s | %6u | %6u | %7u | %-*s |\n",
(tests[name]["fail"]) ? ":x:" : ":heavy_check_mark:",
(tests[name]["fail"]) ? "fail" : "pass",
tests[name]["pass"] - tests[name]["skip"],
tests[name]["fail"], tests[name]["skip"],
tests[name]["pass"], tests[name]["fail"], tests[name]["skip"],
maxNameLength, name
}
}
6 changes: 6 additions & 0 deletions test/buzztrax-7856445010/bml.log.tap
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ok 1 - tests/lib/bml/e-core.c:BmlCoreExamples:test_bml_setup: Passed
ok 2 - tests/lib/bml/e-core.c:BmlCoreExamples:test_bml_finalize: Passed
ok 3 - tests/lib/bml/e-core.c:BmlCoreExamples:test_bmln_master_info: Passed
ok 4 - tests/lib/bml/e-core.c:BmlCoreExamples:test_bmln_open: Passed
ok 5 - tests/lib/bml/e-class.c:BmlClassExamples:test_bmln_get_machine_info: Passed
1..5
7 changes: 7 additions & 0 deletions test/buzztrax-7856445010/bt_cmd.log.tap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ok 1 - tests/ui/cmd/e-cmd-application.c:BtCmdApplicationExamples:test_bt_cmd_application_create: Passed
ok 2 - tests/ui/cmd/e-cmd-application.c:BtCmdApplicationExamples:test_bt_cmd_application_play: Passed
ok 3 - tests/ui/cmd/e-cmd-application.c:BtCmdApplicationExamples:test_bt_cmd_application_play_two_files: Passed
ok 4 - tests/ui/cmd/e-cmd-application.c:BtCmdApplicationExamples:test_bt_cmd_application_play_incomplete_file: Passed
ok 5 - tests/ui/cmd/e-cmd-application.c:BtCmdApplicationExamples:test_bt_cmd_application_info: Passed
ok 6 - tests/ui/cmd/e-cmd-application.c:BtCmdApplicationExamples:test_bt_cmd_application_info_for_incomplete_file: Passed
1..6
Loading

0 comments on commit 45ac521

Please sign in to comment.