Moved all spec and benchmark tests

- Moved benchmark to test/benchmark
- Moved tests to test/spec
- Removed individual servers
- Implemented single test server
- Moved server assets to test/server
- Updated Gulpfile.js
- Moved tools/impact to test/impact

This commit move's nearly all code related to testing the PEG.js module into the test directory, and also ensures they run as they did before the move.
master
Futago-za Ryuu 7 years ago
parent a1ad351c2c
commit 5a833bd982

@ -1,36 +0,0 @@
#!/usr/bin/env node
"use strict";
/* eslint-env node */
// Small server whose main purpose is to ensure that both the benchmarked code
// and the benchmark get passed through Babel & Browserify before they are
// served to the browser.
let babelify = require("babelify");
let browserify = require("browserify");
let express = require("express");
let glob = require("glob");
let logger = require("morgan");
let app = express();
app.use(logger("dev"));
app.use(express.static(__dirname));
app.use("/examples", express.static(`${__dirname}/../examples`));
app.get("/bundle.js", (req, res) => {
let files = glob.sync(`${__dirname}/**/*.js`, {
ignore: `${__dirname}/vendor/**/*`
});
browserify(files)
.transform(babelify, { presets: "es2015", compact: false })
.bundle()
.pipe(res);
});
app.listen(8000, () => {
console.log("Benchmark server running at http://localhost:8000...");
});

@ -32,20 +32,16 @@ const HEADER = [
const JS_FILES = [
"lib/**/*.js",
"!lib/parser.js",
"test/**/*.js",
"test/server",
"!test/vendor/**/*",
"benchmark/**/*.js",
"benchmark/run",
"benchmark/server",
"!benchmark/vendor/**/*",
"test/benchmark/**/*.js",
"test/benchmark/run",
"test/spec/**/*.js",
"test/server/run",
"bin/*.js",
"gulpfile.js"
];
const TEST_FILES = [
"test/**/*.js",
"!test/vendor/**/*"
"test/spec/**/*.js"
];
function generate(contents) {
@ -71,7 +67,7 @@ gulp.task("test", () =>
// Run benchmarks.
gulp.task("benchmark", () =>
spawn("node", ["benchmark/run"], { stdio: "inherit" })
spawn("node", ["test/benchmark/run"], { stdio: "inherit" })
);
// Create the browser build.

@ -49,6 +49,7 @@
"lint": "gulp lint",
"spec": "gulp test",
"test": "gulp",
"test:server": "node test/server/run",
"benchmark": "gulp benchmark",
"browser:build": "gulp browser:build",
"browser:clean": "gulp browser:build",

@ -10,12 +10,6 @@ $("#run").click(() => {
let resultsTable = $("#results-table");
function appendHeading(heading) {
resultsTable.append(
"<tr class='heading'><th colspan='4'>" + heading + "</th></tr>"
);
}
function appendResult(klass, title, url, inputSize, parseTime) {
const KB = 1024;
const MS_IN_S = 1000;
@ -76,7 +70,7 @@ $("#run").click(() => {
readFile(file) {
return $.ajax({
type: "GET",
url: file,
url: "benchmark/" + file,
dataType: "text",
async: false
}).responseText;
@ -90,14 +84,20 @@ $("#run").click(() => {
appendResult(
"individual",
test.title,
benchmark.id + "/" + test.file,
"benchmark/" + benchmark.id + "/" + test.file,
inputSize,
parseTime
);
},
benchmarkStart(benchmark) {
appendHeading(benchmark.title);
resultsTable.append(
"<tr class='heading'><th colspan='4'>"
+ "<a href='../../examples/" + benchmark.id + ".pegjs'>"
+ benchmark.title
+ "</a>"
+ "</th></tr>"
);
},
benchmarkFinish(benchmark, inputSize, parseTime) {

@ -2,7 +2,7 @@
/* global setTimeout */
let peg = require("../lib/peg");
let peg = require("../../lib/peg");
let Runner = {
run(benchmarks, runCount, options, callbacks) {
@ -53,7 +53,7 @@ let Runner = {
callbacks.benchmarkStart(benchmark);
state.parser = peg.generate(
callbacks.readFile("../examples/" + benchmark.id + ".pegjs"),
callbacks.readFile("../../examples/" + benchmark.id + ".pegjs"),
options
);
state.benchmarkInputSize = 0;

@ -1,35 +0,0 @@
#!/usr/bin/env node
"use strict";
/* eslint-env node */
// Small server whose main purpose is to ensure that both the tested code and
// the tests get passed through Babel & Browserify before they are served to the
// browser.
let babelify = require("babelify");
let browserify = require("browserify");
let express = require("express");
let glob = require("glob");
let logger = require("morgan");
let app = express();
app.use(logger("dev"));
app.use(express.static(__dirname));
app.get("/bundle.js", (req, res) => {
let files = glob.sync(`${__dirname}/**/*.js`, {
ignore: `${__dirname}/vendor/**/*`
});
browserify(files)
.transform(babelify, { presets: "es2015", compact: false })
.bundle()
.pipe(res);
});
app.listen(8000, () => {
console.log("Test server running at http://localhost:8000...");
});

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>PEG.js Benchmark Suite</title>
<link rel="stylesheet" href="index.css">
<link rel="stylesheet" href="benchmark.css">
</head>
<body>
<h1>PEG.js Benchmark Suite</h1>
@ -35,6 +35,6 @@
<script src="vendor/jquery/jquery.js"></script>
<script src="vendor/jquery.scrollto/jquery.scrollTo.js"></script>
<script src="bundle.js"></script>
<script src="benchmark/bundle.js"></script>
</body>
</html>

@ -0,0 +1,24 @@
<!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>

@ -0,0 +1,34 @@
#!/usr/bin/env node
"use strict";
/* eslint-env node */
let babelify = require("babelify");
let browserify = require("browserify");
let express = require("express");
let glob = require("glob");
let logger = require("morgan");
let 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, {
presets: "es2015",
compact: false
})
.bundle()
.pipe(res);
});
app.listen(8000, () => {
console.log("Test server running at: http://localhost:8000/");
});

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>PEG.js Test Suite</title>
<title>PEG.js Spec Suite</title>
<link rel="stylesheet" href="vendor/mocha/mocha.css">
</head>
<body>
@ -11,7 +11,7 @@
<script>
mocha.setup('bdd');
</script>
<script src="bundle.js"></script>
<script src="spec/bundle.js"></script>
<script>
mocha.run();
</script>

@ -1,7 +1,7 @@
/**
* Copyright (c) 2007-2015 Ariel Flesler - aflesler<a>gmail<d>com | http://flesler.blogspot.com
* Licensed under MIT
* @author Ariel Flesler
* @version 2.1.2
*/
/**
* Copyright (c) 2007-2015 Ariel Flesler - aflesler<a>gmail<d>com | http://flesler.blogspot.com
* Licensed under MIT
* @author Ariel Flesler
* @version 2.1.2
*/
;(function(f){"use strict";"function"===typeof define&&define.amd?define(["jquery"],f):"undefined"!==typeof module&&module.exports?module.exports=f(require("jquery")):f(jQuery)})(function($){"use strict";function n(a){return!a.nodeName||-1!==$.inArray(a.nodeName.toLowerCase(),["iframe","#document","html","body"])}function h(a){return $.isFunction(a)||$.isPlainObject(a)?a:{top:a,left:a}}var p=$.scrollTo=function(a,d,b){return $(window).scrollTo(a,d,b)};p.defaults={axis:"xy",duration:0,limit:!0};$.fn.scrollTo=function(a,d,b){"object"=== typeof d&&(b=d,d=0);"function"===typeof b&&(b={onAfter:b});"max"===a&&(a=9E9);b=$.extend({},p.defaults,b);d=d||b.duration;var u=b.queue&&1<b.axis.length;u&&(d/=2);b.offset=h(b.offset);b.over=h(b.over);return this.each(function(){function k(a){var k=$.extend({},b,{queue:!0,duration:d,complete:a&&function(){a.call(q,e,b)}});r.animate(f,k)}if(null!==a){var l=n(this),q=l?this.contentWindow||window:this,r=$(q),e=a,f={},t;switch(typeof e){case "number":case "string":if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(e)){e= h(e);break}e=l?$(e):$(e,q);case "object":if(e.length===0)return;if(e.is||e.style)t=(e=$(e)).offset()}var v=$.isFunction(b.offset)&&b.offset(q,e)||b.offset;$.each(b.axis.split(""),function(a,c){var d="x"===c?"Left":"Top",m=d.toLowerCase(),g="scroll"+d,h=r[g](),n=p.max(q,c);t?(f[g]=t[m]+(l?0:h-r.offset()[m]),b.margin&&(f[g]-=parseInt(e.css("margin"+d),10)||0,f[g]-=parseInt(e.css("border"+d+"Width"),10)||0),f[g]+=v[m]||0,b.over[m]&&(f[g]+=e["x"===c?"width":"height"]()*b.over[m])):(d=e[m],f[g]=d.slice&& "%"===d.slice(-1)?parseFloat(d)/100*n:d);b.limit&&/^\d+$/.test(f[g])&&(f[g]=0>=f[g]?0:Math.min(f[g],n));!a&&1<b.axis.length&&(h===f[g]?f={}:u&&(k(b.onAfterFirst),f={}))});k(b.onAfter)}})};p.max=function(a,d){var b="x"===d?"Width":"Height",h="scroll"+b;if(!n(a))return a[h]-$(a)[b.toLowerCase()]();var b="client"+b,k=a.ownerDocument||a.document,l=k.documentElement,k=k.body;return Math.max(l[h],k[h])-Math.min(l[b],k[b])};$.Tween.propHooks.scrollLeft=$.Tween.propHooks.scrollTop={get:function(a){return $(a.elem)[a.prop]()}, set:function(a){var d=this.get(a);if(a.options.interrupt&&a._last&&a._last!==d)return $(a.elem).stop();var b=Math.round(a.now);d!==b&&($(a.elem)[a.prop](b),a._last=this.get(a))}};return p});

@ -3,7 +3,7 @@
/* global console */
let chai = require("chai");
let peg = require("../../lib/peg");
let peg = require("../../../lib/peg");
let sinon = require("sinon");
let expect = chai.expect;

@ -1,7 +1,7 @@
"use strict";
let chai = require("chai");
let peg = require("../../lib/peg");
let peg = require("../../../lib/peg");
let sinon = require("sinon");
let expect = chai.expect;

@ -1,7 +1,7 @@
"use strict";
let chai = require("chai");
let peg = require("../../lib/peg");
let peg = require("../../../lib/peg");
let expect = chai.expect;

@ -3,7 +3,7 @@
/* global console */
let chai = require("chai");
let peg = require("../../lib/peg");
let peg = require("../../../lib/peg");
let sinon = require("sinon");
let expect = chai.expect;

@ -2,7 +2,7 @@
let chai = require("chai");
let helpers = require("./helpers");
let pass = require("../../../../lib/compiler/passes/generate-bytecode");
let pass = require("../../../../../lib/compiler/passes/generate-bytecode");
chai.use(helpers);

@ -1,6 +1,6 @@
"use strict";
let parser = require("../../../../lib/parser");
let parser = require("../../../../../lib/parser");
module.exports = function(chai, utils) {
let Assertion = chai.Assertion;

@ -2,7 +2,7 @@
let chai = require("chai");
let helpers = require("./helpers");
let pass = require("../../../../lib/compiler/passes/remove-proxy-rules");
let pass = require("../../../../../lib/compiler/passes/remove-proxy-rules");
chai.use(helpers);

@ -2,7 +2,7 @@
let chai = require("chai");
let helpers = require("./helpers");
let pass = require("../../../../lib/compiler/passes/report-duplicate-labels");
let pass = require("../../../../../lib/compiler/passes/report-duplicate-labels");
chai.use(helpers);

@ -2,7 +2,7 @@
let chai = require("chai");
let helpers = require("./helpers");
let pass = require("../../../../lib/compiler/passes/report-duplicate-rules");
let pass = require("../../../../../lib/compiler/passes/report-duplicate-rules");
chai.use(helpers);

@ -2,7 +2,7 @@
let chai = require("chai");
let helpers = require("./helpers");
let pass = require("../../../../lib/compiler/passes/report-infinite-recursion");
let pass = require("../../../../../lib/compiler/passes/report-infinite-recursion");
chai.use(helpers);

@ -2,7 +2,7 @@
let chai = require("chai");
let helpers = require("./helpers");
let pass = require("../../../../lib/compiler/passes/report-infinite-repetition");
let pass = require("../../../../../lib/compiler/passes/report-infinite-repetition");
chai.use(helpers);

@ -2,7 +2,7 @@
let chai = require("chai");
let helpers = require("./helpers");
let pass = require("../../../../lib/compiler/passes/report-undefined-rules");
let pass = require("../../../../../lib/compiler/passes/report-undefined-rules");
chai.use(helpers);

@ -1,7 +1,7 @@
"use strict";
let chai = require("chai");
let parser = require("../../lib/parser");
let parser = require("../../../lib/parser");
let expect = chai.expect;
Loading…
Cancel
Save