[Pkg-javascript-commits] [less.js] 24/38: some fixes to the tests and warn if render calls the callback multiple times

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:27:27 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag v2.2.0
in repository less.js.

commit f47875ea2817898b4315f6bd1f09c6bf8be3721d
Author: Luke Page <luke.a.page at gmail.com>
Date:   Sat Jan 3 14:52:50 2015 +0000

    some fixes to the tests and warn if render calls the callback multiple times
---
 test/index.js     |  1 +
 test/less-test.js | 40 ++++++++++++++++++++++++++++++----------
 2 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/test/index.js b/test/index.js
index d0778d6..4f7e510 100644
--- a/test/index.js
+++ b/test/index.js
@@ -46,3 +46,4 @@ lessTester.runTestSet({urlArgs: '424242'}, "url-args/");
 lessTester.testSyncronous({syncImport: true}, "import");
 lessTester.testSyncronous({syncImport: true}, "css");
 lessTester.testNoOptions();
+lessTester.finished();
\ No newline at end of file
diff --git a/test/less-test.js b/test/less-test.js
index 9d7ecef..f3919d9 100644
--- a/test/less-test.js
+++ b/test/less-test.js
@@ -9,21 +9,22 @@ module.exports = function() {
 
     var globals = Object.keys(global);
 
-    var oneTestOnly = process.argv[2];
+    var oneTestOnly = process.argv[2],
+	    isFinished = false;
 
     var isVerbose = process.env.npm_config_loglevel === 'verbose';
 
     less.logger.addListener({
         info: function(msg) {
             if (isVerbose) {
-                console.log(msg);
+                process.stdout.write(msg + "\n");
             }
         },
         warn: function(msg) {
-            console.warn(msg);
+	        process.stdout.write(msg + "\n");
         },
         error: function(msg) {
-            console.error(msg);
+	        process.stdout.write(msg + "\n");
         }
     });
 
@@ -31,17 +32,21 @@ module.exports = function() {
         queueRunning = false;
     function queue(func) {
         if (queueRunning) {
+	        //console.log("adding to queue");
             queueList.push(func);
         } else {
+	        //console.log("first in queue - starting");
             queueRunning = true;
             func();
         }
     }
     function release() {
         if (queueList.length) {
+	        //console.log("running next in queue");
             var func = queueList.shift();
-            func();
+	        setTimeout(func, 0);
         } else {
+	        //console.log("stopping queue");
             queueRunning = false;
         }
     }
@@ -131,6 +136,7 @@ module.exports = function() {
             } else {
                 fail("Not Sync");
             }
+	        release();
         });
         isSync = false;
         });
@@ -170,8 +176,17 @@ module.exports = function() {
                 return JSON.parse(fs.readFileSync(getFilename(getBasename(file), 'vars'), 'utf8'));
             };
 
+	        var doubleCallCheck = false;
             queue(function() {
             toCSS(options, path.join('test/less/', foldername + file), function (err, result) {
+	            if (doubleCallCheck) {
+		            totalTests++;
+		            fail("less is calling back twice");
+		            process.stdout.write(doubleCallCheck + "\n");
+		            process.stdout.write((new Error()).stack + "\n");
+		            return;
+	            }
+	            doubleCallCheck = (new Error()).stack;
 
                 if (verifyFunction) {
                     var verificationResult = verifyFunction(name, err, result && result.css, doReplacements, result && result.map);
@@ -235,11 +250,16 @@ module.exports = function() {
         passedTests++;
         endTest();
     }
+	
+	function finished() {
+		isFinished = true;
+		endTest();
+	}
 
     function endTest() {
-        var leaked = checkGlobalLeaks();
-
-        if (failedTests + passedTests === totalTests) {
+        if (isFinished && ((failedTests + passedTests) >= totalTests)) {
+	        var leaked = checkGlobalLeaks();
+	        
             process.stdout.write("\n");
             if (failedTests > 0) {
                 process.stdout.write(failedTests + stylize(" Failed", "red") + ", " + passedTests + " passed\n");
@@ -252,7 +272,6 @@ module.exports = function() {
             }
 
             if (leaked.length || failedTests) {
-                process.exit(1);
                 process.on('exit', function() { process.reallyExit(1); });
             }
         }
@@ -292,6 +311,7 @@ module.exports = function() {
         testSyncronous: testSyncronous,
         testErrors: testErrors,
         testSourcemap: testSourcemap,
-        testNoOptions: testNoOptions
+        testNoOptions: testNoOptions,
+	    finished: finished
     };
 };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git



More information about the Pkg-javascript-commits mailing list