@@ -73,6 +73,9 @@ describe('version tests', () => {
73
73
74
74
describe ( 'installer tests' , ( ) => {
75
75
beforeAll ( async ( ) => {
76
+ process . env . RUNNER_TOOL_CACHE = toolDir ;
77
+ process . env . DOTNET_INSTALL_DIR = toolDir ;
78
+ process . env . RUNNER_TEMP = tempDir ;
76
79
await io . rmRF ( toolDir ) ;
77
80
await io . rmRF ( tempDir ) ;
78
81
} ) ;
@@ -84,23 +87,21 @@ describe('installer tests', () => {
84
87
} catch {
85
88
console . log ( 'Failed to remove test directories' ) ;
86
89
}
87
- } , 100000 ) ;
90
+ } , 30000 ) ;
88
91
89
92
it ( 'Resolving a normal generic version works' , async ( ) => {
90
93
const dotnetInstaller = new installer . DotnetCoreInstaller ( '3.1.x' ) ;
91
- let versInfo = await dotnetInstaller . resolveInfos (
92
- [ 'win-x64' ] ,
94
+ let versInfo = await dotnetInstaller . resolveVersion (
93
95
new installer . DotNetVersionInfo ( '3.1.x' )
94
96
) ;
95
97
96
- expect ( versInfo . resolvedVersion . startsWith ( '3.1.' ) ) ;
98
+ expect ( versInfo . startsWith ( '3.1.' ) ) ;
97
99
} , 100000 ) ;
98
100
99
101
it ( 'Resolving a nonexistent generic version fails' , async ( ) => {
100
102
const dotnetInstaller = new installer . DotnetCoreInstaller ( '999.1.x' ) ;
101
103
try {
102
- await dotnetInstaller . resolveInfos (
103
- [ 'win-x64' ] ,
104
+ await dotnetInstaller . resolveVersion (
104
105
new installer . DotNetVersionInfo ( '999.1.x' )
105
106
) ;
106
107
fail ( ) ;
@@ -111,53 +112,47 @@ describe('installer tests', () => {
111
112
112
113
it ( 'Resolving a exact stable version works' , async ( ) => {
113
114
const dotnetInstaller = new installer . DotnetCoreInstaller ( '3.1.201' ) ;
114
- let versInfo = await dotnetInstaller . resolveInfos (
115
- [ 'win-x64' ] ,
115
+ let versInfo = await dotnetInstaller . resolveVersion (
116
116
new installer . DotNetVersionInfo ( '3.1.201' )
117
117
) ;
118
118
119
- expect ( versInfo . resolvedVersion ) . toBe ( '3.1.201' ) ;
119
+ expect ( versInfo ) . toBe ( '3.1.201' ) ;
120
120
} , 100000 ) ;
121
121
122
122
it ( 'Resolving a exact preview version works' , async ( ) => {
123
123
const dotnetInstaller = new installer . DotnetCoreInstaller (
124
- '5.0.0-preview.4 '
124
+ '5.0.0-preview.6 '
125
125
) ;
126
- let versInfo = await dotnetInstaller . resolveInfos (
127
- [ 'win-x64' ] ,
128
- new installer . DotNetVersionInfo ( '5.0.0-preview.4' )
126
+ let versInfo = await dotnetInstaller . resolveVersion (
127
+ new installer . DotNetVersionInfo ( '5.0.0-preview.6' )
129
128
) ;
130
129
131
- expect ( versInfo . resolvedVersion ) . toBe ( '5.0.0-preview.4 ' ) ;
130
+ expect ( versInfo ) . toBe ( '5.0.0-preview.6 ' ) ;
132
131
} , 100000 ) ;
133
132
134
133
it ( 'Acquires version of dotnet if no matching version is installed' , async ( ) => {
135
- await getDotnet ( '2.2.205' ) ;
136
- const dotnetDir = path . join ( toolDir , 'dncs' , '2.2.205' , os . arch ( ) ) ;
137
-
138
- expect ( fs . existsSync ( `${ dotnetDir } .complete` ) ) . toBe ( true ) ;
134
+ await getDotnet ( '3.1.201' ) ;
135
+ expect ( fs . existsSync ( path . join ( toolDir , 'sdk' , '3.1.201' ) ) ) . toBe ( true ) ;
139
136
if ( IS_WINDOWS ) {
140
- expect ( fs . existsSync ( path . join ( dotnetDir , 'dotnet.exe' ) ) ) . toBe ( true ) ;
137
+ expect ( fs . existsSync ( path . join ( toolDir , 'dotnet.exe' ) ) ) . toBe ( true ) ;
141
138
} else {
142
- expect ( fs . existsSync ( path . join ( dotnetDir , 'dotnet' ) ) ) . toBe ( true ) ;
139
+ expect ( fs . existsSync ( path . join ( toolDir , 'dotnet' ) ) ) . toBe ( true ) ;
143
140
}
144
141
} , 400000 ) ; //This needs some time to download on "slower" internet connections
145
142
146
- it ( 'Acquires version of dotnet if no matching version is installed' , async ( ) => {
147
- const dotnetDir = path . join ( toolDir , 'dncs' , '2.2.105' , os . arch ( ) ) ;
148
-
143
+ it ( 'Acquires version of dotnet from global.json if no matching version is installed' , async ( ) => {
149
144
const globalJsonPath = path . join ( process . cwd ( ) , 'global.json' ) ;
150
- const jsonContents = `{${ os . EOL } "sdk": {${ os . EOL } "version": "2.2.105 "${ os . EOL } }${ os . EOL } }` ;
145
+ const jsonContents = `{${ os . EOL } "sdk": {${ os . EOL } "version": "3.1.201 "${ os . EOL } }${ os . EOL } }` ;
151
146
if ( ! fs . existsSync ( globalJsonPath ) ) {
152
147
fs . writeFileSync ( globalJsonPath , jsonContents ) ;
153
148
}
154
149
await setup . run ( ) ;
155
150
156
- expect ( fs . existsSync ( ` ${ dotnetDir } .complete` ) ) . toBe ( true ) ;
151
+ expect ( fs . existsSync ( path . join ( toolDir , 'sdk' , '3.1.201' ) ) ) . toBe ( true ) ;
157
152
if ( IS_WINDOWS ) {
158
- expect ( fs . existsSync ( path . join ( dotnetDir , 'dotnet.exe' ) ) ) . toBe ( true ) ;
153
+ expect ( fs . existsSync ( path . join ( toolDir , 'dotnet.exe' ) ) ) . toBe ( true ) ;
159
154
} else {
160
- expect ( fs . existsSync ( path . join ( dotnetDir , 'dotnet' ) ) ) . toBe ( true ) ;
155
+ expect ( fs . existsSync ( path . join ( toolDir , 'dotnet' ) ) ) . toBe ( true ) ;
161
156
}
162
157
fs . unlinkSync ( globalJsonPath ) ;
163
158
} , 100000 ) ;
@@ -170,30 +165,7 @@ describe('installer tests', () => {
170
165
thrown = true ;
171
166
}
172
167
expect ( thrown ) . toBe ( true ) ;
173
- } , 100000 ) ;
174
-
175
- it ( 'Uses version of dotnet installed in cache' , async ( ) => {
176
- const dotnetDir : string = path . join ( toolDir , 'dncs' , '250.0.0' , os . arch ( ) ) ;
177
- await io . mkdirP ( dotnetDir ) ;
178
- fs . writeFileSync ( `${ dotnetDir } .complete` , 'hello' ) ;
179
- // This will throw if it doesn't find it in the cache (because no such version exists)
180
- await getDotnet ( '250.0.0' ) ;
181
- return ;
182
- } ) ;
183
-
184
- it ( 'Doesnt use version of dotnet that was only partially installed in cache' , async ( ) => {
185
- const dotnetDir : string = path . join ( toolDir , 'dncs' , '251.0.0' , os . arch ( ) ) ;
186
- await io . mkdirP ( dotnetDir ) ;
187
- let thrown = false ;
188
- try {
189
- // This will throw if it doesn't find it in the cache (because no such version exists)
190
- await getDotnet ( '251.0.0' ) ;
191
- } catch {
192
- thrown = true ;
193
- }
194
- expect ( thrown ) . toBe ( true ) ;
195
- return ;
196
- } ) ;
168
+ } , 30000 ) ;
197
169
198
170
it ( 'Uses an up to date bash download script' , async ( ) => {
199
171
const httpCallbackClient = new hc . HttpClient ( 'setup-dotnet-test' , [ ] , {
@@ -213,7 +185,7 @@ describe('installer tests', () => {
213
185
expect ( normalizeFileContents ( currentContents ) ) . toBe (
214
186
normalizeFileContents ( upToDateContents )
215
187
) ;
216
- } , 100000 ) ;
188
+ } , 30000 ) ;
217
189
218
190
it ( 'Uses an up to date powershell download script' , async ( ) => {
219
191
var httpCallbackClient = new hc . HttpClient ( 'setup-dotnet-test' , [ ] , {
@@ -233,7 +205,7 @@ describe('installer tests', () => {
233
205
expect ( normalizeFileContents ( currentContents ) ) . toBe (
234
206
normalizeFileContents ( upToDateContents )
235
207
) ;
236
- } , 100000 ) ;
208
+ } , 30000 ) ;
237
209
} ) ;
238
210
239
211
function normalizeFileContents ( contents : string ) : string {
0 commit comments