Generate the browser test list at built time
Thomas Aylott committed
Oct 28, 2013 at 14:51 UTC
001bda28d9e8e7bfda68eb03cf7e2cf2a367aedd
2 files changed
+13
-1
.gitignore
+1
@@ -23,3 +23,4 @@ docs/js/examples
23
docs/downloads
24
examples/shared/*.js
25
26
+test/the files to test.generated.js
\ No newline at end of file
grunt/tasks/populist.js
+12
-1
@@ -1,11 +1,19 @@
1
'use strict';
2
3
var grunt = require('grunt');
4
+var fs = require('fs')
5
6
module.exports = function() {
7
var config = this.data;
8
var done = this.async();
9
10
+ var theFilesToTestScript = fs.createWriteStream(__dirname + '/../../test/the files to test.generated.js');
11
+ theFilesToTestScript.write('// Generated by ');
12
+ theFilesToTestScript.write(JSON.stringify(__filename.split(/(?=grunt)/)[1]));
13
+ theFilesToTestScript.write(' at ');
14
+ theFilesToTestScript.write(JSON.stringify(new Date()));
15
+ theFilesToTestScript.write('\n\n');
16
+
17
// create the bundle we'll work with
18
var args = config.args;
19
@@ -15,7 +23,9 @@ module.exports = function() {
23
nonull: true, // Keep IDs that don't expand to anything.
24
cwd: config.rootDirectory
25
}, requires).forEach(function(name) {
18
- args.push(name.replace(/\.js$/i, ""));
26
+ name = name.replace(/\.js$/i, "");
27
+ args.push(name);
28
+ theFilesToTestScript.write('harness.enableTest(' + JSON.stringify(name) + ');\n');
29
});
30
31
require("populist").buildP({
@@ -23,6 +33,7 @@ module.exports = function() {
33
args: args
34
}).then(function(output) {
35
grunt.file.write(config.outfile, output);
36
+ theFilesToTestScript.end();
37
done();
38
});
39
};