From 522d150e25639453496043df71f2ee42512604cc Mon Sep 17 00:00:00 2001 From: Nick Craver Date: Mon, 3 Sep 2018 21:38:27 -0400 Subject: [PATCH] Faster builds + use MySqlConnector MySql.Data is a travesty at this point - moving to something more stable. Really we weren't testing Dapper with previous test failures, we were testing what mood MySql.Data and NuGet extraction are in and which phase of the moon is about. Also speeds up the builds with 1 restore and 1 build. We can simplify here because everything is relevant (no wasted builds). --- Dapper.Tests.Contrib/Dapper.Tests.Contrib.csproj | 2 +- Dapper.Tests.Contrib/TestSuites.cs | 11 ++++------- .../Dapper.Tests.Performance.csproj | 5 ++--- Dapper.Tests/Dapper.Tests.csproj | 2 +- build.ps1 | 14 ++++++-------- 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/Dapper.Tests.Contrib/Dapper.Tests.Contrib.csproj b/Dapper.Tests.Contrib/Dapper.Tests.Contrib.csproj index dd9a7dd3..5c5d6ce6 100644 --- a/Dapper.Tests.Contrib/Dapper.Tests.Contrib.csproj +++ b/Dapper.Tests.Contrib/Dapper.Tests.Contrib.csproj @@ -18,7 +18,7 @@ - + diff --git a/Dapper.Tests.Contrib/TestSuites.cs b/Dapper.Tests.Contrib/TestSuites.cs index 88cafece..31ef7f37 100644 --- a/Dapper.Tests.Contrib/TestSuites.cs +++ b/Dapper.Tests.Contrib/TestSuites.cs @@ -37,7 +37,7 @@ namespace Dapper.Tests.Contrib using (var connection = new SqlConnection(ConnectionString)) { // ReSharper disable once AccessToDisposedClosure - Action dropTable = name => connection.Execute($"IF OBJECT_ID('{name}', 'U') IS NOT NULL DROP TABLE [{name}]; "); + void dropTable(string name) => connection.Execute($"IF OBJECT_ID('{name}', 'U') IS NOT NULL DROP TABLE [{name}]; "); connection.Open(); dropTable("Stuff"); connection.Execute("CREATE TABLE Stuff (TheId int IDENTITY(1,1) not null, Name nvarchar(100) not null, Created DateTime null);"); @@ -65,12 +65,10 @@ namespace Dapper.Tests.Contrib public class MySqlServerTestSuite : TestSuite { - private const string DbName = "DapperContribTests"; - public static string ConnectionString { get; } = IsAppVeyor - ? "Server=localhost;Uid=root;Pwd=Password12!;" - : "Server=localhost;Uid=test;Pwd=pass;"; + ? "Server=localhost;Database=test;Uid=root;Pwd=Password12!;UseAffectedRows=false;" + : "Server=localhost;Database=tests;Uid=test;Pwd=pass;UseAffectedRows=false;"; public override IDbConnection GetConnection() { @@ -87,9 +85,8 @@ namespace Dapper.Tests.Contrib using (var connection = new MySqlConnection(ConnectionString)) { // ReSharper disable once AccessToDisposedClosure - Action dropTable = name => connection.Execute($"DROP TABLE IF EXISTS `{name}`;"); + void dropTable(string name) => connection.Execute($"DROP TABLE IF EXISTS `{name}`;"); connection.Open(); - connection.Execute($"DROP DATABASE IF EXISTS {DbName}; CREATE DATABASE {DbName}; USE {DbName};"); dropTable("Stuff"); connection.Execute("CREATE TABLE Stuff (TheId int not null AUTO_INCREMENT PRIMARY KEY, Name nvarchar(100) not null, Created DateTime null);"); dropTable("People"); diff --git a/Dapper.Tests.Performance/Dapper.Tests.Performance.csproj b/Dapper.Tests.Performance/Dapper.Tests.Performance.csproj index dd4ec0bd..7299588b 100644 --- a/Dapper.Tests.Performance/Dapper.Tests.Performance.csproj +++ b/Dapper.Tests.Performance/Dapper.Tests.Performance.csproj @@ -19,9 +19,8 @@ - - + @@ -46,6 +45,6 @@ - + diff --git a/Dapper.Tests/Dapper.Tests.csproj b/Dapper.Tests/Dapper.Tests.csproj index 373fd7c9..13aea73f 100644 --- a/Dapper.Tests/Dapper.Tests.csproj +++ b/Dapper.Tests/Dapper.Tests.csproj @@ -21,7 +21,7 @@ - + diff --git a/build.ps1 b/build.ps1 index bdbf83f3..de16c65b 100644 --- a/build.ps1 +++ b/build.ps1 @@ -29,17 +29,15 @@ if ($PullRequestNumber) { $CreatePackages = $false } -Write-Host "Building projects..." -ForegroundColor "Magenta" -foreach ($project in $projectsToBuild + $testsToRun) { - Write-Host "Building $project (dotnet restore/build)..." -ForegroundColor "Magenta" - dotnet restore ".\$project\$project.csproj" /p:CI=true - dotnet build ".\$project\$project.csproj" -c Release /p:CI=true - Write-Host "" -} +Write-Host "Restoring all projects..." -ForegroundColor "Magenta" +dotnet restore +Write-Host "Done restoring." -ForegroundColor "Green" + +Write-Host "Building all projects..." -ForegroundColor "Magenta" +dotnet build -c Release --no-restore /p:CI=true Write-Host "Done building." -ForegroundColor "Green" if ($RunTests) { - dotnet restore /ConsoleLoggerParameters:Verbosity=Quiet foreach ($project in $testsToRun) { Write-Host "Running tests: $project (all frameworks)" -ForegroundColor "Magenta" Push-Location ".\$project"