Generate the browser test list at built time

This commit is contained in:
Thomas Aylott
2013-10-28 14:51:52 -04:00
parent 28eddd1670
commit 001bda28d9
2 changed files with 13 additions and 1 deletions

1
.gitignore vendored
View File

@@ -23,3 +23,4 @@ docs/js/examples
docs/downloads
examples/shared/*.js
test/the files to test.generated.js

View File

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