Skip to content

Commit

Permalink
Run fiber tests just once on Travis (#8221)
Browse files Browse the repository at this point in the history
Consolidate facts tracking with the other script.
  • Loading branch information
sophiebits authored Nov 7, 2016
1 parent c4b9330 commit 75ff12e
Show file tree
Hide file tree
Showing 4 changed files with 909 additions and 19 deletions.
17 changes: 1 addition & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,7 @@ script:
git checkout -- src/renderers/dom/shared/ReactDOMFeatureFlags.js
echo 'Testing in fiber mode...'
printf '\nmodule.exports.useFiber = true;\n' \
>> src/renderers/dom/shared/ReactDOMFeatureFlags.js
FIBER_TESTS=`\
NODE_ENV=test node node_modules/jest/bin/jest --json | \
node -e "\
var data = JSON.parse(require('fs').readFileSync('/dev/stdin', 'utf8')); \
console.log(data.numPassedTests + '/' + data.numTotalTests)\
"\
`
git checkout -- src/renderers/dom/shared/ReactDOMFeatureFlags.js
node scripts/facts-tracker/index.js \
"fiber-tests" "$FIBER_TESTS"
# Should consolidate this with the above fiber run
echo 'Testing in fiber mode against test records...'
scripts/fiber/record-tests
scripts/fiber/record-tests --track-facts
git --no-pager diff scripts/fiber
FIBER_TESTS_STATUS=$(git status --porcelain scripts/fiber)
test -z "$FIBER_TESTS_STATUS"
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"tmp": "~0.0.28",
"typescript": "~1.8.10",
"uglify-js": "^2.5.0",
"uglifyify": "^3.0.1"
"uglifyify": "^3.0.1",
"yargs": "^6.3.0"
},
"devEngines": {
"node": "4.x || 5.x || 6.x || 7.x",
Expand Down
28 changes: 26 additions & 2 deletions scripts/fiber/record-tests
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

'use strict';

const child_process = require('child_process');
const crypto = require('crypto');
const fs = require('fs');
const os = require('os');
Expand Down Expand Up @@ -84,7 +85,7 @@ function formatResults(runResults, predicate) {
return formatted.join('\n\n');
}

function recordTests() {
function recordTests(trackFacts) {
process.env.REACT_DOM_JEST_USE_FIBER = true;
runJest()
.then((runResults) => {
Expand All @@ -104,11 +105,34 @@ function recordTests() {
path.join(__dirname, 'tests-failing.txt'),
failing + '\n'
);

if (trackFacts) {
const fact = runResults.numPassedTests + '/' + runResults.numTotalTests;
// TODO: Shelling out here is silly.
child_process.spawnSync(
process.execPath,
[
path.join(__dirname, '../facts-tracker/index.js'),
'fiber-tests',
fact,
],
{
stdio: 'inherit',
}
);
}
});
}

if (require.main === module) {
recordTests();
const argv = require('yargs')
.demand(0, 0)
.boolean('track-facts')
.describe('track-facts', 'Use facts-tracker to record passing tests.')
.strict()
.help()
.argv;
recordTests(argv.trackFacts);
}

module.exports = {
Expand Down
Loading

0 comments on commit 75ff12e

Please sign in to comment.