{"size": 738, "ext": "js", "max_stars_repo_path": "tests/testhelper.js", "max_stars_repo_name": "grmartin/jsontabulate", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tests/testhelper.js", "max_issues_repo_name": "grmartin/jsontabulate", "max_issues_repo_issues_event_min_datetime": "2021-05-11T16:30:49.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-11T16:30:49.000Z", "max_forks_repo_path": "tests/testhelper.js", "max_forks_repo_name": "grmartin/jsontabulate", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 23.8064516129, "max_line_length": 83, "alphanum_fraction": 0.5921409214}
const path = require('path');

const {EXIT_SUCCESS, main_test_fn} = require('../run');

const filePath = (inPath) => path.resolve(__dirname, inPath)
const dataFile = (inPath) => path.resolve(filePath('data'), inPath)

const covExec = (args) => {
    let retVal = undefined;

    const oldConsole = global.console;
    let buffer = [];
    let retCode = EXIT_SUCCESS;
    const falseConsole = {
        log: (x) => {
            buffer.push(x);
        }
    };

    try {
        retVal = main_test_fn([...args], {exit: (x) => retCode = x}, falseConsole);
    } finally {
        global.console = oldConsole;
    }

    return {retVal, buffer:buffer.join("\n"), code: retCode};
}

module.exports = { exec: covExec, filePath, dataFile };

