diff --git a/benchmark/server b/benchmark/server deleted file mode 100755 index 253103a..0000000 --- a/benchmark/server +++ /dev/null @@ -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..."); -}); diff --git a/gulpfile.js b/gulpfile.js index 8a3e2fe..03c9ee9 100644 --- a/gulpfile.js +++ b/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. diff --git a/package.json b/package.json index 62cb56b..4c22f18 100644 --- a/package.json +++ b/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", diff --git a/benchmark/README.md b/test/benchmark/README.md similarity index 100% rename from benchmark/README.md rename to test/benchmark/README.md diff --git a/benchmark/benchmarks.js b/test/benchmark/benchmarks.js similarity index 100% rename from benchmark/benchmarks.js rename to test/benchmark/benchmarks.js diff --git a/benchmark/css/960.gs/min/960.css b/test/benchmark/css/960.gs/min/960.css similarity index 100% rename from benchmark/css/960.gs/min/960.css rename to test/benchmark/css/960.gs/min/960.css diff --git a/benchmark/css/960.gs/min/960_24_col.css b/test/benchmark/css/960.gs/min/960_24_col.css similarity index 100% rename from benchmark/css/960.gs/min/960_24_col.css rename to test/benchmark/css/960.gs/min/960_24_col.css diff --git a/benchmark/css/960.gs/min/reset.css b/test/benchmark/css/960.gs/min/reset.css similarity index 100% rename from benchmark/css/960.gs/min/reset.css rename to test/benchmark/css/960.gs/min/reset.css diff --git a/benchmark/css/960.gs/min/text.css b/test/benchmark/css/960.gs/min/text.css similarity index 100% rename from benchmark/css/960.gs/min/text.css rename to test/benchmark/css/960.gs/min/text.css diff --git a/benchmark/css/960.gs/src/960.css b/test/benchmark/css/960.gs/src/960.css similarity index 100% rename from benchmark/css/960.gs/src/960.css rename to test/benchmark/css/960.gs/src/960.css diff --git a/benchmark/css/960.gs/src/960_24_col.css b/test/benchmark/css/960.gs/src/960_24_col.css similarity index 100% rename from benchmark/css/960.gs/src/960_24_col.css rename to test/benchmark/css/960.gs/src/960_24_col.css diff --git a/benchmark/css/960.gs/src/reset.css b/test/benchmark/css/960.gs/src/reset.css similarity index 100% rename from benchmark/css/960.gs/src/reset.css rename to test/benchmark/css/960.gs/src/reset.css diff --git a/benchmark/css/960.gs/src/text.css b/test/benchmark/css/960.gs/src/text.css similarity index 100% rename from benchmark/css/960.gs/src/text.css rename to test/benchmark/css/960.gs/src/text.css diff --git a/benchmark/css/blueprint/min/ie.css b/test/benchmark/css/blueprint/min/ie.css similarity index 100% rename from benchmark/css/blueprint/min/ie.css rename to test/benchmark/css/blueprint/min/ie.css diff --git a/benchmark/css/blueprint/min/print.css b/test/benchmark/css/blueprint/min/print.css similarity index 100% rename from benchmark/css/blueprint/min/print.css rename to test/benchmark/css/blueprint/min/print.css diff --git a/benchmark/css/blueprint/min/screen.css b/test/benchmark/css/blueprint/min/screen.css similarity index 100% rename from benchmark/css/blueprint/min/screen.css rename to test/benchmark/css/blueprint/min/screen.css diff --git a/benchmark/css/blueprint/src/forms.css b/test/benchmark/css/blueprint/src/forms.css similarity index 100% rename from benchmark/css/blueprint/src/forms.css rename to test/benchmark/css/blueprint/src/forms.css diff --git a/benchmark/css/blueprint/src/grid.css b/test/benchmark/css/blueprint/src/grid.css similarity index 100% rename from benchmark/css/blueprint/src/grid.css rename to test/benchmark/css/blueprint/src/grid.css diff --git a/benchmark/css/blueprint/src/ie.css b/test/benchmark/css/blueprint/src/ie.css similarity index 100% rename from benchmark/css/blueprint/src/ie.css rename to test/benchmark/css/blueprint/src/ie.css diff --git a/benchmark/css/blueprint/src/print.css b/test/benchmark/css/blueprint/src/print.css similarity index 100% rename from benchmark/css/blueprint/src/print.css rename to test/benchmark/css/blueprint/src/print.css diff --git a/benchmark/css/blueprint/src/reset.css b/test/benchmark/css/blueprint/src/reset.css similarity index 100% rename from benchmark/css/blueprint/src/reset.css rename to test/benchmark/css/blueprint/src/reset.css diff --git a/benchmark/css/blueprint/src/typography.css b/test/benchmark/css/blueprint/src/typography.css similarity index 100% rename from benchmark/css/blueprint/src/typography.css rename to test/benchmark/css/blueprint/src/typography.css diff --git a/benchmark/index.js b/test/benchmark/index.js similarity index 90% rename from benchmark/index.js rename to test/benchmark/index.js index 190d95a..57fd4aa 100644 --- a/benchmark/index.js +++ b/test/benchmark/index.js @@ -10,12 +10,6 @@ $("#run").click(() => { let resultsTable = $("#results-table"); - function appendHeading(heading) { - resultsTable.append( - "" + heading + "" - ); - } - 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( + "" + + "" + + benchmark.title + + "" + + "" + ); }, benchmarkFinish(benchmark, inputSize, parseTime) { diff --git a/benchmark/json/example1.json b/test/benchmark/json/example1.json similarity index 100% rename from benchmark/json/example1.json rename to test/benchmark/json/example1.json diff --git a/benchmark/json/example2.json b/test/benchmark/json/example2.json similarity index 100% rename from benchmark/json/example2.json rename to test/benchmark/json/example2.json diff --git a/benchmark/json/example3.json b/test/benchmark/json/example3.json similarity index 100% rename from benchmark/json/example3.json rename to test/benchmark/json/example3.json diff --git a/benchmark/json/example4.json b/test/benchmark/json/example4.json similarity index 100% rename from benchmark/json/example4.json rename to test/benchmark/json/example4.json diff --git a/benchmark/json/example5.json b/test/benchmark/json/example5.json similarity index 100% rename from benchmark/json/example5.json rename to test/benchmark/json/example5.json diff --git a/benchmark/run b/test/benchmark/run old mode 100755 new mode 100644 similarity index 100% rename from benchmark/run rename to test/benchmark/run diff --git a/benchmark/runner.js b/test/benchmark/runner.js similarity index 96% rename from benchmark/runner.js rename to test/benchmark/runner.js index 861bf7a..7b49506 100644 --- a/benchmark/runner.js +++ b/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; diff --git a/tools/impact b/test/impact old mode 100755 new mode 100644 similarity index 100% rename from tools/impact rename to test/impact diff --git a/test/server b/test/server deleted file mode 100755 index 9dbb3f2..0000000 --- a/test/server +++ /dev/null @@ -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..."); -}); diff --git a/benchmark/index.css b/test/server/benchmark.css similarity index 100% rename from benchmark/index.css rename to test/server/benchmark.css diff --git a/benchmark/index.html b/test/server/benchmark.html similarity index 91% rename from benchmark/index.html rename to test/server/benchmark.html index ec6a390..3d53fe6 100644 --- a/benchmark/index.html +++ b/test/server/benchmark.html @@ -3,7 +3,7 @@ PEG.js Benchmark Suite - +

PEG.js Benchmark Suite

@@ -35,6 +35,6 @@ - + diff --git a/test/server/index.html b/test/server/index.html new file mode 100644 index 0000000..7c0d5fa --- /dev/null +++ b/test/server/index.html @@ -0,0 +1,24 @@ + + + + + PEG.js Test Suites + + + +

+

PEG.js Test Suites

+

+ • Benchmark Suite
+ • Spec Suite + + diff --git a/test/server/run b/test/server/run new file mode 100644 index 0000000..1843fb1 --- /dev/null +++ b/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/"); +}); diff --git a/test/index.html b/test/server/spec.html similarity index 80% rename from test/index.html rename to test/server/spec.html index ef3d950..1775f44 100644 --- a/test/index.html +++ b/test/server/spec.html @@ -2,7 +2,7 @@ - PEG.js Test Suite + PEG.js Spec Suite @@ -11,7 +11,7 @@ - + diff --git a/benchmark/vendor/jquery.scrollto/LICENSE b/test/server/vendor/jquery.scrollto/LICENSE similarity index 100% rename from benchmark/vendor/jquery.scrollto/LICENSE rename to test/server/vendor/jquery.scrollto/LICENSE diff --git a/benchmark/vendor/jquery.scrollto/jquery.scrollTo.js b/test/server/vendor/jquery.scrollto/jquery.scrollTo.js similarity index 98% rename from benchmark/vendor/jquery.scrollto/jquery.scrollTo.js rename to test/server/vendor/jquery.scrollto/jquery.scrollTo.js index 65a020d..ead8108 100644 --- a/benchmark/vendor/jquery.scrollto/jquery.scrollTo.js +++ b/test/server/vendor/jquery.scrollto/jquery.scrollTo.js @@ -1,7 +1,7 @@ -/** - * Copyright (c) 2007-2015 Ariel Flesler - afleslergmailcom | http://flesler.blogspot.com - * Licensed under MIT - * @author Ariel Flesler - * @version 2.1.2 - */ +/** + * Copyright (c) 2007-2015 Ariel Flesler - afleslergmailcom | 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=f[g]?0:Math.min(f[g],n));!a&&1