Browse Source

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 4 years ago
parent
commit
5a833bd982
  1. 36
      benchmark/server
  2. 16
      gulpfile.js
  3. 1
      package.json
  4. 0
      test/benchmark/README.md
  5. 0
      test/benchmark/benchmarks.js
  6. 0
      test/benchmark/css/960.gs/min/960.css
  7. 0
      test/benchmark/css/960.gs/min/960_24_col.css
  8. 0
      test/benchmark/css/960.gs/min/reset.css
  9. 0
      test/benchmark/css/960.gs/min/text.css
  10. 0
      test/benchmark/css/960.gs/src/960.css
  11. 0
      test/benchmark/css/960.gs/src/960_24_col.css
  12. 0
      test/benchmark/css/960.gs/src/reset.css
  13. 0
      test/benchmark/css/960.gs/src/text.css
  14. 0
      test/benchmark/css/blueprint/min/ie.css
  15. 0
      test/benchmark/css/blueprint/min/print.css
  16. 0
      test/benchmark/css/blueprint/min/screen.css
  17. 0
      test/benchmark/css/blueprint/src/forms.css
  18. 0
      test/benchmark/css/blueprint/src/grid.css
  19. 0
      test/benchmark/css/blueprint/src/ie.css
  20. 0
      test/benchmark/css/blueprint/src/print.css
  21. 0
      test/benchmark/css/blueprint/src/reset.css
  22. 0
      test/benchmark/css/blueprint/src/typography.css
  23. 18
      test/benchmark/index.js
  24. 0
      test/benchmark/json/example1.json
  25. 0
      test/benchmark/json/example2.json
  26. 0
      test/benchmark/json/example3.json
  27. 0
      test/benchmark/json/example4.json
  28. 0
      test/benchmark/json/example5.json
  29. 0
      test/benchmark/run
  30. 4
      test/benchmark/runner.js
  31. 0
      test/impact
  32. 35
      test/server
  33. 0
      test/server/benchmark.css
  34. 4
      test/server/benchmark.html
  35. 24
      test/server/index.html
  36. 34
      test/server/run
  37. 4
      test/server/spec.html
  38. 0
      test/server/vendor/jquery.scrollto/LICENSE
  39. 12
      test/server/vendor/jquery.scrollto/jquery.scrollTo.js
  40. 0
      test/server/vendor/jquery/LICENSE.txt
  41. 0
      test/server/vendor/jquery/jquery.js
  42. 0
      test/server/vendor/mocha/LICENSE
  43. 0
      test/server/vendor/mocha/mocha.css
  44. 0
      test/server/vendor/mocha/mocha.js
  45. 0
      test/spec/.eslintrc.json
  46. 0
      test/spec/README.md
  47. 2
      test/spec/api/generated-parser-api.spec.js
  48. 2
      test/spec/api/pegjs-api.spec.js
  49. 2
      test/spec/api/plugin-api.spec.js
  50. 2
      test/spec/behavior/generated-parser-behavior.spec.js
  51. 2
      test/spec/unit/compiler/passes/generate-bytecode.spec.js
  52. 2
      test/spec/unit/compiler/passes/helpers.js
  53. 2
      test/spec/unit/compiler/passes/remove-proxy-rules.spec.js
  54. 2
      test/spec/unit/compiler/passes/report-duplicate-labels.spec.js
  55. 2
      test/spec/unit/compiler/passes/report-duplicate-rules.spec.js
  56. 2
      test/spec/unit/compiler/passes/report-infinite-recursion.spec.js
  57. 2
      test/spec/unit/compiler/passes/report-infinite-repetition.spec.js
  58. 2
      test/spec/unit/compiler/passes/report-undefined-rules.spec.js
  59. 2
      test/spec/unit/parser.spec.js

36
benchmark/server

@ -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...");
});

16
gulpfile.js

@ -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.

1
package.json

@ -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",

0
benchmark/README.md → test/benchmark/README.md

0
benchmark/benchmarks.js → test/benchmark/benchmarks.js

0
benchmark/css/960.gs/min/960.css → test/benchmark/css/960.gs/min/960.css

0
benchmark/css/960.gs/min/960_24_col.css → test/benchmark/css/960.gs/min/960_24_col.css

0
benchmark/css/960.gs/min/reset.css → test/benchmark/css/960.gs/min/reset.css

0
benchmark/css/960.gs/min/text.css → test/benchmark/css/960.gs/min/text.css

0
benchmark/css/960.gs/src/960.css → test/benchmark/css/960.gs/src/960.css

0
benchmark/css/960.gs/src/960_24_col.css → test/benchmark/css/960.gs/src/960_24_col.css

