@@ -1244,15 +1244,15 @@ namespace Harness {
1244
1244
options : ts . CompilerOptions ,
1245
1245
// Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file
1246
1246
currentDirectory : string ) : DeclarationCompilationContext | undefined {
1247
- if ( options . declaration && result . errors . length === 0 && result . declFilesCode . length !== result . files . length ) {
1247
+ if ( options . declaration && result . diagnostics . length === 0 && result . declFilesCode . length !== result . files . length ) {
1248
1248
throw new Error ( "There were no errors and declFiles generated did not match number of js files generated" ) ;
1249
1249
}
1250
1250
1251
1251
const declInputFiles : TestFile [ ] = [ ] ;
1252
1252
const declOtherFiles : TestFile [ ] = [ ] ;
1253
1253
1254
1254
// if the .d.ts is non-empty, confirm it compiles correctly as well
1255
- if ( options . declaration && result . errors . length === 0 && result . declFilesCode . length > 0 ) {
1255
+ if ( options . declaration && result . diagnostics . length === 0 && result . declFilesCode . length > 0 ) {
1256
1256
ts . forEach ( inputFiles , file => addDtsFile ( file , declInputFiles ) ) ;
1257
1257
ts . forEach ( otherFiles , file => addDtsFile ( file , declOtherFiles ) ) ;
1258
1258
return { declInputFiles, declOtherFiles, harnessSettings, options, currentDirectory : currentDirectory || harnessSettings . currentDirectory } ;
@@ -1264,8 +1264,8 @@ namespace Harness {
1264
1264
}
1265
1265
else if ( vpath . isTypeScript ( file . unitName ) ) {
1266
1266
const declFile = findResultCodeFile ( file . unitName ) ;
1267
- if ( declFile && ! findUnit ( declFile . fileName , declInputFiles ) && ! findUnit ( declFile . fileName , declOtherFiles ) ) {
1268
- dtsFiles . push ( { unitName : declFile . fileName , content : declFile . code } ) ;
1267
+ if ( declFile && ! findUnit ( declFile . file , declInputFiles ) && ! findUnit ( declFile . file , declOtherFiles ) ) {
1268
+ dtsFiles . push ( { unitName : declFile . file , content : core . removeByteOrderMark ( declFile . text ) } ) ;
1269
1269
}
1270
1270
}
1271
1271
}
@@ -1278,7 +1278,7 @@ namespace Harness {
1278
1278
const outFile = options . outFile || options . out ;
1279
1279
if ( ! outFile ) {
1280
1280
if ( options . outDir ) {
1281
- let sourceFilePath = ts . getNormalizedAbsolutePath ( sourceFile . fileName , result . currentDirectoryForProgram ) ;
1281
+ let sourceFilePath = ts . getNormalizedAbsolutePath ( sourceFile . fileName , result . vfs . currentDirectory ) ;
1282
1282
sourceFilePath = sourceFilePath . replace ( result . program . getCommonSourceDirectory ( ) , "" ) ;
1283
1283
sourceFileName = ts . combinePaths ( options . outDir , sourceFilePath ) ;
1284
1284
}
@@ -1293,7 +1293,7 @@ namespace Harness {
1293
1293
1294
1294
const dTsFileName = ts . removeFileExtension ( sourceFileName ) + ts . Extension . Dts ;
1295
1295
1296
- return ts . forEach ( result . declFilesCode , declFile => declFile . fileName === dTsFileName ? declFile : undefined ) ;
1296
+ return ts . forEach ( result . declFilesCode , declFile => declFile . file === dTsFileName ? declFile : undefined ) ;
1297
1297
}
1298
1298
1299
1299
function findUnit ( fileName : string , units : TestFile [ ] ) {
@@ -1602,10 +1602,6 @@ namespace Harness {
1602
1602
}
1603
1603
}
1604
1604
1605
- function getByteOrderMarkText ( file : Harness . Compiler . GeneratedFile ) : string {
1606
- return file . writeByteOrderMark ? "\u00EF\u00BB\u00BF" : "" ;
1607
- }
1608
-
1609
1605
export function doSourcemapBaseline ( baselinePath : string , options : ts . CompilerOptions , result : compiler . CompilationResult , harnessSettings : Harness . TestCaseParser . CompilerSettings ) {
1610
1606
if ( options . inlineSourceMap ) {
1611
1607
if ( result . sourceMaps . length > 0 ) {
@@ -1619,7 +1615,7 @@ namespace Harness {
1619
1615
}
1620
1616
1621
1617
Harness . Baseline . runBaseline ( baselinePath . replace ( / \. t s x ? / , ".js.map" ) , ( ) => {
1622
- if ( ( options . noEmitOnError && result . errors . length !== 0 ) || result . sourceMaps . length === 0 ) {
1618
+ if ( ( options . noEmitOnError && result . diagnostics . length !== 0 ) || result . sourceMaps . length === 0 ) {
1623
1619
// We need to return null here or the runBaseLine will actually create a empty file.
1624
1620
// Baselining isn't required here because there is no output.
1625
1621
/* tslint:disable:no-null-keyword */
@@ -1638,7 +1634,7 @@ namespace Harness {
1638
1634
}
1639
1635
1640
1636
export function doJsEmitBaseline ( baselinePath : string , header : string , options : ts . CompilerOptions , result : compiler . CompilationResult , tsConfigFiles : ReadonlyArray < Harness . Compiler . TestFile > , toBeCompiled : ReadonlyArray < Harness . Compiler . TestFile > , otherFiles : ReadonlyArray < Harness . Compiler . TestFile > , harnessSettings : Harness . TestCaseParser . CompilerSettings ) {
1641
- if ( ! options . noEmit && result . files . length === 0 && result . errors . length === 0 ) {
1637
+ if ( ! options . noEmit && result . files . length === 0 && result . diagnostics . length === 0 ) {
1642
1638
throw new Error ( "Expected at least one js file to be emitted or at least one error to be created." ) ;
1643
1639
}
1644
1640
@@ -1671,10 +1667,10 @@ namespace Harness {
1671
1667
) ;
1672
1668
const declFileCompilationResult = Harness . Compiler . compileDeclarationFiles ( declFileContext ) ;
1673
1669
1674
- if ( declFileCompilationResult && declFileCompilationResult . declResult . errors . length ) {
1670
+ if ( declFileCompilationResult && declFileCompilationResult . declResult . diagnostics . length ) {
1675
1671
jsCode += "\r\n\r\n//// [DtsFileErrors]\r\n" ;
1676
1672
jsCode += "\r\n\r\n" ;
1677
- jsCode += Harness . Compiler . getErrorBaseline ( tsConfigFiles . concat ( declFileCompilationResult . declInputFiles , declFileCompilationResult . declOtherFiles ) , declFileCompilationResult . declResult . errors ) ;
1673
+ jsCode += Harness . Compiler . getErrorBaseline ( tsConfigFiles . concat ( declFileCompilationResult . declInputFiles , declFileCompilationResult . declOtherFiles ) , declFileCompilationResult . declResult . diagnostics ) ;
1678
1674
}
1679
1675
1680
1676
if ( jsCode . length > 0 ) {
@@ -1688,12 +1684,12 @@ namespace Harness {
1688
1684
} ) ;
1689
1685
}
1690
1686
1691
- function fileOutput ( file : GeneratedFile , harnessSettings : Harness . TestCaseParser . CompilerSettings ) : string {
1692
- const fileName = harnessSettings . fullEmitPaths ? utils . removeTestPathPrefixes ( file . fileName ) : ts . getBaseFileName ( file . fileName ) ;
1693
- return "//// [" + fileName + "]\r\n" + getByteOrderMarkText ( file ) + utils . removeTestPathPrefixes ( file . code ) ;
1687
+ function fileOutput ( file : documents . TextDocument , harnessSettings : Harness . TestCaseParser . CompilerSettings ) : string {
1688
+ const fileName = harnessSettings . fullEmitPaths ? utils . removeTestPathPrefixes ( file . file ) : ts . getBaseFileName ( file . file ) ;
1689
+ return "//// [" + fileName + "]\r\n" + utils . removeTestPathPrefixes ( file . text ) ;
1694
1690
}
1695
1691
1696
- export function collateOutputs ( outputFiles : ReadonlyArray < Harness . Compiler . GeneratedFile > ) : string {
1692
+ export function collateOutputs ( outputFiles : ReadonlyArray < documents . TextDocument > ) : string {
1697
1693
const gen = iterateOutputs ( outputFiles ) ;
1698
1694
// Emit them
1699
1695
let result = "" ;
@@ -1709,13 +1705,13 @@ namespace Harness {
1709
1705
return result ;
1710
1706
}
1711
1707
1712
- export function * iterateOutputs ( outputFiles : ReadonlyArray < Harness . Compiler . GeneratedFile > ) : IterableIterator < [ string , string ] > {
1708
+ export function * iterateOutputs ( outputFiles : ReadonlyArray < documents . TextDocument > ) : IterableIterator < [ string , string ] > {
1713
1709
// Collect, test, and sort the fileNames
1714
- outputFiles . slice ( ) . sort ( ( a , b ) => ts . compareStringsCaseSensitive ( cleanName ( a . fileName ) , cleanName ( b . fileName ) ) ) ;
1710
+ outputFiles . slice ( ) . sort ( ( a , b ) => ts . compareStringsCaseSensitive ( cleanName ( a . file ) , cleanName ( b . file ) ) ) ;
1715
1711
const dupeCase = ts . createMap < number > ( ) ;
1716
1712
// Yield them
1717
1713
for ( const outputFile of outputFiles ) {
1718
- yield [ checkDuplicatedFileName ( outputFile . fileName , dupeCase ) , "/*====== " + outputFile . fileName + " ======*/\r\n" + outputFile . code ] ;
1714
+ yield [ checkDuplicatedFileName ( outputFile . file , dupeCase ) , "/*====== " + outputFile . file + " ======*/\r\n" + core . removeByteOrderMark ( outputFile . text ) ] ;
1719
1715
}
1720
1716
1721
1717
function cleanName ( fn : string ) {
@@ -1745,12 +1741,6 @@ namespace Harness {
1745
1741
}
1746
1742
return path ;
1747
1743
}
1748
-
1749
- export interface GeneratedFile {
1750
- fileName : string ;
1751
- code : string ;
1752
- writeByteOrderMark : boolean ;
1753
- }
1754
1744
}
1755
1745
1756
1746
export namespace TestCaseParser {
0 commit comments