Sha256: 4cbe2ad1853cae4b27d197df5e073b6cb6110c8c082e974aed7a2d481550be51

Contents?: true

Size: 1.49 KB

Versions: 11

Compression:

Stored size: 1.49 KB

Contents

const fs = require("fs");
const fmt = require("simple-fmt");
const exec = require("child_process").exec;
const diff = require("diff");

function slurp(filename) {
    return fs.existsSync(filename) ? String(fs.readFileSync(filename)) : "";
}

const pathToTests = (fs.existsSync("tests") ? "tests" : "../../tests");

const tests = fs.readdirSync(pathToTests).filter(function(filename) {
    return !/-out\.js$/.test(filename) && !/-stderr$/.test(filename);
});

function run(test) {
    function diffOutput(correct, got, name) {
        if (got !== correct) {
            const patch = diff.createPatch(name, correct, got);
            process.stdout.write(patch);
            process.stdout.write("\n\n");
        }
    }

    const noSuffix = test.slice(0, -3);
    exec(fmt("{0} {1} defs-cmd {2}/{3}", NODE, FLAG, pathToTests, test), function(error, stdout, stderr) {
        stderr = stderr || "";
        stdout = stdout || "";
        const expectedStderr = slurp(fmt("{0}/{1}-stderr", pathToTests, noSuffix));
        const expectedStdout = slurp(fmt("{0}/{1}-out.js", pathToTests, noSuffix));

        const pass = (stderr === expectedStderr && stdout === expectedStdout);

        if (!pass) {
            console.log(fmt("FAILED test {0}", test));
        }
        diffOutput(expectedStdout, stdout, fmt("{0}-out.js", test));
        diffOutput(expectedStderr, stderr, fmt("{0}-stderr", test));
    });
}

const NODE = process.argv[0];
const FLAG = (process.argv[2] === "es5" ? "" : "--harmony");
tests.forEach(run);

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
ilog-0.4.1 node_modules/defs/run-tests.js
ilog-0.4.0 node_modules/defs/run-tests.js
ilog-0.3.3 node_modules/defs/run-tests.js
xcodebuild-helper-1.2.5 externals/ios-sim-master/node_modules/defs/run-tests.js
xcodebuild-helper-1.2.3 externals/ios-sim-master/node_modules/defs/run-tests.js
es6_tilt-0.1.2 test/dummy/app/assets/javascripts/node_modules/defs/run-tests.js
es6_tilt-0.1.1 test/dummy/app/assets/javascripts/node_modules/defs/run-tests.js
es6_tilt-0.1.0 test/dummy/app/assets/javascripts/node_modules/defs/run-tests.js
gulp_assets-1.0.0.pre.5 template/node_modules/babel-core/node_modules/regenerator/node_modules/defs/run-tests.js
gulp_assets-1.0.0.pre.4 template/node_modules/babel-core/node_modules/regenerator/node_modules/defs/run-tests.js
gulp_assets-1.0.0.pre.3 template/node_modules/babel-core/node_modules/regenerator/node_modules/defs/run-tests.js