Merge the test suites into the website

This commit is contained in:
Futago-za Ryuu 2018-09-06 12:38:26 +01:00
parent 4596daae28
commit 5e7134936b
22 changed files with 107 additions and 15723 deletions

View file

@ -35,7 +35,6 @@
"clean": "gulp clean",
"start": "node server.js",
"test:impact": "node test/impact master",
"test:server": "node test/server/run",
"test": "nyc gulp",
"coverage": "nyc report --reporter=text-lcov | coveralls"
},

View file

@ -1,20 +1,27 @@
"use strict";
const babelify = require( "babelify" );
const bodyParser = require( "body-parser" );
const browserify = require( "browserify" );
const express = require( "express" );
const layout = require( "express-layout" );
const glob = require( "glob" ).sync;
const logger = require( "morgan" );
const { join } = require( "path" );
const path = ( ...parts ) => join( __dirname, ...parts );
/* Setup */
const app = express();
app.set( "views", join( __dirname, "website", "views" ) );
app.set( "views", path( "website", "views" ) );
app.set( "view engine", "ejs" );
app.use( logger( "dev" ) );
app.use( express.static( join( __dirname, "website" ) ) );
app.use( express.static( path( "website" ) ) );
app.use( "/benchmark", express.static( path( "test", "benchmark" ) ) );
app.use( "/examples", express.static( path( "examples" ) ) );
app.use( layout() );
app.use( ( req, res, next ) => {
@ -72,6 +79,27 @@ app.get( "/download", ( req, res ) => {
} );
app.get( "/spec", ( req, res ) => {
res.render( "spec", { title: "Spec Suite" } );
} );
app.get( "/benchmark", ( req, res ) => {
res.render( "benchmark", { title: "Benchmark Suite" } );
} );
app.get( "/:dir/bundle.js", ( req, res ) => {
browserify( glob( `${ __dirname }/test/${ req.params.dir }/**/*.js` ) )
.transform( babelify )
.bundle()
.pipe( res );
} );
/* Main */
app.listen( 80, () => {

View file

@ -68,10 +68,7 @@ The commands below need to be executed via the console from the PEG.js root dire
## Running in the Browser
1. Serve the test suites using a web server:
* [Benchmark Suite](https://pegjs.org/benchmark)
* [Spec Suite](https://pegjs.org/spec)
```console
$ node test/server/run
```
2. Point your browser to the [test suite](http://localhost:8000/)
You also have the option of running the website locally by running `node server.js` or `npm start` from the root of this repository. After that just go to the development page and click the link `Benchmark Suite` or `Spec Suite`.

View file

@ -76,7 +76,7 @@ $( "#run" ).click( () => {
return $.ajax( {
type: "GET",
url: "benchmark/" + file,
url: file,
dataType: "text",
async: false
} ).responseText;

View file

@ -1,40 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>PEG.js Benchmark Suite</title>
<link rel="stylesheet" href="benchmark.css">
</head>
<body>
<h1>PEG.js Benchmark Suite</h1>
<div id="options">
<label for="run-count">Run each test</label>
<input type="text" id="run-count" value="10"> times
<input type="checkbox" id="cache">
<label for="cache">Use results cache</label>
<label for="optimize">Optimize:</label>
<select id="optimize">
<option value="speed">Speed</option>
<option value="size">Size</option>
</select>
<input type="button" id="run" value="Run">
</div>
<table id="results-table">
<tr class="columns">
<th>Test</th>
<th>Input Size</th>
<th>Average Parse Time</th>
<th>Average Parse Speed</th>
</tr>
<tr>
<td class="no-results" colspan="4">No results available yet.</td>
</tr>
</table>
<script src="vendor/jquery/jquery.js"></script>
<script src="vendor/jquery.scrollto/jquery.scrollTo.js"></script>
<script src="benchmark/bundle.js"></script>
</body>
</html>

View file

@ -1,24 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>PEG.js Test Suites</title>
<style>
a {
text-decoration: none;
color: #1A0BF1;
}
a:hover {
text-decoration: underline;
color: #9D0BF1;
}
</style>
</head>
<body>
<p>
<h1>PEG.js Test Suites</h1>
</p>
&bull; <a href="/benchmark.html">Benchmark Suite</a><br />
&bull; <a href="/spec.html">Spec Suite</a>
</body>
</html>

View file

@ -1,31 +0,0 @@
#!/usr/bin/env node
"use strict";
const babelify = require( "babelify" );
const browserify = require( "browserify" );
const express = require( "express" );
const glob = require( "glob" );
const logger = require( "morgan" );
const app = express();
app.use( logger( "dev" ) );
app.use( express.static( __dirname ) );
app.use( "/benchmark", express.static( `${ __dirname }/../benchmark` ) );
app.use( "/examples", express.static( `${ __dirname }/../../examples` ) );
app.get( "/:dir/bundle.js", ( req, res ) => {
browserify( glob.sync( `${ __dirname }/../${ req.params.dir }/**/*.js` ) )
.transform( babelify )
.bundle()
.pipe( res );
} );
app.listen( 8000, () => {
console.log( "Test server running at: http://localhost:8000/" );
} );

View file

@ -1,19 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>PEG.js Spec Suite</title>
<link rel="stylesheet" href="vendor/mocha/mocha.css">
</head>
<body>
<div id="mocha"></div>
<script src="vendor/mocha/mocha.js"></script>
<script>
mocha.setup('bdd');
</script>
<script src="spec/bundle.js"></script>
<script>
mocha.run();
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

View file

@ -1,22 +0,0 @@
(The MIT License)
Copyright (c) 2016 JS Foundation and contributors, https://js.foundation
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

File diff suppressed because it is too large Load diff

View file

@ -14,7 +14,16 @@
background-color: #f0f0f0;
}
#content table { border-spacing: 0; }
#content a, #content a:visited { color: #3d586c; }
#content a {
text-decoration: none;
color: #1A0BF1;
}
#content a:hover {
text-decoration: underline;
color: #9D0BF1;
}
#content .center { text-align: center; }
@ -148,4 +157,4 @@
#output {
max-width: 50vw;
}
}

View file

@ -40,6 +40,13 @@
#footer {
margin-bottom: 2em;
text-align: center; font-size: 75%;
color: silver;
color: #3d586c;
}
#footer a {
text-decoration: none;
color: #1A0BF1;
}
#footer a:hover {
text-decoration: underline;
color: #9D0BF1;
}
#footer a, #footer a:visited { color: silver; }

View file

@ -259,9 +259,6 @@ body {
}
#mocha-stats {
position: fixed;
top: 15px;
right: 10px;
font-size: 12px;
margin: 0;
color: #888;

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,30 @@
<link rel="stylesheet" href="/css/benchmark.css">
<div id="options">
<label for="run-count">Run each test</label>
<input type="text" id="run-count" value="10"> times
<input type="checkbox" id="cache">
<label for="cache">Use results cache</label>
<label for="optimize">Optimize:</label>
<select id="optimize">
<option value="speed">Speed</option>
<option value="size">Size</option>
</select>
<input type="button" id="run" value="Run">
</div>
<table id="results-table">
<tr class="columns">
<th>Test</th>
<th>Input Size</th>
<th>Average Parse Time</th>
<th>Average Parse Speed</th>
</tr>
<tr>
<td class="no-results" colspan="4">No results available yet.</td>
</tr>
</table>
<script src="/vendor/jquery/jquery.js"></script>
<script src="/vendor/jquery.scrollto/jquery.scrollTo.js"></script>
<script src="/benchmark/bundle.js"></script>

View file

@ -1,9 +1,10 @@
<h1>Development</h1>
<ul>
<li><a href="https://pegjs.org/">Project website</a></li>
<li><a href="https://github.com/pegjs/pegjs/wiki">Wiki</a></li>
<li><a href="https://github.com/pegjs/pegjs">Source code</a></li>
<li><a href="/benchmark">Benchmark Suite</a></li>
<li><a href="/spec">Spec Suite</a></li>
<li><a href="https://github.com/pegjs/pegjs/issues">Issue tracker</a></li>
<li><a href="https://groups.google.com/group/pegjs">Google Group</a></li>
<li><a href="https://twitter.com/peg_js">Twitter</a></li>

16
website/views/spec.ejs Normal file
View file

@ -0,0 +1,16 @@
<div id="mocha"></div>
<link href="/css/spec.css" rel="stylesheet" />
<script src="https://unpkg.com/mocha@5.2.0/mocha.js"></script>
<script>
mocha.setup( {
ui: "bdd"
} );
</script>
<script src="/spec/bundle.js"></script>
<script>
mocha.run();
</script>