Blame view

bower_components/prism/tests/run.js 1.83 KB
eb240478   Luigi Serra   public room cards...
1
2
3
  "use strict";
  
  var TestDiscovery = require("./helper/test-discovery");
eb240478   Luigi Serra   public room cards...
4
5
  var path = require("path");
  var argv = require("yargs").argv;
f748e9cf   Luigi Serra   new controllet an...
6
  var child_process = require("child_process");
eb240478   Luigi Serra   public room cards...
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  
  var testSuite;
  if (argv.language) {
  	testSuite = TestDiscovery.loadSomeTests(__dirname + "/languages", argv.language);
  } else {
  	// load complete test suite
  	testSuite = TestDiscovery.loadAllTests(__dirname + "/languages");
  }
  
  // define tests for all tests in all languages in the test suite
  for (var language in testSuite) {
  	if (!testSuite.hasOwnProperty(language)) {
  		continue;
  	}
  
  	(function (language, testFiles) {
  		describe("Testing language '" + language + "'", function () {
f748e9cf   Luigi Serra   new controllet an...
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  			this.timeout(10000);
  
  			// Each set of tests runs in its own child process
  			var child;
  			before(function () {
  				child = child_process.fork(__dirname + "/run-child.js", ['--language=' + language], {
  					stdio: 'inherit'
  				});
  			});
  
  			after(function () {
  				child.kill();
  			});
  
eb240478   Luigi Serra   public room cards...
38
39
  			testFiles.forEach(
  				function (filePath) {
f748e9cf   Luigi Serra   new controllet an...
40
  			        var fileName = path.basename(filePath, path.extname(filePath));
eb240478   Luigi Serra   public room cards...
41
  
f748e9cf   Luigi Serra   new controllet an...
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
  			        it("– should pass test case '" + fileName + "'",
  			            function (done) {
  
  				            child.removeAllListeners('message');
  			                child.on('message', function (o) {
  				                // We have to delay the call,
  				                // otherwise the first message is received
  				                // over and over again.
  				                setTimeout(function() {
  					                if (o.error) {
  						                throw o.error;
  					                } else if (o.success) {
  						                done();
  					                }
  				                }, 1);
  			                });
  				            child.send({
  					            filePath: filePath
  				            });
  			            }
  			        );
eb240478   Luigi Serra   public room cards...
63
64
65
66
  				}
  			);
  		});
  	})(language, testSuite[language]);
f748e9cf   Luigi Serra   new controllet an...
67
  }