Enable CBOR property tests in CI runs (#40135)
authorEirik Tsarpalis <eirik.tsarpalis@gmail.com>
Fri, 7 Aug 2020 10:52:56 +0000 (11:52 +0100)
committerGitHub <noreply@github.com>
Fri, 7 Aug 2020 10:52:56 +0000 (11:52 +0100)
* enable cbor property tests in CI runs

* address feedback

src/libraries/System.Formats.Cbor/tests/PropertyTests/CborPropertyTests.cs
src/libraries/System.Formats.Cbor/tests/System.Formats.Cbor.Tests.csproj

index 6aca08f..d265bae 100644 (file)
@@ -12,7 +12,7 @@ namespace System.Formats.Cbor.Tests
     public static class CborPropertyTests
     {
         private const string? ReplaySeed = "(42,42)"; // set a seed for deterministic runs, null for randomized runs
-        private const int MaxTests = 10_000;
+        private const int MaxTests = 100; // FsCheck default is 100
 
         [Property(Replay = ReplaySeed, MaxTest = MaxTests, Arbitrary = new[] { typeof(CborRandomGenerators) })]
         public static void Roundtrip_Int64(CborConformanceMode mode, long input)
@@ -178,7 +178,7 @@ namespace System.Formats.Cbor.Tests
         }
 
         [Property(Replay = ReplaySeed, MaxTest = MaxTests, Arbitrary = new[] { typeof(CborRandomGenerators) })]
-        public static void PropertyTest_Roundtrip(CborPropertyTestContext input)
+        public static void CborDocument_Roundtrip(CborPropertyTestContext input)
         {
             byte[] encoding = CborDocumentSerializer.encode(input);
 
@@ -188,7 +188,7 @@ namespace System.Formats.Cbor.Tests
         }
 
         [Property(Replay = ReplaySeed, MaxTest = MaxTests, Arbitrary = new[] { typeof(CborRandomGenerators) })]
-        public static void PropertyTest_SkipValue(CborPropertyTestContext input)
+        public static void CborDocument_SkipValue(CborPropertyTestContext input)
         {
             int length = input.RootDocuments.Length;
             input.RootDocuments = new[] { CborDocument.NewArray(_isDefiniteLength: true, input.RootDocuments) };
@@ -205,7 +205,7 @@ namespace System.Formats.Cbor.Tests
         }
 
         [Property(Replay = ReplaySeed, MaxTest = MaxTests, Arbitrary = new[] { typeof(CborRandomGenerators) })]
-        public static void PropertyTest_SkipToParent(CborPropertyTestContext input)
+        public static void CborDocument_SkipToParent(CborPropertyTestContext input)
         {
             input.RootDocuments = new[] { CborDocument.NewArray(_isDefiniteLength: true, input.RootDocuments) };
             byte[] encoding = CborDocumentSerializer.encode(input);
index 71735ea..c2211d7 100644 (file)
@@ -1,20 +1,16 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
     <TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
     <nullable>enable</nullable>
-    <CborPropertyTests>false</CborPropertyTests>
-  </PropertyGroup>
-  
-  <PropertyGroup Condition="'$(CborPropertyTests)' == 'True'">
-    <DefineConstants>$(DefineConstants),CBOR_PROPERTY_TESTS</DefineConstants>
     <!-- Referenced assembly 'FsCheck' does not have a strong name.-->
     <NoWarn>CS8002</NoWarn>
   </PropertyGroup>
-
   <ItemGroup>
     <Compile Include="$(CommonTestPath)System\Security\Cryptography\ByteUtils.cs">
       <Link>CommonTest\System\Security\Cryptography\ByteUtils.cs</Link>
     </Compile>
+    <Compile Include="PropertyTests\CborPropertyTests.cs" />
+    <Compile Include="PropertyTests\CborRandomGenerators.cs" />
     <Compile Include="Reader\CborReaderTests.cs" />
     <Compile Include="Reader\CborReaderTests.ByteString.cs" />
     <Compile Include="Reader\CborReaderTests.TextString.cs" />
     <Compile Include="Writer\CborWriterTests.TextString.cs" />
     <Compile Include="CoseKeyHelpers.cs" />
   </ItemGroup>
-
-  <ItemGroup Condition="'$(CborPropertyTests)' == 'True'">
-    <Compile Include="PropertyTests\CborPropertyTests.cs" />
-    <Compile Include="PropertyTests\CborRandomGenerators.cs" />
-  </ItemGroup>
-
+  
   <ItemGroup>
     <ProjectReference Include="..\src\System.Formats.Cbor.csproj" />
-  </ItemGroup>
-
-  <ItemGroup Condition="'$(CborPropertyTests)' == 'True'">
     <ProjectReference Include="CborDocument\System.Formats.Cbor.Tests.DataModel.fsproj" />
+    <PackageReference Include="FsCheck" Version="$(FsCheckVersion)" />
     <PackageReference Include="FsCheck.Xunit" Version="$(FsCheckVersion)" />
   </ItemGroup>
 </Project>