0
benchmark/css/960.gs/src/reset.css → test/benchmark/css/960.gs/src/reset.css

0
benchmark/css/960.gs/src/text.css → test/benchmark/css/960.gs/src/text.css

0
benchmark/css/blueprint/min/ie.css → test/benchmark/css/blueprint/min/ie.css

0
benchmark/css/blueprint/min/print.css → test/benchmark/css/blueprint/min/print.css

0
benchmark/css/blueprint/min/screen.css → test/benchmark/css/blueprint/min/screen.css

0
benchmark/css/blueprint/src/forms.css → test/benchmark/css/blueprint/src/forms.css

0
benchmark/css/blueprint/src/grid.css → test/benchmark/css/blueprint/src/grid.css

0
benchmark/css/blueprint/src/ie.css → test/benchmark/css/blueprint/src/ie.css

0
benchmark/css/blueprint/src/print.css → test/benchmark/css/blueprint/src/print.css

0
benchmark/css/blueprint/src/reset.css → test/benchmark/css/blueprint/src/reset.css

0
benchmark/css/blueprint/src/typography.css → test/benchmark/css/blueprint/src/typography.css

18
benchmark/index.js → test/benchmark/index.js

@ -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) {

0
benchmark/json/example1.json → test/benchmark/json/example1.json

0
benchmark/json/example2.json → test/benchmark/json/example2.json

0
benchmark/json/example3.json → test/benchmark/json/example3.json

0
benchmark/json/example4.json → test/benchmark/json/example4.json

0
benchmark/json/example5.json → test/benchmark/json/example5.json

0
benchmark/run → test/benchmark/run

4
benchmark/runner.js → test/benchmark/runner.js

@ -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;

0
tools/impact → test/impact

35
test/server

@ -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...");
});

0
benchmark/index.css → test/server/benchmark.css

4
benchmark/index.html → test/server/benchmark.html

@ -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>

24
test/server/index.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>

34
test/server/run

@ -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/");
});

4
test/index.html → test/server/spec.html

@ -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>

0
benchmark/vendor/jquery.scrollto/LICENSE → test/server/vendor/jquery.scrollto/LICENSE

12
benchmark/vendor/jquery.scrollto/jquery.scrollTo.js → test/server/vendor/jquery.scrollto/jquery.scrollTo.js

@ -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});

0
benchmark/vendor/jquery/LICENSE.txt → test/server/vendor/jquery/LICENSE.txt

0
benchmark/vendor/jquery/jquery.js → test/server/vendor/jquery/jquery.js

0
test/vendor/mocha/LICENSE → test/server/vendor/mocha/LICENSE

0
test/vendor/mocha/mocha.css → test/server/vendor/mocha/mocha.css

0
test/vendor/mocha/mocha.js → test/server/vendor/mocha/mocha.js

0
test/.eslintrc.json → test/spec/.eslintrc.json

0
test/README.md → test/spec/README.md

2
test/api/generated-parser-api.spec.js → test/spec/api/generated-parser-api.spec.js

@ -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
test/api/pegjs-api.spec.js → test/spec/api/pegjs-api.spec.js

@ -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;

2
test/api/plugin-api.spec.js → test/spec/api/plugin-api.spec.js

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

2
test/behavior/generated-parser-behavior.spec.js → test/spec/behavior/generated-parser-behavior.spec.js

@ -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
test/unit/compiler/passes/generate-bytecode.spec.js → test/spec/unit/compiler/passes/generate-bytecode.spec.js

@ -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);

2
test/unit/compiler/passes/helpers.js → test/spec/unit/compiler/passes/helpers.js

@ -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
test/unit/compiler/passes/remove-proxy-rules.spec.js → test/spec/unit/compiler/passes/remove-proxy-rules.spec.js

@ -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
test/unit/compiler/passes/report-duplicate-labels.spec.js → test/spec/unit/compiler/passes/report-duplicate-labels.spec.js

@ -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
test/unit/compiler/passes/report-duplicate-rules.spec.js → test/spec/unit/compiler/passes/report-duplicate-rules.spec.js

@ -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
test/unit/compiler/passes/report-infinite-recursion.spec.js → test/spec/unit/compiler/passes/report-infinite-recursion.spec.js

@ -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
test/unit/compiler/passes/report-infinite-repetition.spec.js → test/spec/unit/compiler/passes/report-infinite-repetition.spec.js

@ -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
test/unit/compiler/passes/report-undefined-rules.spec.js → test/spec/unit/compiler/passes/report-undefined-rules.spec.js

@ -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);

2
test/unit/parser.spec.js → test/spec/unit/parser.spec.js

@ -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