Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide detailed failure output in scripts/fiber/record-tests #8214

Merged
merged 1 commit into from
Nov 7, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
83 changes: 63 additions & 20 deletions scripts/fiber/record-tests
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env node

'use strict';

const crypto = require('crypto');
const fs = require('fs');
const os = require('os');
const path = require('path');
Expand All @@ -14,9 +17,39 @@ const argv = {};
const root = path.normalize(path.join(__dirname, '..', '..'));
const testPathPattern = '';

function wrapRunnerFile(runnerPath) {
const filename = path.join(
os.tmpdir(),
'test-runner-' + crypto.randomBytes(8).toString('hex') + '.js'
);
fs.writeFileSync(
filename,
`
'use strict';
var wrap = require(${JSON.stringify(__filename)}).wrapRunner;
var original = require(${JSON.stringify(runnerPath)});
module.exports = wrap(original);
`
);
return filename;
}

function wrapRunner(original) {
return function runner(config, environment, runtime, testPath) {
return original(config, environment, runtime, testPath)
.then((results) => {
results.failureMessage = null;
return results;
});
};
}

function runJest() {
return readConfig(argv, root)
.then((config) => {
config = Object.assign({}, config, {
testRunner: wrapRunnerFile(config.testRunner),
});
return createHasteContext(config, {}).then((hasteMap) => {
const source = new SearchSource(hasteMap, config);
return source.getTestPaths({testPathPattern})
Expand Down Expand Up @@ -51,23 +84,33 @@ function formatResults(runResults, predicate) {
return formatted.join('\n\n');
}

process.env.REACT_DOM_JEST_USE_FIBER = true;
runJest()
.then((runResults) => {
const passing = formatResults(
runResults,
(file, test) => test.status === 'passed'
);
const failing = formatResults(
runResults,
(file, test) => test.status === 'failed'
);
fs.writeFileSync(
path.join(__dirname, 'tests-passing.txt'),
passing + '\n'
);
fs.writeFileSync(
path.join(__dirname, 'tests-failing.txt'),
failing + '\n'
);
});
function recordTests() {
process.env.REACT_DOM_JEST_USE_FIBER = true;
runJest()
.then((runResults) => {
const passing = formatResults(
runResults,
(file, test) => test.status === 'passed'
);
const failing = formatResults(
runResults,
(file, test) => test.status === 'failed'
);
fs.writeFileSync(
path.join(__dirname, 'tests-passing.txt'),
passing + '\n'
);
fs.writeFileSync(
path.join(__dirname, 'tests-failing.txt'),
failing + '\n'
);
});
}

if (require.main === module) {
recordTests();
}

module.exports = {
wrapRunner,
};