From 001bda28d9e8e7bfda68eb03cf7e2cf2a367aedd Mon Sep 17 00:00:00 2001 From: Thomas Aylott Date: Mon, 28 Oct 2013 14:51:52 -0400 Subject: [PATCH] Generate the browser test list at built time --- .gitignore | 1 + grunt/tasks/populist.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fce7d1d993..635740490d 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ docs/js/examples docs/downloads examples/shared/*.js +test/the files to test.generated.js \ No newline at end of file diff --git a/grunt/tasks/populist.js b/grunt/tasks/populist.js index b9b848bf88..cca0498c14 100644 --- a/grunt/tasks/populist.js +++ b/grunt/tasks/populist.js @@ -1,11 +1,19 @@ 'use strict'; var grunt = require('grunt'); +var fs = require('fs') module.exports = function() { var config = this.data; var done = this.async(); + var theFilesToTestScript = fs.createWriteStream(__dirname + '/../../test/the files to test.generated.js'); + theFilesToTestScript.write('// Generated by '); + theFilesToTestScript.write(JSON.stringify(__filename.split(/(?=grunt)/)[1])); + theFilesToTestScript.write(' at '); + theFilesToTestScript.write(JSON.stringify(new Date())); + theFilesToTestScript.write('\n\n'); + // create the bundle we'll work with var args = config.args; @@ -15,7 +23,9 @@ module.exports = function() { nonull: true, // Keep IDs that don't expand to anything. cwd: config.rootDirectory }, requires).forEach(function(name) { - args.push(name.replace(/\.js$/i, "")); + name = name.replace(/\.js$/i, ""); + args.push(name); + theFilesToTestScript.write('harness.enableTest(' + JSON.stringify(name) + ');\n'); }); require("populist").buildP({ @@ -23,6 +33,7 @@ module.exports = function() { args: args }).then(function(output) { grunt.file.write(config.outfile, output); + theFilesToTestScript.end(); done(); }); };