Fix node.js tests on Windows agents in Teamcity
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -176,7 +176,7 @@ abstract class BasicBoxTest(
|
|||||||
ignored: Boolean,
|
ignored: Boolean,
|
||||||
testPackage: String?
|
testPackage: String?
|
||||||
): String {
|
): String {
|
||||||
val filesToLoad = files.map { FileUtil.getRelativePath(dir, File(it))!! }.map { "\"$it\"" }
|
val filesToLoad = files.map { FileUtil.getRelativePath(dir, File(it))!!.replace(File.separatorChar, '/') }.map { "\"$it\"" }
|
||||||
val fqn = testPackage?.let { ".$it" } ?: ""
|
val fqn = testPackage?.let { ".$it" } ?: ""
|
||||||
val loadAndRun = "load([${filesToLoad.joinToString(",")}], '$moduleName')$fqn.box()"
|
val loadAndRun = "load([${filesToLoad.joinToString(",")}], '$moduleName')$fqn.box()"
|
||||||
|
|
||||||
|
|||||||
+3
@@ -5,5 +5,8 @@
|
|||||||
"devDependencies" : {
|
"devDependencies" : {
|
||||||
"mocha": "3.2.0",
|
"mocha": "3.2.0",
|
||||||
"mocha-teamcity-reporter": "1.1.1"
|
"mocha-teamcity-reporter": "1.1.1"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "mocha --reporter mocha-teamcity-reporter"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vendored
+17
-16
@@ -1,7 +1,11 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var path = require('path');
|
||||||
|
var assert = require('assert');
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
var kotlinJsLocation = process.env.KOTLIN_JS_LOCATION || __dirname + "/../../../dist/js/kotlin.js";
|
var kotlinJsLocation = process.env.KOTLIN_JS_LOCATION || path.resolve(__dirname, "../../../dist/js/kotlin.js");
|
||||||
var Module = require('module');
|
var Module = require('module');
|
||||||
var originalRequire = Module.prototype.require;
|
var originalRequire = Module.prototype.require;
|
||||||
|
|
||||||
@@ -13,10 +17,7 @@
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
var assert = require('assert');
|
var kotlinJsTestLocation = process.env.KOTLIN_JS_TEST_LOCATION || path.resolve(__dirname, "../../../dist/js/kotlin-test.js");
|
||||||
var fs = require('fs');
|
|
||||||
var path = require('path');
|
|
||||||
var kotlinJsTestLocation = process.env.KOTLIN_JS_TEST_LOCATION || __dirname + "/../../../dist/js/kotlin-test.js";
|
|
||||||
|
|
||||||
var kotlin = require("kotlin");
|
var kotlin = require("kotlin");
|
||||||
var kotlinTest = require(kotlinJsTestLocation);
|
var kotlinTest = require(kotlinJsTestLocation);
|
||||||
@@ -25,15 +26,15 @@ var requireFromString = require('require-from-string');
|
|||||||
|
|
||||||
var baseDir = "out";
|
var baseDir = "out";
|
||||||
var model = generateModel(baseDir);
|
var model = generateModel(baseDir);
|
||||||
exposeModel(model, "./" + baseDir);
|
exposeModel(model, path.resolve(baseDir));
|
||||||
|
|
||||||
function exposeModel(model, path) {
|
function exposeModel(model, currentPath) {
|
||||||
for (var property in model) {
|
for (var property in model) {
|
||||||
if (!model.hasOwnProperty(property)) {
|
if (!model.hasOwnProperty(property)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var childPath = path + "/" + property;
|
var childPath = path.join(currentPath, property);
|
||||||
var item = model[property];
|
var item = model[property];
|
||||||
describe(property, function(childPath, item) {
|
describe(property, function(childPath, item) {
|
||||||
return function() {
|
return function() {
|
||||||
@@ -52,18 +53,18 @@ function exposeModel(model, path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param path String
|
* @param currentPath String
|
||||||
* @returns String|{}
|
* @returns String|{}
|
||||||
*/
|
*/
|
||||||
function generateModel(path) {
|
function generateModel(currentPath) {
|
||||||
var stats = fs.statSync(path);
|
var stats = fs.statSync(currentPath);
|
||||||
if (stats.isDirectory()) {
|
if (stats.isDirectory()) {
|
||||||
var result = {};
|
var result = {};
|
||||||
var files = fs.readdirSync(path);
|
var files = fs.readdirSync(currentPath);
|
||||||
var empty = true;
|
var empty = true;
|
||||||
for (var i = 0; i < files.length; ++i) {
|
for (var i = 0; i < files.length; ++i) {
|
||||||
var child = files[i];
|
var child = files[i];
|
||||||
var childModel = generateModel(path + "/" + child);
|
var childModel = generateModel(path.join(currentPath, child));
|
||||||
if (childModel !== void 0) {
|
if (childModel !== void 0) {
|
||||||
result[child] = childModel;
|
result[child] = childModel;
|
||||||
empty = false;
|
empty = false;
|
||||||
@@ -72,8 +73,8 @@ function generateModel(path) {
|
|||||||
return !empty ? result : void 0;
|
return !empty ? result : void 0;
|
||||||
}
|
}
|
||||||
else if (stats.isFile()) {
|
else if (stats.isFile()) {
|
||||||
if (path.endsWith(".node.js")) {
|
if (currentPath.endsWith(".node.js")) {
|
||||||
return path;
|
return currentPath;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return void 0;
|
return void 0;
|
||||||
@@ -92,7 +93,7 @@ function runTest(testRunner, location) {
|
|||||||
text += 'module.exports = function(kotlin) {\n';
|
text += 'module.exports = function(kotlin) {\n';
|
||||||
text += "var exports = void 0;";
|
text += "var exports = void 0;";
|
||||||
for (var i = 0; i < fileNames.length; ++i) {
|
for (var i = 0; i < fileNames.length; ++i) {
|
||||||
text += fs.readFileSync(basePath + "/" + fileNames[i]) + "\n";
|
text += fs.readFileSync(path.resolve(basePath, fileNames[i])) + "\n";
|
||||||
}
|
}
|
||||||
text += 'var resultModule = typeof emulatedModules != "undefined" ? emulatedModules.' + moduleName + ' : null;\n';
|
text += 'var resultModule = typeof emulatedModules != "undefined" ? emulatedModules.' + moduleName + ' : null;\n';
|
||||||
text += "resultModule = resultModule || this." + moduleName + ";\n";
|
text += "resultModule = resultModule || this." + moduleName + ";\n";
|
||||||
|
|||||||
+5
-4
@@ -44,9 +44,11 @@
|
|||||||
|
|
||||||
<move file="${dependencies}/${node.full.name}" tofile="${dependencies}/node"/>
|
<move file="${dependencies}/${node.full.name}" tofile="${dependencies}/node"/>
|
||||||
<delete dir="${dependencies}/${node.full.name}"/>
|
<delete dir="${dependencies}/${node.full.name}"/>
|
||||||
|
<delete file="${node.tar.gz}"/>
|
||||||
|
|
||||||
<sequential if:set="isWindows">
|
<sequential if:set="isWindows">
|
||||||
<get src="${url.node.exe}" dest="${node.exe}" usetimestamp="true"/>
|
<get src="${url.node.exe}" dest="${node.exe}" usetimestamp="true"/>
|
||||||
|
<delete file="${node.executable}"/>
|
||||||
</sequential>
|
</sequential>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
@@ -122,9 +124,8 @@
|
|||||||
|
|
||||||
<target name="run-nodejs-tests" description="Run JS backend tests in node.js" depends="download-nodejs-and-npm">
|
<target name="run-nodejs-tests" description="Run JS backend tests in node.js" depends="download-nodejs-and-npm">
|
||||||
<npm command="install" dir="js/js.translator/testData" />
|
<npm command="install" dir="js/js.translator/testData" />
|
||||||
<exec executable="node_modules/mocha/bin/mocha" dir="js/js.translator/testData" failonerror="true">
|
<npm command="run" dir="js/js.translator/testData">
|
||||||
<arg value="--reporter"/>
|
<arg value="test"/>
|
||||||
<arg value="mocha-teamcity-reporter"/>
|
</npm>
|
||||||
</exec>
|
|
||||||
</target>
|
</target>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
Reference in New Issue
Block a user