Skip to content

Commit

Permalink
bin: Fix exit code propagation
Browse files Browse the repository at this point in the history
Now that we're loading entrypoints as modules, exit codes
no longer propagate  in the same way. Therefore, we  must
do that explicitly through the system exit function.

Without this the exit code is always  ZERO and in practical
terms all CI pipelines depending on this are always passing
even when the tests are actually failing.

See 7825a0c.
  • Loading branch information
tchx84 authored and ptomato committed Apr 10, 2024
1 parent c6aa28b commit f6a42db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions bin/jasmine-runner.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* global jasmineImporter */

import GLib from 'gi://GLib';
import System from 'system';

const pkgdatadir = GLib.getenv('TEST_PKGDATADIR') ?? '@pkgdatadir@';
const jasmineMod = GLib.getenv('TEST_JASMINE_MOD') ?? '@jasmine_mod@';
Expand Down Expand Up @@ -30,5 +31,4 @@ const JasmineBoot = await import(`${base}/jasmineBoot.js`);
const _jasmine = new JasmineBoot.Jasmine();
_jasmine.installAPI(globalThis);

// Don't put any code after this; the return value is used as the exit code.
await Command.run(_jasmine, ARGV, 10);
System.exit(await Command.run(_jasmine, ARGV, 10));
12 changes: 5 additions & 7 deletions bin/jasmine.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S gjs -m

import GLib from 'gi://GLib';
import * as System from 'system';
import System from 'system';

const pkglibexecdir = GLib.getenv('TEST_PKGLIBEXECDIR') ?? '@pkglibexecdir@';
const pkgdatadir = GLib.getenv('TEST_PKGDATADIR') ?? '@pkgdatadir@';
Expand Down Expand Up @@ -29,9 +29,7 @@ args = Config.wrapArgs(args, config, options);
const process = launcher.spawnv(args);
process.wait(null);

// Don't put any code after this; the return value is used as the exit code.
(function () {
if (process.get_if_exited())
return process.get_exit_status();
return 1;
})();
if (process.get_if_exited())
System.exit(process.get_exit_status());

System.exit(1);

0 comments on commit f6a42db

Please sign in to comment.