@@ -2068,6 +2068,89 @@ func TestBuildProgramUpdates(t *testing.T) {
2068
2068
}
2069
2069
}
2070
2070
2071
+ func TestBuildProjectsBuilding (t * testing.T ) {
2072
+ t .Parallel ()
2073
+ addPackageFiles := func (files FileMap , index int ) {
2074
+ files [fmt .Sprintf (`/user/username/projects/myproject/pkg%d/index.ts` , index )] = fmt .Sprintf (`export const pkg%d = %d;` , index , index )
2075
+ var references string
2076
+ if index > 0 {
2077
+ references = `"references": [{ "path": "../pkg0" }],`
2078
+ }
2079
+ files [fmt .Sprintf (`/user/username/projects/myproject/pkg%d/tsconfig.json` , index )] = stringtestutil .Dedent (fmt .Sprintf (`
2080
+ {
2081
+ "compilerOptions": { "composite": true },
2082
+ %s
2083
+ }` , references ))
2084
+ }
2085
+ addSolution := func (files FileMap , count int ) {
2086
+ var pkgReferences []string
2087
+ for i := range count {
2088
+ pkgReferences = append (pkgReferences , fmt .Sprintf (`{ "path": "./pkg%d" }` , i ))
2089
+ }
2090
+ files [`/user/username/projects/myproject/tsconfig.json` ] = stringtestutil .Dedent (fmt .Sprintf (`
2091
+ {
2092
+ "compilerOptions": { "composite": true },
2093
+ "references": [
2094
+ %s
2095
+ ]
2096
+ }` , strings .Join (pkgReferences , ",\n \t \t \t \t " )))
2097
+ }
2098
+ files := func (count int ) FileMap {
2099
+ files := FileMap {}
2100
+ for i := range count {
2101
+ addPackageFiles (files , i )
2102
+ }
2103
+ addSolution (files , count )
2104
+ return files
2105
+ }
2106
+
2107
+ getTestCases := func (pkgCount int ) []* tscInput {
2108
+ edits := []* tscEdit {
2109
+ {
2110
+ caption : "dts doesn't change" ,
2111
+ edit : func (sys * testSys ) {
2112
+ sys .appendFile (`/user/username/projects/myproject/pkg0/index.ts` , `const someConst2 = 10;` )
2113
+ },
2114
+ },
2115
+ noChange ,
2116
+ {
2117
+ caption : "dts change" ,
2118
+ edit : func (sys * testSys ) {
2119
+ sys .appendFile (`/user/username/projects/myproject/pkg0/index.ts` , `export const someConst = 10;` )
2120
+ },
2121
+ },
2122
+ noChange ,
2123
+ }
2124
+ return []* tscInput {
2125
+ {
2126
+ subScenario : fmt .Sprintf (`when there are %d projects in a solution` , pkgCount ),
2127
+ files : files (pkgCount ),
2128
+ cwd : "/user/username/projects/myproject" ,
2129
+ commandLineArgs : []string {"-b" , "-v" },
2130
+ edits : edits ,
2131
+ },
2132
+ {
2133
+ subScenario : fmt .Sprintf (`when there are %d projects in a solution` , pkgCount ),
2134
+ files : files (pkgCount ),
2135
+ cwd : "/user/username/projects/myproject" ,
2136
+ commandLineArgs : []string {"-b" , "-w" , "-v" },
2137
+ edits : edits ,
2138
+ },
2139
+ }
2140
+ }
2141
+
2142
+ testCases := slices .Concat (
2143
+ getTestCases (3 ),
2144
+ getTestCases (5 ),
2145
+ getTestCases (8 ),
2146
+ getTestCases (23 ),
2147
+ )
2148
+
2149
+ for _ , test := range testCases {
2150
+ test .run (t , "projectsBuilding" )
2151
+ }
2152
+ }
2153
+
2071
2154
func TestBuildProjectReferenceWithRootDirInParent (t * testing.T ) {
2072
2155
t .Parallel ()
2073
2156
getBuildProjectReferenceWithRootDirInParentFileMap := func (modify func (files FileMap )) FileMap {
0 commit comments