Skip to content

Commit 5ae912c

Browse files
authored
Skip tests using nuget from signed builds (#19111) (#19159)
2 parents d506d82 + a84178b commit 5ae912c

File tree

5 files changed

+61
-38
lines changed

5 files changed

+61
-38
lines changed

tests/FSharp.Compiler.Private.Scripting.UnitTests/DependencyManagerInteractiveTests.fs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type DependencyManagerInteractiveTests() =
3939
let getErrors ((_value: Result<FsiValue option, exn>), (errors: FSharpDiagnostic[])) =
4040
errors
4141

42-
[<Fact>]
42+
[<FSharp.Test.FactSkipOnSignedBuild>]
4343
member _.``SmokeTest - #r nuget``() =
4444
let text = """
4545
#r @"nuget:Newtonsoft.Json, Version=9.0.1"
@@ -50,7 +50,7 @@ type DependencyManagerInteractiveTests() =
5050
Assert.Equal(typeof<int>, value.ReflectionType)
5151
Assert.Equal(0, value.ReflectionValue :?> int)
5252

53-
[<Fact>]
53+
[<FSharp.Test.FactSkipOnSignedBuild>]
5454
member _.``SmokeTest - #r nuget package not found``() =
5555
let text = """
5656
#r @"nuget:System.Collections.Immutable.DoesNotExist, version=1.5.0"
@@ -259,7 +259,7 @@ TorchSharp.Tensor.LongTensor.From([| 0L .. 100L |]).Device
259259
()
260260

261261

262-
[<Fact>]
262+
[<FSharp.Test.FactSkipOnSignedBuild>]
263263
member _.``Use Dependency Manager to restore packages with native dependencies, build and run script that depends on the results``() =
264264
// Skip test on arm64, because there is not an arm64 native library
265265
if RuntimeInformation.ProcessArchitecture = Architecture.Arm64 then
@@ -358,7 +358,7 @@ printfn ""%A"" result
358358
let value = opt.Value
359359
Assert.Equal(123, value.ReflectionValue :?> int32)
360360

361-
[<Fact>]
361+
[<FSharp.Test.FactSkipOnSignedBuild>]
362362
member _.``Use NativeResolver to resolve native dlls.``() =
363363
// Skip test on arm64, because there is not an arm64 native library
364364
if RuntimeInformation.ProcessArchitecture = Architecture.Arm64 then
@@ -442,7 +442,7 @@ printfn ""%A"" result
442442
let value = opt.Value
443443
Assert.Equal(123, value.ReflectionValue :?> int32)
444444

445-
[<Fact>]
445+
[<FSharp.Test.FactSkipOnSignedBuild>]
446446
member _.``Use AssemblyResolver to resolve assemblies``() =
447447
// Skip test on arm64, because there is not an arm64 native library
448448
if RuntimeInformation.ProcessArchitecture = Architecture.Arm64 then

tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ stacktype.Name = "Stack"
168168
| Error(ex) -> Assert.IsAssignableFrom(typeof<FsiCompilationException>, ex)
169169

170170

171-
[<Fact>]
171+
[<FSharp.Test.FactSkipOnSignedBuild>]
172172
member _.``Script using System.Configuration succeeds``() =
173173
use script = new FSharpScript()
174174
let result, errors = script.Eval("""
@@ -246,7 +246,7 @@ System.Configuration.ConfigurationManager.AppSettings.Item "Environment" <- "LOC
246246

247247
/// Native dll resolution is not implemented on desktop
248248
#if NETSTANDARD
249-
[<Fact>]
249+
[<FSharp.Test.FactSkipOnSignedBuild>]
250250
member _.``ML - use assembly with native dependencies``() =
251251
// Skip test on arm64, because there is not an arm64 native library
252252
if RuntimeInformation.ProcessArchitecture = Architecture.Arm64 then
@@ -304,7 +304,7 @@ printfn "{@"%A"}" result
304304
| Ok(_) -> Assert.False(true, "expected a failure")
305305
| Error(ex) -> Assert.IsAssignableFrom(typeof<FsiCompilationException>, ex)
306306

307-
[<Fact>]
307+
[<FSharp.Test.FactSkipOnSignedBuild>]
308308
member _.``Eval script with invalid PackageName should fail immediately``() =
309309
use capture = new TestConsole.ExecutionCapture()
310310
use script = new FSharpScript(additionalArgs=[| |])
@@ -316,7 +316,7 @@ printfn "{@"%A"}" result
316316
Assert.True( errors |> Seq.exists (fun error -> error.Message.Contains("error NU1101:")), "Expect to error containing 'error NU1101:'")
317317
Assert.True( errors |> Seq.exists (fun error -> error.Message.Contains("FSharp.Really.Not.A.Package")), "Expect to error containing 'FSharp.Really.Not.A.Package'")
318318

319-
[<Fact>]
319+
[<FSharp.Test.FactSkipOnSignedBuild>]
320320
member _.``Eval script with invalid PackageName should fail immediately and resolve one time only``() =
321321
use capture = new TestConsole.ExecutionCapture()
322322
use script = new FSharpScript(additionalArgs=[| |])
@@ -330,7 +330,7 @@ printfn "{@"%A"}" result
330330
Assert.Equal(1, (errors |> Seq.filter (fun error -> error.Message.Contains("FSharp.Really.Not.A.Package")) |> Seq.length))
331331
Assert.Equal(1, (errors |> Seq.filter (fun error -> error.Message.Contains("FSharp.Really.Not.Another.Package")) |> Seq.length))
332332

333-
[<Fact>]
333+
[<FSharp.Test.FactSkipOnSignedBuild>]
334334
member _.``FsharpPlus - report errors``() =
335335
let code = """
336336
#i "nuget:https://api.nuget.org/v3/index.json"
@@ -366,7 +366,7 @@ printTable [{|Age = 15; Weight = 88; Name = "Blahboolahboogaloo"|}]
366366
let value = opt.Value
367367
Assert.Equal(1, downcast value.ReflectionValue)
368368

369-
[<Fact>]
369+
[<FSharp.Test.FactSkipOnSignedBuild>]
370370
member _.``ML - use assembly with ref dependencies``() =
371371
let code = """
372372
#r "nuget:Microsoft.ML.OnnxTransformer,1.4.0"
@@ -383,7 +383,7 @@ tInput.Length
383383
let value = opt.Value
384384
Assert.Equal(4L, downcast value.ReflectionValue)
385385

386-
[<FSharp.Test.FactForNETCOREAPP>] // usessdkrefs is not a valid option for desktop compiler
386+
[<FSharp.Test.FactForNETCOREAPPSkipOnSignedBuild>] // usessdkrefs is not a valid option for desktop compiler
387387
member _.``ML - use assembly with ref dependencies and without refing SMemory``() =
388388
let code = """
389389
#r "nuget:Microsoft.ML.OnnxTransformer,1.4.0"
@@ -399,7 +399,7 @@ tInput.Length
399399
let value = opt.Value
400400
Assert.Equal(4L, downcast value.ReflectionValue)
401401

402-
[<Fact>]
402+
[<FSharp.Test.FactSkipOnSignedBuild>]
403403
member _.``System.Device.Gpio - Ensure we reference the runtime version of the assembly``() =
404404
let code = """
405405
#r "nuget:System.Device.Gpio, 1.0.0"
@@ -512,7 +512,7 @@ let x =
512512
Assert.False(foundInner)
513513

514514

515-
[<Fact>]
515+
[<FSharp.Test.FactSkipOnSignedBuild>]
516516
member _.``Script with nuget package that yields out of order dependencies works correctly``() =
517517
// regression test for: https://github.com/dotnet/fsharp/issues/9217
518518
let code = """
@@ -535,7 +535,7 @@ test pfloat "1.234"
535535
let value = opt.Value
536536
Assert.True(true = downcast value.ReflectionValue)
537537

538-
[<Fact>]
538+
[<FSharp.Test.FactSkipOnSignedBuild>]
539539
member _.``Nuget package with method duplicates differing only in generic arity``() =
540540
// regression test for: https://github.com/dotnet/fsharp/issues/17796
541541
// Was an internal error
@@ -549,7 +549,7 @@ let add (col:IServiceCollection) =
549549
let _value,diag = script.Eval(code)
550550
Assert.Empty(diag)
551551

552-
[<Theory>]
552+
[<FSharp.Test.TheorySkipOnSignedBuild>]
553553
[<InlineData("""#r "nuget:envdte,usepackagetargets=true" """, true, "")>]
554554
[<InlineData("""#r "nuget:envdte,usepackagetargets=false" """, true, "")>]
555555
[<InlineData("""#r "nuget:envdte,usepackagetargets=invalidvalue" """, false, "input.fsx (1,1)-(1,49) interactive error Invalid value for boolean 'usepackagetargets', valid values: true or false")>]

tests/FSharp.Compiler.Service.Tests/ProjectAnalysisTests.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5807,7 +5807,7 @@ let checkContentAsScript content =
58075807
[<Collection(nameof NotThreadSafeResourceCollection)>]
58085808
module ScriptClosureCacheUse =
58095809

5810-
[<Fact>]
5810+
[<FSharp.Test.FactSkipOnSignedBuild>]
58115811
let ``References from #r nuget are included in script project options`` () =
58125812
let checkResults = checkContentAsScript """
58135813
#i "nuget:https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json"

tests/FSharp.Test.Utilities/Utilities.fs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,29 @@ type FactForDESKTOPAttribute() =
3939
do base.Skip <- "NETCOREAPP is not supported runtime for this kind of test, it is intended for DESKTOP only"
4040
#endif
4141

42+
module SignedBuildSkip =
43+
let isSignedBuild = System.Environment.GetEnvironmentVariable("SIGNTYPE") = "Real"
44+
let skipMessage = "Test skipped on signed builds due to NuGet package restore restrictions"
45+
46+
let skipIfSigned (attr: #FactAttribute) =
47+
if isSignedBuild then
48+
attr.Skip <- skipMessage
49+
50+
type FactSkipOnSignedBuildAttribute() as this =
51+
inherit FactAttribute()
52+
do SignedBuildSkip.skipIfSigned this
53+
54+
type TheorySkipOnSignedBuildAttribute() as this =
55+
inherit TheoryAttribute()
56+
do SignedBuildSkip.skipIfSigned this
57+
58+
type FactForNETCOREAPPSkipOnSignedBuildAttribute() as this =
59+
inherit FactAttribute()
60+
do SignedBuildSkip.skipIfSigned this
61+
#if !NETCOREAPP
62+
do base.Skip <- "Only NETCOREAPP is supported runtime for this kind of test."
63+
#endif
64+
4265
// This file mimics how Roslyn handles their compilation references for compilation testing
4366
module Utilities =
4467

tests/fsharp/tests.fs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -627,46 +627,46 @@ module CoreTests =
627627
| "" -> ()
628628
| diffs -> failwithf "'%s' and '%s' differ; %A" diffFileErr expectedFileErr diffs
629629

630-
[<Fact>]
630+
[<FSharp.Test.FactSkipOnSignedBuild>]
631631
let ``printing`` () =
632632
runPrintingTest "--multiemit- --debug+" "output"
633633

634634
// F# 5.0 changed some things printing output
635-
[<Fact>]
635+
[<FSharp.Test.FactSkipOnSignedBuild>]
636636
let ``printing-langversion47`` () =
637637
runPrintingTest "--langversion:4.7" "output.47"
638638

639639
// Output should not change with optimization off
640-
[<Fact>]
640+
[<FSharp.Test.FactSkipOnSignedBuild>]
641641
let ``printing-optimizeoff`` () =
642642
runPrintingTest "--multiemit- --debug+ --optimize-" "output"
643643

644644
// Legacy one-dynamic-assembly emit is the default for .NET Framework, which these tests are using
645645
// Turning that off enables multi-assembly-emit. The printing test is useful for testing multi-assembly-emit
646646
// as it feeds in many incremental fragments into stdin of the FSI process.
647-
[<Fact>]
647+
[<FSharp.Test.FactSkipOnSignedBuild>]
648648
let ``printing-multiemit`` () =
649649
runPrintingTest "--multiemit+ --debug+" "output.multiemit"
650650

651651
// Multi-assembly-emit establishes some slightly different rules regarding internals, and this
652652
// needs to be tested with optimizations off. The output should not change.
653-
[<Fact>]
653+
[<FSharp.Test.FactSkipOnSignedBuild>]
654654
let ``printing-multiemit-optimizeoff`` () =
655655
runPrintingTest "--multiemit+ --debug+ --optimize-" "output.multiemit"
656656

657-
[<Fact>]
657+
[<FSharp.Test.FactSkipOnSignedBuild>]
658658
let ``printing-width-1000`` () =
659659
runPrintingTest "--use:preludePrintSize1000.fsx" "output.1000"
660660

661-
[<Fact>]
661+
[<FSharp.Test.FactSkipOnSignedBuild>]
662662
let ``printing-width-200`` () =
663663
runPrintingTest "--use:preludePrintSize200.fsx" "output.200"
664664

665-
[<Fact>]
665+
[<FSharp.Test.FactSkipOnSignedBuild>]
666666
let ``printing-off`` () =
667667
runPrintingTest "--use:preludeShowDeclarationValuesFalse.fsx" "output.off"
668668

669-
[<Fact>]
669+
[<FSharp.Test.FactSkipOnSignedBuild>]
670670
let ``printing-quiet`` () =
671671
runPrintingTest "--quiet" "output.quiet"
672672

@@ -1645,77 +1645,77 @@ module RegressionTests =
16451645
[<Fact>]
16461646
let ``12383-FSC_OPTIMIZED`` () = singleTestBuildAndRun "regression/12383" FSC_OPTIMIZED
16471647

1648-
[<Fact>]
1648+
[<FSharp.Test.FactSkipOnSignedBuild>]
16491649
let ``13219-bug-FSI`` () = singleTestBuildAndRun "regression/13219" FSI
16501650

16511651
[<Fact>]
16521652
let ``4715-optimized`` () =
16531653
let cfg = testConfig "regression/4715"
16541654
fsc cfg "%s -o:test.exe --optimize+" cfg.fsc_flags ["date.fs"; "env.fs"; "main.fs"]
16551655

1656-
[<Fact>]
1656+
[<FSharp.Test.FactSkipOnSignedBuild>]
16571657
let ``multi-package-type-provider-test-FSI`` () = singleTestBuildAndRun "regression/13710" FSI
16581658

16591659
#if NETCOREAPP
1660-
[<Fact>]
1660+
[<FSharp.Test.FactSkipOnSignedBuild>]
16611661
let ``Large inputs 12322 fsc.dll 64-bit fsc.dll .NET SDK generating optimized code`` () =
16621662
let cfg = testConfig "regression/12322"
16631663
let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:portable --define:PORTABLE_PDB" }
16641664
singleTestBuildAndRunAux cfg (FSC_BUILDONLY true)
16651665

1666-
[<Fact>]
1666+
[<FSharp.Test.FactSkipOnSignedBuild>]
16671667
let ``Large inputs 12322 fsc.dll 64-bit .NET SDK generating debug code`` () =
16681668
let cfg = testConfig "regression/12322"
16691669
let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:portable --define:PORTABLE_PDB" }
16701670
singleTestBuildAndRunAux cfg (FSC_BUILDONLY false)
16711671

16721672
#else
1673-
[<Fact>]
1673+
[<FSharp.Test.FactSkipOnSignedBuild>]
16741674
let ``Large inputs 12322 fsc.exe 32-bit .NET Framework generating optimized code, portable PDB`` () =
16751675
let cfg = testConfig "regression/12322"
16761676
let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:portable --define:PORTABLE_PDB" }
16771677
singleTestBuildAndRunAux cfg (FSC_BUILDONLY true)
16781678

1679-
[<Fact>]
1679+
[<FSharp.Test.FactSkipOnSignedBuild>]
16801680
let ``Large inputs 12322 fsc.exe 32-bit .NET Framework generating optimized code, full PDB`` () =
16811681
let cfg = testConfig "regression/12322"
16821682
let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:full" }
16831683
singleTestBuildAndRunAux cfg (FSC_BUILDONLY true)
16841684

1685-
[<Fact>]
1685+
[<FSharp.Test.FactSkipOnSignedBuild>]
16861686
let ``Large inputs 12322 fsc.exe 32-bit .NET Framework generating debug code portable PDB`` () =
16871687
let cfg = testConfig "regression/12322"
16881688
let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:portable --define:PORTABLE_PDB" }
16891689
singleTestBuildAndRunAux cfg (FSC_BUILDONLY false)
16901690

1691-
[<Fact>]
1691+
[<FSharp.Test.FactSkipOnSignedBuild>]
16921692
let ``Large inputs 12322 fsc.exe 32-bit .NET Framework generating debug code, full PDB`` () =
16931693
let cfg = testConfig "regression/12322"
16941694
let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:full" }
16951695
singleTestBuildAndRunAux cfg (FSC_BUILDONLY false)
16961696

1697-
[<Fact>]
1697+
[<FSharp.Test.FactSkipOnSignedBuild>]
16981698
let ``Large inputs 12322 fscAnyCpu.exe 64-bit .NET Framework generating optimized code, portable PDB`` () =
16991699
let cfg = testConfig "regression/12322"
17001700
let cfg = { cfg with FSC = cfg.FSCANYCPU }
17011701
let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:portable --define:PORTABLE_PDB" }
17021702
singleTestBuildAndRunAux cfg (FSC_BUILDONLY true)
17031703

1704-
[<Fact>]
1704+
[<FSharp.Test.FactSkipOnSignedBuild>]
17051705
let ``Large inputs 12322 fscAnyCpu.exe 64-bit .NET Framework generating optimized code, full PDB`` () =
17061706
let cfg = testConfig "regression/12322"
17071707
let cfg = { cfg with FSC = cfg.FSCANYCPU }
17081708
let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:full " }
17091709
singleTestBuildAndRunAux cfg (FSC_BUILDONLY true)
17101710

1711-
[<Fact>]
1711+
[<FSharp.Test.FactSkipOnSignedBuild>]
17121712
let ``12322 fscAnyCpu.exe 64-bit .NET Framework generating debug code, portable PDB`` () =
17131713
let cfg = testConfig "regression/12322"
17141714
let cfg = { cfg with FSC = cfg.FSCANYCPU }
17151715
let cfg = { cfg with fsc_flags = cfg.fsc_flags + " --debug:portable --define:PORTABLE_PDB" }
17161716
singleTestBuildAndRunAux cfg (FSC_BUILDONLY false)
17171717

1718-
[<Fact>]
1718+
[<FSharp.Test.FactSkipOnSignedBuild>]
17191719
let ``12322 fscAnyCpu.exe 64-bit .NET Framework generating debug code, full PDB`` () =
17201720
let cfg = testConfig "regression/12322"
17211721
let cfg = { cfg with FSC = cfg.FSCANYCPU }

0 commit comments

Comments
 (0)