@@ -125,7 +125,7 @@ let ensureDefaultFSharpCoreAvailable tmpDir =
125
125
File.Copy( fsCoreDefaultReference(), Path.Combine( tmpDir, Path.GetFileName( fsCoreDefaultReference())), overwrite = true )
126
126
#endif
127
127
128
- let compile isDll debugMode ( assemblyName : string ) ( ext : string ) ( code : string ) ( dependencies : string list ) =
128
+ let compile isDll debugMode ( assemblyName : string ) ( ext : string ) ( code : string ) ( dependencies : string list ) ( extraArgs : string list ) =
129
129
let tmp = Path.Combine( Path.GetTempPath(), " test" + string( hash ( isDll, debugMode, assemblyName, code, dependencies)))
130
130
try Directory.CreateDirectory( tmp) |> ignore with _ -> ()
131
131
let sourceFile = Path.Combine( tmp, assemblyName + " ." + ext)
@@ -156,7 +156,10 @@ let compile isDll debugMode (assemblyName : string) (ext: string) (code : string
156
156
157
157
yield sprintf " --out:%s " outFile
158
158
159
+ yield ! extraArgs
160
+
159
161
yield sourceFile
162
+
160
163
|]
161
164
162
165
ensureDefaultFSharpCoreAvailable tmp
@@ -172,7 +175,7 @@ let compile isDll debugMode (assemblyName : string) (ext: string) (code : string
172
175
//sizeof<nativeint>
173
176
let compileAndVerify isDll debugMode assemblyName ext code dependencies =
174
177
let verifier = new PEVerifier ()
175
- let outFile = compile isDll debugMode assemblyName ext code dependencies
178
+ let outFile = compile isDll debugMode assemblyName ext code dependencies []
176
179
verifier.Verify outFile
177
180
outFile
178
181
@@ -293,7 +296,8 @@ module Bar
293
296
294
297
"""
295
298
try
296
- compile false PdbOnly " Bar" " fs" code [] |> ignore
299
+ let outFile : string = compile false PdbOnly " Bar" " fs" code [] []
300
+ ()
297
301
with
298
302
| :? CompilationError as exn ->
299
303
Assert.AreEqual( 6 , exn.Data2.[ 0 ]. StartLineAlternate)
@@ -305,7 +309,8 @@ let ``Check cols are indexed by 1`` () =
305
309
let code = " let x = 1 + a"
306
310
307
311
try
308
- compile false PdbOnly " Foo" " fs" code [] |> ignore
312
+ let outFile : string = compile false PdbOnly " Foo" " fs" code [] []
313
+ ()
309
314
with
310
315
| :? CompilationError as exn ->
311
316
Assert.True( exn.Data2.[ 0 ]. ToString() .Contains( " Foo.fs (1,13)-(1,14)" ))
@@ -320,7 +325,8 @@ let ``Check compile of bad fsx`` () =
320
325
"""
321
326
322
327
try
323
- compile false PdbOnly " Foo" " fsx" code [] |> ignore
328
+ let outFile : string = compile false PdbOnly " Foo" " fsx" code [] []
329
+ ()
324
330
with
325
331
| :? CompilationError as exn ->
326
332
Assert.True( exn.Data2.[ 0 ]. ToString() .Contains( " Could not load file '" ))
@@ -329,6 +335,21 @@ let ``Check compile of bad fsx`` () =
329
335
| _ -> failwith " No compilation error"
330
336
331
337
338
+ [<Test>]
339
+ let ``Check compile of good fsx with bad option`` () =
340
+ let code = """
341
+ let x = 1
342
+ """
343
+
344
+ try
345
+ let outFile : string = compile false PdbOnly " Foo" " fsx" code [] [ " -r:missing.dll" ]
346
+ ()
347
+ with
348
+ | :? CompilationError as exn ->
349
+ Assert.True( exn.Data2.[ 0 ]. ToString() .Contains( " startup (1,1)-(1,81) parameter error Could not resolve this reference" ))
350
+ | _ -> failwith " No compilation error"
351
+
352
+
332
353
#if STRESS
333
354
// For this stress test the aim is to check if we have a memory leak
334
355
@@ -348,7 +369,8 @@ type C() =
348
369
let x = 3 + 4
349
370
"""
350
371
351
- compile true PdbOnly " Foo" code [] |> ignore
372
+ let outFile : string = compile true PdbOnly " Foo" " fs" code [] []
373
+ ()
352
374
353
375
#endif
354
376
0 commit comments