Skip to content

Commit

Permalink
Run 'colcon test-result' to print test failures (#794)
Browse files Browse the repository at this point in the history
Signed-off-by: Christophe Bedard <christophe.bedard@apex.ai>
  • Loading branch information
christophebedard committed Feb 16, 2023
1 parent e9721b4 commit 79e12af
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
10 changes: 9 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11337,7 +11337,6 @@ function runTests(colconCommandPrefix, options, testPackageSelection, colconExtr
`colcon`,
`test`,
`--event-handlers=console_cohesion+`,
`--return-code-on-test-failure`,
...testPackageSelection,
...colconExtraArgs,
];
Expand All @@ -11346,6 +11345,15 @@ function runTests(colconCommandPrefix, options, testPackageSelection, colconExtr
}
if (doTests) {
yield execShellCommand([...colconCommandPrefix, ...colconTestCmd], options, false);
/**
* Display all test results first and ignore the return code. Then, display only failing
* tests with their output and let non-zero return code fail the job.
*/
const colconTestResultCmd = ["colcon", "test-result"];
const colconTestResultAllCmd = [...colconTestResultCmd, "--all"];
const colconTestResultVerboseCmd = [...colconTestResultCmd, "--verbose"];
yield execShellCommand([...colconCommandPrefix, ...colconTestResultAllCmd], Object.assign(Object.assign({}, options), { ignoreReturnCode: true }), false);
yield execShellCommand([...colconCommandPrefix, ...colconTestResultVerboseCmd], options, false);
}
if (doLcovResult) {
// ignoreReturnCode, check comment above in --initial
Expand Down
22 changes: 21 additions & 1 deletion src/action-ros-ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ async function runTests(
`colcon`,
`test`,
`--event-handlers=console_cohesion+`,
`--return-code-on-test-failure`,
...testPackageSelection,
...colconExtraArgs,
];
Expand All @@ -253,6 +252,27 @@ async function runTests(
options,
false
);

/**
* Display all test results first and ignore the return code. Then, display only failing
* tests with their output and let non-zero return code fail the job.
*/
const colconTestResultCmd = ["colcon", "test-result"];
const colconTestResultAllCmd = [...colconTestResultCmd, "--all"];
const colconTestResultVerboseCmd = [...colconTestResultCmd, "--verbose"];
await execShellCommand(
[...colconCommandPrefix, ...colconTestResultAllCmd],
{
...options,
ignoreReturnCode: true,
},
false
);
await execShellCommand(
[...colconCommandPrefix, ...colconTestResultVerboseCmd],
options,
false
);
}

if (doLcovResult) {
Expand Down

0 comments on commit 79e12af

Please sign in to comment.