Created
May 20, 2015 14:13
-
-
Save nicolas-cherel/ddddf03055955b10087a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/spec/env/common.js b/spec/env/common.js | |
index 9ffbc14..1882148 100644 | |
--- a/spec/env/common.js | |
+++ b/spec/env/common.js | |
@@ -1,16 +1,19 @@ | |
+var fs = require('fs'); | |
+var test_counter = 0; | |
+ | |
/*global CompilerContext, compileWithPartials, shouldCompileToWithPartials */ | |
global.shouldCompileTo = function(string, hashOrArray, expected, message) { | |
shouldCompileToWithPartials(string, hashOrArray, false, expected, message); | |
}; | |
global.shouldCompileToWithPartials = function(string, hashOrArray, partials, expected, message) { | |
- var result = compileWithPartials(string, hashOrArray, partials); | |
+ var result = compileWithPartials(string, hashOrArray, partials, expected, message); | |
if (result !== expected) { | |
throw new Error("'" + result + "' should === '" + expected + "': " + message); | |
} | |
}; | |
-global.compileWithPartials = function(string, hashOrArray, partials) { | |
+global.compileWithPartials = function(string, hashOrArray, partials, expected, message) { | |
var template, | |
ary, | |
options; | |
@@ -28,6 +31,48 @@ global.compileWithPartials = function(string, hashOrArray, partials) { | |
} | |
template = CompilerContext[partials ? 'compileWithPartial' : 'compile'](string, options); | |
+ | |
+ | |
+ var stream = fs.createWriteStream("/tmp/hb.dump", {flags: 'a'}); | |
+ stream.once('open', function(fd) { | |
+ if (Object.keys((ary[1] || {}).helpers || {}).length > 0) return; | |
+ | |
+ var has_func = false; | |
+ var stack = [ary[0]]; | |
+ var searched; | |
+ while ((searched = stack.pop())) { | |
+ for (var key in searched) { | |
+ var o = searched[key]; | |
+ if (typeof(o) == "object") { | |
+ stack.push(o) | |
+ } else { | |
+ if (typeof(o) == "function") { has_func = true; }; // detect and dissmiss on functions | |
+ } | |
+ } | |
+ } | |
+ | |
+ | |
+ if (! has_func) { | |
+ try { | |
+ var str = "hbtest!(" + (message||"test_").toLowerCase().replace(/\s+|[^a-zA-Z]+/g, "_").replace(/_+/g, "_") +test_counter + "_hb, " + | |
+ JSON.stringify((JSON.stringify({ | |
+ template: string, | |
+ data: ary[0], | |
+ partials: (ary[1] || {}).partials, | |
+ expected: expected, | |
+ message: message, | |
+ options: options | |
+ }))) + | |
+ ");\n"; | |
+ test_counter += 1; | |
+ stream.write(str); | |
+ } catch(e) { /*snip errors*/ } | |
+ } | |
+ | |
+ | |
+ }); | |
+ | |
+ | |
return template.apply(this, ary); | |
}; | |
diff --git a/spec/env/runner.js b/spec/env/runner.js | |
index 143d300..36d91c6 100644 | |
--- a/spec/env/runner.js | |
+++ b/spec/env/runner.js | |
@@ -13,11 +13,11 @@ var files = fs.readdirSync(testDir) | |
.map(function(name) { return testDir + '/' + name; }); | |
run('./node', function() { | |
- run('./browser', function() { | |
- run('./runtime', function() { | |
+ // run('./browser', function() { | |
+ // run('./runtime', function() { | |
process.exit(errors); | |
- }); | |
- }); | |
+ // }); | |
+ // }); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment