~endlessm/jasmine-gjs/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env gjs

const {GLib} = imports.gi;
const System = imports.system;

let runnerPath = '@pkglibexecdir@/jasmine-runner';
if (GLib.getenv('JASMINE_UNINSTALLED')) {
    // Trick to use the uninstalled copy of Jasmine when running "make check".
    const srcdir = GLib.getenv('SRCDIR');
    imports.searchPath.unshift(GLib.build_filenamev([srcdir, 'src']));
    const builddir = GLib.getenv('BUILDDIR');
    runnerPath = GLib.build_filenamev([builddir, 'jasmine-runner']);
} else {
    imports.searchPath.unshift('@datadir@/jasmine-gjs');
}

const Config = imports.config;
const Options = imports.options;

const [files, options] = Options.parseOptions(ARGV);

if (options.version) {
    print('Jasmine @PACKAGE_VERSION@');
    System.exit(0);
}

const config = Config.loadConfig(options);

// Launch Jasmine in a subprocess so we can control the environment
const launcher = Config.prepareLauncher(config, options);
let args = Config.configToArgs(config, files, options);
args.unshift(runnerPath);  // argv[0]
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;
})();