Skip to content

Commit

Permalink
Deploy browserified test suite on every commit
Browse files Browse the repository at this point in the history
This commit adds a script that bundles up the test suite, using browserify, into a form suitable for running against browsers. It will automatically be deployed on every commit to https://streams.spec.whatwg.org/tests/.

This is, perhaps, the first step toward #216.
  • Loading branch information
domenic committed Feb 17, 2015
1 parent db28a0d commit 28f9bda
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
streams.spec.whatwg.org/
index.html
/streams.spec.whatwg.org/
/index.html
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Snapshots of any given commit or branch are available at specially-crafted URLs:
- https://streams.spec.whatwg.org/commit-snapshots/ contains snapshots of any given commit
- https://streams.spec.whatwg.org/branch-snapshots/ contains snapshots of the latest commit to any given branch

This repository also includes a polyfill and test suite under `reference-implementation/`. See the README under that directory for more details.
This repository also includes a polyfill and test suite under `reference-implementation/`. See the README under that directory for more details. The test suite is automatically deployed, in a form viable for running against browsers, to https://streams.spec.whatwg.org/tests/.


## Building the spec

Expand Down
8 changes: 8 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ SERVER="streams.spec.whatwg.org"
WEB_ROOT="streams.spec.whatwg.org"
COMMITS_DIR="commit-snapshots"
BRANCHES_DIR="branch-snapshots"
TESTS_DIR="tests"

SHA="`git rev-parse HEAD`"
BRANCH="`git rev-parse --abbrev-ref HEAD`"
Expand Down Expand Up @@ -64,6 +65,13 @@ else
> $WEB_ROOT/index.html
cp *.svg $WEB_ROOT
echo "Living standard output to $WEB_ROOT"

# Test suite, if master
cd reference-implementation
npm run build-browser-tests
cd ..
mkdir "$WEB_ROOT/$TESTS_DIR"
cp reference-implementation/browser-tests/{index.html,bundle.js} "$WEB_ROOT/$TESTS_DIR"
fi

# scp the output directory up
Expand Down
5 changes: 4 additions & 1 deletion reference-implementation/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
node_modules/
bench/results/
npm-debug.log

bench/results/

browser-tests/bundle.js
5 changes: 5 additions & 0 deletions reference-implementation/browser-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Streams Standard Tests, In Your Browser

This directory contains some preliminary work on creating a version of the [test suite](https://github.com/whatwg/streams/tree/master/reference-implementation/test) which can run in your browser, against any implementation that may be implemented there.

To set these up, run the command `npm run build-browser-tests`. This will generate a `bundle.js` in this directory. At that point, `index.html` + `bundle.js` together will be enough to run the tests. (The other files in this directory are for the build process.)
34 changes: 34 additions & 0 deletions reference-implementation/browser-tests/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const browserify = require('browserify');
const es6ify = require('es6ify');
const glob = require('glob');
const path = require('path');
const fs = require('fs');

es6ify.traceurOverrides = {
// Present in Chrome 41
blockBinding: 'parse',
forOf: 'parse',
generators: 'parse',
numericLiterals: 'parse',
symbols: false,
templateLiterals: 'parse'

// Probably Chrome 42
// classes: 'parse',
// computedPropertyNames: 'parse',
// propertyMethods: 'parse',
// propertyNameShorthand: 'parse'
};


const tests = glob.sync(path.resolve(__dirname, '../test/*.js'));
const experimentalTests = glob.sync(path.resolve(__dirname, '../test/experimental/*.js'));

const browserifyInstance = browserify({ debug: true })
.add(es6ify.runtime)
.add(path.resolve(__dirname, 'setup.js'))
.transform(es6ify);
tests.concat(experimentalTests).forEach(t => browserifyInstance.add(t));

const dest = fs.createWriteStream(path.resolve(__dirname, 'bundle.js'));
browserifyInstance.bundle().pipe(dest);
15 changes: 15 additions & 0 deletions reference-implementation/browser-tests/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Streams Standard Tests</title>

<style>
body { color: white; }
</style>

<body id="out">
<h1>Streams Standard Tests</h1>
<p>This page runs the <a href="https://streams.spec.whatwg.org/">Streams Standard</a>'s <a href="https://github.com/whatwg/streams/tree/master/reference-implementation/test">test suite</a> against your current browser's implementation.</p>

<script src="https://use.edgefonts.net/source-code-pro.js" async defer></script>
<script src="bundle.js"></script>
</body>
1 change: 1 addition & 0 deletions reference-implementation/browser-tests/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require('tape-catch').createStream().pipe(require('browserify-tape-spec')('out'));
6 changes: 5 additions & 1 deletion reference-implementation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "Reference implementation and tests for the WHATWG Streams Standard",
"scripts": {
"test": "traceur-runner run-tests.js | tap-spec",
"bench": "traceur-runner bench/recording-runner.js && traceur-runner bench/recording-differ.js"
"bench": "traceur-runner bench/recording-runner.js && traceur-runner bench/recording-differ.js",
"build-browser-tests": "traceur-runner browser-tests/build.js"
},
"repository": "whatwg/streams",
"keywords": [
Expand All @@ -21,6 +22,9 @@
"license": "CC0",
"traceur-runner": true,
"devDependencies": {
"browserify": "^8.1.3",
"browserify-tape-spec": "^1.1.2",
"es6ify": "^1.6.0",
"glob": "^4.3.5",
"mkdirp": "^0.5.0",
"ms": "^0.7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default class SequentialPullSource {

this._exec = f => f();
if (async) {
this._exec = f => setImmediate(f);
this._exec = f => setTimeout(f, 0);
}
}

Expand Down

0 comments on commit 28f9bda

Please sign in to comment.