From 79c32b17acecbd01968a081dda695fc25d8bc992 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 12 Mar 2019 04:05:37 -0400 Subject: [PATCH 1/6] add scripts for C# windows tests --- csharp/buildall.bat | 13 +++++++++++++ kokoro/windows/csharp/build.bat | 10 ++++++++++ kokoro/windows/csharp/continuous.cfg | 5 +++++ 3 files changed, 28 insertions(+) create mode 100644 csharp/buildall.bat create mode 100644 kokoro/windows/csharp/build.bat create mode 100644 kokoro/windows/csharp/continuous.cfg diff --git a/csharp/buildall.bat b/csharp/buildall.bat new file mode 100644 index 0000000000000..1ec4dd5309dad --- /dev/null +++ b/csharp/buildall.bat @@ -0,0 +1,13 @@ +@rem Builds Google.Protobuf and runs the tests + +dotnet build src/Google.Protobuf.sln || goto :error + +echo Running tests. + +dotnet test -f netcoreapp1.0 src/Google.Protobuf.Test/Google.Protobuf.Test.csproj || goto :error + +goto :EOF + +:error +echo Failed! +exit /b %errorlevel% diff --git a/kokoro/windows/csharp/build.bat b/kokoro/windows/csharp/build.bat new file mode 100644 index 0000000000000..94d0906cc6337 --- /dev/null +++ b/kokoro/windows/csharp/build.bat @@ -0,0 +1,10 @@ +@rem enter repo root +cd /d %~dp0\..\..\.. + +cd csharp + +@rem Install dotnet SDK +powershell -File install_dotnet_sdk.ps1 +set PATH=%LOCALAPPDATA%\Microsoft\dotnet;%PATH% + +call buildall.bat diff --git a/kokoro/windows/csharp/continuous.cfg b/kokoro/windows/csharp/continuous.cfg new file mode 100644 index 0000000000000..f586585176b10 --- /dev/null +++ b/kokoro/windows/csharp/continuous.cfg @@ -0,0 +1,5 @@ +# Config file for running tests in Kokoro + +# Location of the build script in repository +build_file: "protobuf/kokoro/windows/csharp/build.bat" +timeout_mins: 1440 From 753daae02725ec73615fb33003c79395f70aa7ff Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 12 Mar 2019 04:40:46 -0400 Subject: [PATCH 2/6] use netcoreapp2.1 for testing --- appveyor.bat | 2 +- csharp/buildall.bat | 2 +- csharp/buildall.sh | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/appveyor.bat b/appveyor.bat index 29ec4922ae9d5..7a35ceb4d678e 100644 --- a/appveyor.bat +++ b/appveyor.bat @@ -38,7 +38,7 @@ dotnet restore dotnet build -c %configuration% || goto error echo Testing C# -dotnet test -c %configuration% -f netcoreapp1.0 Google.Protobuf.Test\Google.Protobuf.Test.csproj || goto error +dotnet test -c %configuration% -f netcoreapp2.1 Google.Protobuf.Test\Google.Protobuf.Test.csproj || goto error dotnet test -c %configuration% -f net451 Google.Protobuf.Test\Google.Protobuf.Test.csproj || goto error goto :EOF diff --git a/csharp/buildall.bat b/csharp/buildall.bat index 1ec4dd5309dad..89cf8f0579b25 100644 --- a/csharp/buildall.bat +++ b/csharp/buildall.bat @@ -4,7 +4,7 @@ dotnet build src/Google.Protobuf.sln || goto :error echo Running tests. -dotnet test -f netcoreapp1.0 src/Google.Protobuf.Test/Google.Protobuf.Test.csproj || goto :error +dotnet test -f netcoreapp2.1 src/Google.Protobuf.Test/Google.Protobuf.Test.csproj || goto :error goto :EOF diff --git a/csharp/buildall.sh b/csharp/buildall.sh index 50d8906dceb44..43b5ac3ffb29a 100755 --- a/csharp/buildall.sh +++ b/csharp/buildall.sh @@ -10,8 +10,8 @@ dotnet restore $SRC/Google.Protobuf.sln dotnet build -c $CONFIG $SRC/Google.Protobuf.sln echo Running tests. -# Only test netcoreapp1.0, which uses the .NET Core runtime. +# Only test netcoreapp2.1, which uses the .NET Core runtime. # If we want to test the .NET 4.5 version separately, we could # run Mono explicitly. However, we don't have any differences between -# the .NET 4.5 and netstandard1.0 assemblies. -dotnet test -c $CONFIG -f netcoreapp1.0 $SRC/Google.Protobuf.Test/Google.Protobuf.Test.csproj +# the .NET 4.5 and netstandard2.1 assemblies. +dotnet test -c $CONFIG -f netcoreapp2.1 $SRC/Google.Protobuf.Test/Google.Protobuf.Test.csproj From 67fee07308283b89adbae5628c3f6391defbd8a2 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 12 Mar 2019 04:48:10 -0400 Subject: [PATCH 3/6] C#: set some dotnet options when testing --- kokoro/release/csharp/windows/build_nuget.bat | 4 ++++ kokoro/windows/csharp/build.bat | 4 ++++ tests.sh | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/kokoro/release/csharp/windows/build_nuget.bat b/kokoro/release/csharp/windows/build_nuget.bat index fdb02b06853cb..0ff8db04284ff 100644 --- a/kokoro/release/csharp/windows/build_nuget.bat +++ b/kokoro/release/csharp/windows/build_nuget.bat @@ -7,4 +7,8 @@ cd csharp powershell -File install_dotnet_sdk.ps1 set PATH=%LOCALAPPDATA%\Microsoft\dotnet;%PATH% +@rem Disable some unwanted dotnet options +set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true +set DOTNET_CLI_TELEMETRY_OPTOUT=true + call build_packages.bat diff --git a/kokoro/windows/csharp/build.bat b/kokoro/windows/csharp/build.bat index 94d0906cc6337..95224f2eb21d2 100644 --- a/kokoro/windows/csharp/build.bat +++ b/kokoro/windows/csharp/build.bat @@ -7,4 +7,8 @@ cd csharp powershell -File install_dotnet_sdk.ps1 set PATH=%LOCALAPPDATA%\Microsoft\dotnet;%PATH% +@rem Disable some unwanted dotnet options +set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true +set DOTNET_CLI_TELEMETRY_OPTOUT=true + call buildall.bat diff --git a/tests.sh b/tests.sh index 09edfbfb15a8a..6bfd1a848aa2c 100755 --- a/tests.sh +++ b/tests.sh @@ -117,6 +117,12 @@ build_csharp() { internal_build_cpp NUGET=/usr/local/bin/nuget.exe + # Disable some unwanted dotnet options + export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true + export DOTNET_CLI_TELEMETRY_OPTOUT=true + + # TODO(jtattermusch): is this still needed with "first time experience" + # disabled? # Perform "dotnet new" once to get the setup preprocessing out of the # way. That spews a lot of output (including backspaces) into logs # otherwise, and can cause problems. It doesn't matter if this step From e6a22c97770c4ca5394f5b242e83e8c5fc6176ea Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 12 Mar 2019 04:58:35 -0400 Subject: [PATCH 4/6] test all frameworks on windows --- csharp/buildall.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csharp/buildall.bat b/csharp/buildall.bat index 89cf8f0579b25..821ffb3102bec 100644 --- a/csharp/buildall.bat +++ b/csharp/buildall.bat @@ -4,7 +4,7 @@ dotnet build src/Google.Protobuf.sln || goto :error echo Running tests. -dotnet test -f netcoreapp2.1 src/Google.Protobuf.Test/Google.Protobuf.Test.csproj || goto :error +dotnet test src/Google.Protobuf.Test/Google.Protobuf.Test.csproj || goto :error goto :EOF From d305c2ac4b72c4ab3a5c477922b661db0431ed09 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 12 Mar 2019 05:47:53 -0400 Subject: [PATCH 5/6] update csharp_EXTRA_DIST --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index faf236d1413f3..d2587fe33715a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -57,6 +57,7 @@ csharp_EXTRA_DIST= \ csharp/README.md \ csharp/build_packages.bat \ csharp/build_tools.sh \ + csharp/buildall.bat \ csharp/buildall.sh \ csharp/generate_protos.sh \ csharp/install_dotnet_sdk.ps1 \ From 60a889e0484dbe55656df4f6a80ffa90cd3b8554 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 12 Mar 2019 08:51:41 -0400 Subject: [PATCH 6/6] make check for distinct hashcode optional --- .../Google.Protobuf.Test/Collections/RepeatedFieldTest.cs | 3 ++- csharp/src/Google.Protobuf.Test/EqualityTester.cs | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs b/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs index 129923b60942b..b3863a4965a10 100644 --- a/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs +++ b/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs @@ -750,7 +750,8 @@ public void NaNValuesComparedBitwise() var list2 = new RepeatedField { SampleNaNs.Regular, SampleNaNs.PayloadFlipped }; var list3 = new RepeatedField { SampleNaNs.Regular, SampleNaNs.SignallingFlipped }; - EqualityTester.AssertInequality(list1, list2); + // All SampleNaNs have the same hashcode under certain targets (e.g. netcoreapp2.1) + EqualityTester.AssertInequality(list1, list2, checkHashcode: false); EqualityTester.AssertEquality(list1, list3); Assert.True(list1.Contains(SampleNaNs.SignallingFlipped)); Assert.False(list2.Contains(SampleNaNs.SignallingFlipped)); diff --git a/csharp/src/Google.Protobuf.Test/EqualityTester.cs b/csharp/src/Google.Protobuf.Test/EqualityTester.cs index a669baba17bfd..d4b3c1341ac68 100644 --- a/csharp/src/Google.Protobuf.Test/EqualityTester.cs +++ b/csharp/src/Google.Protobuf.Test/EqualityTester.cs @@ -49,13 +49,14 @@ public static void AssertEquality(T first, T second) where T : IEquatable Assert.AreEqual(first.GetHashCode(), second.GetHashCode()); } - public static void AssertInequality(T first, T second) where T : IEquatable + public static void AssertInequality(T first, T second, bool checkHashcode = true) where T : IEquatable { Assert.IsFalse(first.Equals(second)); Assert.IsFalse(first.Equals((object) second)); // While this isn't a requirement, the chances of this test failing due to // coincidence rather than a bug are very small. - if (first != null && second != null) + // For such rare cases, an argument can be used to disable the check. + if (checkHashcode && first != null && second != null) { Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode()); }