Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated test harness
  • Loading branch information
rbuckton committed May 10, 2015
commit 28438bfaa8da48648a7d7f765b49f837a1978b06
23 changes: 14 additions & 9 deletions src/harness/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1162,12 +1162,20 @@ module Harness {
options?: ts.CompilerOptions,
// Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file
currentDirectory?: string) {
if (options.declaration && result.errors.length === 0 && (options.packageDeclaration ? result.declFilesCode.length !== 1 : result.declFilesCode.length !== result.files.length)) {
let expectedDeclFileCount = 0;
if (options.declaration) {
expectedDeclFileCount += result.files.length;
}
if (options.packageDeclaration) {
expectedDeclFileCount++;
}

if ((options.declaration || options.packageDeclaration) && result.errors.length === 0 && (result.declFilesCode.length !== expectedDeclFileCount)) {
throw new Error('There were no errors and declFiles generated did not match number of js files generated');
}

// if the .d.ts is non-empty, confirm it compiles correctly as well
if (options.declaration && result.errors.length === 0 && result.declFilesCode.length > 0) {
if ((options.declaration || options.packageDeclaration) && result.errors.length === 0 && result.declFilesCode.length > 0) {
var declInputFiles: { unitName: string; content: string }[] = [];
var declOtherFiles: { unitName: string; content: string }[] = [];
var declResult: Harness.Compiler.CompilerResult;
Expand All @@ -1176,13 +1184,10 @@ module Harness {
if (file) {
declInputFiles.push({ unitName: file.fileName, content: file.code });
}
ts.forEach(inputFiles, file => isDTS(file.unitName) && declInputFiles.push(file));
ts.forEach(otherFiles, file => isDTS(file.unitName) && declOtherFiles.push(file));
}
else {
ts.forEach(inputFiles, file => addDtsFile(file, declInputFiles));
ts.forEach(otherFiles, file => addDtsFile(file, declOtherFiles));
}

ts.forEach(inputFiles, file => addDtsFile(file, declInputFiles));
ts.forEach(otherFiles, file => addDtsFile(file, declOtherFiles));

this.compileFiles(declInputFiles, declOtherFiles, function (compileResult) { declResult = compileResult; },
settingsCallback, options, currentDirectory);
Expand All @@ -1193,7 +1198,7 @@ module Harness {
if (isDTS(file.unitName)) {
dtsFiles.push(file);
}
else if (isTS(file.unitName)) {
else if (isTS(file.unitName) && options.declaration) {
var declFile = findResultCodeFile(file.unitName);
if (!findUnit(declFile.fileName, declInputFiles) && !findUnit(declFile.fileName, declOtherFiles)) {
dtsFiles.push({ unitName: declFile.fileName, content: declFile.code });
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/packageDeclarationEmit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @module: commonjs
// @target: es5
// @declaration: true
// @packageName: app
// @packageMain: index.ts
// @packageDeclaration: app.d.ts
Expand Down