Fix node-tests on OSX by explicitly requiring modules with relative paths.

This commit is contained in:
Hristo Deshev
2016-05-30 12:41:18 +03:00
parent b812411ce1
commit 2ebe9d681a
4 changed files with 13 additions and 10 deletions

View File

@ -152,7 +152,7 @@ module.exports = function(grunt) {
}; };
var nodeTestEnv = JSON.parse(JSON.stringify(process.env)); var nodeTestEnv = JSON.parse(JSON.stringify(process.env));
nodeTestEnv.NODE_PATH = localCfg.outTnsCoreModules nodeTestEnv.NODE_PATH = localCfg.outTnsCoreModules;
localCfg.nodeTestsDir = path.join(localCfg.outDir, 'node-tests'); localCfg.nodeTestsDir = path.join(localCfg.outDir, 'node-tests');
@ -546,10 +546,10 @@ module.exports = function(grunt) {
grunt.file.write(combinedDtsPath, dtsLines.join('\n')); grunt.file.write(combinedDtsPath, dtsLines.join('\n'));
} }
function generateModulesDts(outDir) { function generateModulesDts(outDir) {
var angularConflicts = ['module.d.ts'] var angularConflicts = ['module.d.ts'];
var angularExcludes = angularConflicts.map(function(file) { var angularExcludes = angularConflicts.map(function(file) {
return '!' + file; return '!' + file;
}) });
var nonES6Files = [ var nonES6Files = [
'es-collections.d.ts', 'es-collections.d.ts',
'es6-promise.d.ts', 'es6-promise.d.ts',
@ -558,7 +558,7 @@ module.exports = function(grunt) {
]; ];
var es6Excludes = nonES6Files.map(function(file) { var es6Excludes = nonES6Files.map(function(file) {
return '!' + file; return '!' + file;
}) });
var dtsFiles = grunt.file.expand({cwd: localCfg.outTnsCoreModules }, [ var dtsFiles = grunt.file.expand({cwd: localCfg.outTnsCoreModules }, [
"**/*.d.ts", "**/*.d.ts",
//Exclude the d.ts files in the apps folder - these are part of the apps and are already packed there! //Exclude the d.ts files in the apps folder - these are part of the apps and are already packed there!
@ -582,8 +582,8 @@ module.exports = function(grunt) {
writeDtsFile(es6Files, outDir, 'tns-core-modules/tns-core-modules.es6.d.ts'); writeDtsFile(es6Files, outDir, 'tns-core-modules/tns-core-modules.es6.d.ts');
var allFiles = angularConflicts.concat(nonES6Files).concat(['tns-core-modules.base.d.ts']); var allFiles = angularConflicts.concat(nonES6Files).concat(['tns-core-modules.base.d.ts']);
writeDtsFile(allFiles, outDir, 'tns-core-modules/tns-core-modules.d.ts'); writeDtsFile(allFiles, outDir, 'tns-core-modules/tns-core-modules.d.ts');
}; }
grunt.registerTask("processTestsApp", function(outTestsAppDir, pkgAppNameSuffix) { grunt.registerTask("processTestsApp", function(outTestsAppDir, pkgAppNameSuffix) {
var tasks = [ var tasks = [
{ {

1
node-tests/node-shims.ts Normal file
View File

@ -0,0 +1 @@
declare var require: any;

View File

@ -1,5 +1,6 @@
import {assert} from "chai"; import {assert} from "chai";
import xml = require('xml'); import * as xmlModule from "xml";
var xml: typeof xmlModule = require("../tns-core-modules/xml");
describe("angular xml parser", () => { describe("angular xml parser", () => {
let last_element = null; let last_element = null;
@ -7,7 +8,7 @@ describe("angular xml parser", () => {
let parser = null; let parser = null;
beforeEach(() => { beforeEach(() => {
parser = new xml.XmlParser(function (event: xml.ParserEvent) { parser = new xml.XmlParser(function (event: xmlModule.ParserEvent) {
switch (event.eventType) { switch (event.eventType) {
case xml.ParserEventType.StartElement: case xml.ParserEventType.StartElement:
last_element = event.elementName; last_element = event.elementName;

View File

@ -1,5 +1,6 @@
import {assert} from "chai"; import {assert} from "chai";
import xml = require('xml'); import * as xmlModule from "xml";
var xml: typeof xmlModule = require("../tns-core-modules/xml");
describe("xml parser", () => { describe("xml parser", () => {
let last_element = null; let last_element = null;
@ -8,7 +9,7 @@ describe("xml parser", () => {
let parser = null; let parser = null;
beforeEach(() => { beforeEach(() => {
parser = new xml.XmlParser(function (event: xml.ParserEvent) { parser = new xml.XmlParser(function (event: xmlModule.ParserEvent) {
switch (event.eventType) { switch (event.eventType) {
case xml.ParserEventType.StartElement: case xml.ParserEventType.StartElement:
last_element = event.elementName; last_element = event.elementName;