Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ script:
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
git --no-pager diff scripts/fiber
FIBER_TESTS_STATUS=$(git status --porcelain scripts/fiber)
test -z "$FIBER_TESTS_STATUS"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that any time anyone adds a passing test, unrelated to Fiber, in a PR we will get a Travis error on the PR?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my intention. I figured it was good to know whether your new test passes in Fiber. Not good?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good for the team but might be noisy for third-party PR. Not too worried about it though. Let's see how it works out.


./node_modules/.bin/gulp react:extract-errors
elif [ "$TEST_TYPE" = flow ]; then
set -e
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
"gulp-util": "^3.0.7",
"gzip-js": "~0.3.2",
"jest": "^15.1.1",
"jest-config": "^15.1.1",
"jest-runtime": "^15.1.1",
"loose-envify": "^1.1.0",
"merge-stream": "^1.0.0",
"object-assign": "^4.1.0",
Expand Down
73 changes: 73 additions & 0 deletions scripts/fiber/record-tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env node

const fs = require('fs');
const os = require('os');
const path = require('path');

const SearchSource = require('jest').SearchSource;
const TestRunner = require('jest').TestRunner;

const createHasteContext = require('jest-runtime').createHasteContext;
const readConfig = require('jest-config').readConfig;

const argv = {};
const root = path.normalize(path.join(__dirname, '..', '..'));
const testPathPattern = '';

function runJest() {
return readConfig(argv, root)
.then((config) => {
return createHasteContext(config, {}).then((hasteMap) => {
const source = new SearchSource(hasteMap, config);
return source.getTestPaths({testPathPattern})
.then((data) => {
const runner = new TestRunner(
hasteMap,
config,
{
maxWorkers: Math.max(os.cpus().length - 1, 1),
getTestSummary: () => 'You did it!'
}
);
return runner.runTests(data.paths);
});
});
});
}

function formatResults(runResults, predicate) {
const formatted = [];
runResults.testResults.forEach((fileResult) => {
const file = path.relative(root, fileResult.testFilePath);
const tests = fileResult.testResults.filter(
(test) => predicate(fileResult, test)
);
if (tests.length) {
const lines = [file].concat(tests.map((test) => '* ' + test.title));
formatted.push(lines.join('\n'));
}
});
formatted.sort();
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'
);
});
Loading