@@ -470,19 +470,6 @@ namespace Utils {
470
470
}
471
471
}
472
472
473
- namespace Harness . Path {
474
- export function getFileName ( fullPath : string ) {
475
- return fullPath . replace ( / ^ .* [ \\ \/ ] / , "" ) ;
476
- }
477
-
478
- export function filePath ( fullPath : string ) {
479
- fullPath = ts . normalizeSlashes ( fullPath ) ;
480
- const components = fullPath . split ( "/" ) ;
481
- const path : string [ ] = components . slice ( 0 , components . length - 1 ) ;
482
- return path . join ( "/" ) + "/" ;
483
- }
484
- }
485
-
486
473
namespace Harness {
487
474
export interface IO {
488
475
newLine ( ) : string ;
@@ -1090,7 +1077,9 @@ namespace Harness {
1090
1077
{ name : "suppressOutputPathCheck" , type : "boolean" } ,
1091
1078
{ name : "noImplicitReferences" , type : "boolean" } ,
1092
1079
{ name : "currentDirectory" , type : "string" } ,
1093
- { name : "symlink" , type : "string" }
1080
+ { name : "symlink" , type : "string" } ,
1081
+ // Emitted js baseline will print full paths for every output file
1082
+ { name : "fullEmitPaths" , type : "boolean" }
1094
1083
] ;
1095
1084
1096
1085
let optionsIndex : ts . Map < ts . CommandLineOption > ;
@@ -1565,7 +1554,7 @@ namespace Harness {
1565
1554
return file . writeByteOrderMark ? "\u00EF\u00BB\u00BF" : "" ;
1566
1555
}
1567
1556
1568
- export function doSourcemapBaseline ( baselinePath : string , options : ts . CompilerOptions , result : CompilerResult ) {
1557
+ export function doSourcemapBaseline ( baselinePath : string , options : ts . CompilerOptions , result : CompilerResult , harnessSettings : Harness . TestCaseParser . CompilerSettings ) {
1569
1558
if ( options . inlineSourceMap ) {
1570
1559
if ( result . sourceMaps . length > 0 ) {
1571
1560
throw new Error ( "No sourcemap files should be generated if inlineSourceMaps was set." ) ;
@@ -1587,10 +1576,8 @@ namespace Harness {
1587
1576
}
1588
1577
1589
1578
let sourceMapCode = "" ;
1590
- for ( let i = 0 ; i < result . sourceMaps . length ; i ++ ) {
1591
- sourceMapCode += "//// [" + Harness . Path . getFileName ( result . sourceMaps [ i ] . fileName ) + "]\r\n" ;
1592
- sourceMapCode += getByteOrderMarkText ( result . sourceMaps [ i ] ) ;
1593
- sourceMapCode += result . sourceMaps [ i ] . code ;
1579
+ for ( const sourceMap of result . sourceMaps ) {
1580
+ sourceMapCode += fileOutput ( sourceMap , harnessSettings ) ;
1594
1581
}
1595
1582
1596
1583
return sourceMapCode ;
@@ -1611,23 +1598,19 @@ namespace Harness {
1611
1598
tsCode += "//// [" + header + "] ////\r\n\r\n" ;
1612
1599
}
1613
1600
for ( let i = 0 ; i < tsSources . length ; i ++ ) {
1614
- tsCode += "//// [" + Harness . Path . getFileName ( tsSources [ i ] . unitName ) + "]\r\n" ;
1601
+ tsCode += "//// [" + ts . getBaseFileName ( tsSources [ i ] . unitName ) + "]\r\n" ;
1615
1602
tsCode += tsSources [ i ] . content + ( i < ( tsSources . length - 1 ) ? "\r\n" : "" ) ;
1616
1603
}
1617
1604
1618
1605
let jsCode = "" ;
1619
- for ( let i = 0 ; i < result . files . length ; i ++ ) {
1620
- jsCode += "//// [" + Harness . Path . getFileName ( result . files [ i ] . fileName ) + "]\r\n" ;
1621
- jsCode += getByteOrderMarkText ( result . files [ i ] ) ;
1622
- jsCode += result . files [ i ] . code ;
1606
+ for ( const file of result . files ) {
1607
+ jsCode += fileOutput ( file , harnessSettings ) ;
1623
1608
}
1624
1609
1625
1610
if ( result . declFilesCode . length > 0 ) {
1626
1611
jsCode += "\r\n\r\n" ;
1627
- for ( let i = 0 ; i < result . declFilesCode . length ; i ++ ) {
1628
- jsCode += "//// [" + Harness . Path . getFileName ( result . declFilesCode [ i ] . fileName ) + "]\r\n" ;
1629
- jsCode += getByteOrderMarkText ( result . declFilesCode [ i ] ) ;
1630
- jsCode += result . declFilesCode [ i ] . code ;
1612
+ for ( const declFile of result . declFilesCode ) {
1613
+ jsCode += fileOutput ( declFile , harnessSettings ) ;
1631
1614
}
1632
1615
}
1633
1616
@@ -1652,6 +1635,11 @@ namespace Harness {
1652
1635
} ) ;
1653
1636
}
1654
1637
1638
+ function fileOutput ( file : GeneratedFile , harnessSettings : Harness . TestCaseParser . CompilerSettings ) : string {
1639
+ const fileName = harnessSettings [ "fullEmitPaths" ] ? file . fileName : ts . getBaseFileName ( file . fileName ) ;
1640
+ return "//// [" + fileName + "]\r\n" + getByteOrderMarkText ( file ) + file . code ;
1641
+ }
1642
+
1655
1643
export function collateOutputs ( outputFiles : Harness . Compiler . GeneratedFile [ ] ) : string {
1656
1644
// Collect, test, and sort the fileNames
1657
1645
outputFiles . sort ( ( a , b ) => ts . compareStrings ( cleanName ( a . fileName ) , cleanName ( b . fileName ) ) ) ;
@@ -1848,7 +1836,7 @@ namespace Harness {
1848
1836
}
1849
1837
1850
1838
// normalize the fileName for the single file case
1851
- currentFileName = testUnitData . length > 0 || currentFileName ? currentFileName : Path . getFileName ( fileName ) ;
1839
+ currentFileName = testUnitData . length > 0 || currentFileName ? currentFileName : ts . getBaseFileName ( fileName ) ;
1852
1840
1853
1841
// EOF, push whatever remains
1854
1842
const newTestFile2 = {
@@ -2012,7 +2000,7 @@ namespace Harness {
2012
2000
2013
2001
export function isDefaultLibraryFile ( filePath : string ) : boolean {
2014
2002
// We need to make sure that the filePath is prefixed with "lib." not just containing "lib." and end with ".d.ts"
2015
- const fileName = Path . getFileName ( filePath ) ;
2003
+ const fileName = ts . getBaseFileName ( filePath ) ;
2016
2004
return ts . startsWith ( fileName , "lib." ) && ts . endsWith ( fileName , ".d.ts" ) ;
2017
2005
}
2018
2006
0 commit comments