Skip to content

Commit

Permalink
Changes in build and tests to improve non-Windows builds (#411)
Browse files Browse the repository at this point in the history
* Changes in build and tests to improve non-Windows builds

 * Added _WINDOWS ifdef variable
 * Run tests for both net461 and netcore2.1
 * Added PackageReference to Microsoft.NETFramework.ReferenceAssemblies
   to be able to build on non-Windows platforms
 * A bit more of #ifdefs on NET461 and _WINDOWS to avoid failing tests on non-Windows
 * Some small adjustments to build.ps1

* Fixed Code Quality issues

* More code quality issues
  • Loading branch information
erikbra authored Jul 3, 2020
1 parent 0073401 commit 4937a25
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 25 deletions.
13 changes: 5 additions & 8 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
#!/usr/bin/env pwsh

$MSBUILD=msbuild

$root = $PSScriptRoot;

$CODEDROP="$($root)/code_drop";
$PACKAGEDIR="$($CODEDROP)/packages";
$LOGDIR="$($CODEDROP)/log";

$TESTOUTDIR="$($root)/product/roundhouse.tests/bin"

$onAppVeyor = $("$($env:APPVEYOR)" -eq "True");

Push-Location $root
Expand All @@ -26,13 +22,13 @@ If ($onAppVeyor) {
appveyor UpdateBuild -Version "$newVersion"
}

" * Updating NuGet to handle newer license metadata"
nuget update -self -Verbosity quiet

" * Restoring nuget packages"
nuget restore -NonInteractive -Verbosity quiet

# Create output and log dirs if they don't exist (don't know why this is necessary - works on my box...)
If (!(Test-Path $CODEDROP)) {
$null = mkdir $CODEDROP;
}
If (!(Test-Path $PACKAGEDIR)) {
$null = mkdir $PACKAGEDIR;
}
Expand Down Expand Up @@ -77,7 +73,8 @@ If (! $onAppVeyor) {
# Find test projects
$testAssemblies = $(dir -r -i *.tests.dll)

$testAssemblies | ? { $_.FullName -NotLike "*obj*" } | % {
$testAssemblies | ? { $_.FullName -NotLike "*obj*" -and $_.FullName -NotLike "*Debug*" } | % {
$_.FullName
dotnet vstest $_
}
}
Expand Down
4 changes: 4 additions & 0 deletions product/roundhouse.console/roundhouse.console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>


Expand Down
5 changes: 1 addition & 4 deletions product/roundhouse.core/databases/DefaultDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ public abstract class DefaultDatabase<DBCONNECTION> : Database
public string master_database_name { get; set; }
public IRepository repository { get; set; }

public virtual string sql_statement_separator_regex_pattern
{
get { return @"(?<KEEP1>^(?:[\s\t])*(?:-{2}).*$)|(?<KEEP1>/{1}\*{1}[\S\s]*?\*{1}/{1})|(?<KEEP1>'{1}(?:[^']|\n[^'])*?'{1})|(?<KEEP1>^|\s)(?<BATCHSPLITTER>\;)(?<KEEP2>\s|$)"; }
}
public virtual string sql_statement_separator_regex_pattern => DefaultDatabase.default_sql_statement_separator_regex_pattern;

public int command_timeout { get; set; }
public int admin_command_timeout { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace roundhouse.infrastructure.extensions

public static class TypeExtensions
{
public const string exception_message_typed_format = "<{0}>";
public static readonly string exception_message_typed_format = "<{0}>";

public static ConstructorInfo greediest_constructor(this Type type)
{
Expand Down
7 changes: 7 additions & 0 deletions product/roundhouse.core/sqlsplitters/DefaultDatabase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace roundhouse.sqlsplitters
{
public static class DefaultDatabase
{
public static readonly string default_sql_statement_separator_regex_pattern = @"(?<KEEP1>^(?:[\s\t])*(?:-{2}).*$)|(?<KEEP1>/{1}\*{1}[\S\s]*?\*{1}/{1})|(?<KEEP1>'{1}(?:[^']|\n[^'])*?'{1})|(?<KEEP1>^|\s)(?<BATCHSPLITTER>\;)(?<KEEP2>\s|$)";
}
}
3 changes: 3 additions & 0 deletions product/roundhouse.databases.access/AccessDatabase.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Data.Common;
using roundhouse.infrastructure.logging;
using roundhouse.sqlsplitters;

namespace roundhouse.databases.access
{
Expand All @@ -11,6 +12,8 @@ namespace roundhouse.databases.access

public class AccessDatabase : AdoNetDatabase
{
public static readonly string default_sql_statement_separator_regex_pattern =
DefaultDatabase.default_sql_statement_separator_regex_pattern;
private string connect_options = "Trusted_Connection";

public AccessDatabase()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,11 @@ This is the MS Access database package.
<ItemGroup>
<ProjectReference Include="..\roundhouse.core\roundhouse.core.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
6 changes: 2 additions & 4 deletions product/roundhouse.databases.oracle/OracleDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ namespace roundhouse.databases.oracle

public class OracleDatabase : AdoNetDatabase
{
public static readonly string default_sql_statement_separator_regex_pattern = @"(?<KEEP1>^(?:.)*(?:-{2}).*$)|(?<KEEP1>/{1}\*{1}[\S\s]*?\*{1}/{1})|(?<KEEP1>^|\s)(?<BATCHSPLITTER>;)(?<KEEP2>\s|$)";
private string connect_options = "Integrated Security";

public override string sql_statement_separator_regex_pattern
{
get { return @"(?<KEEP1>^(?:.)*(?:-{2}).*$)|(?<KEEP1>/{1}\*{1}[\S\s]*?\*{1}/{1})|(?<KEEP1>^|\s)(?<BATCHSPLITTER>;)(?<KEEP2>\s|$)"; }
}
public override string sql_statement_separator_regex_pattern => default_sql_statement_separator_regex_pattern;

public override bool supports_ddl_transactions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,11 @@ This is the Oracle database package.
<ItemGroup>
<ProjectReference Include="..\roundhouse.core\roundhouse.core.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
7 changes: 7 additions & 0 deletions product/roundhouse.lib/roundhouse.lib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ This is an "include all" package that gives you all the databases. If you want o
<ProjectReference Include="..\roundhouse.databases.sqlserver\roundhouse.databases.sqlserver.csproj" />
<ProjectReference Include="..\roundhouse.core\roundhouse.core.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<None Include="..\..\docs\logo\roundhouse.ico">
Expand Down
4 changes: 4 additions & 0 deletions product/roundhouse.tasks/roundhouse.tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
<PackageReference Include="NHibernate" Version="5.2.5" />
<PackageReference Include="log4net" Version="2.0.8.0" />
<PackageReference Include="NHibernate.JetDriver" Version="2.0.0.1002" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Content Include="samples.xml">
Expand Down
8 changes: 6 additions & 2 deletions product/roundhouse.tests/databases/DbProviderFactories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ public void has_mysql_provider_factory()
}

#if NET461

[Concern(typeof(TestableOracleDatabase))]
public class concern_for_OracleDatabase : concern_for_Database<TestableOracleDatabase>
{
Expand All @@ -143,7 +142,9 @@ public void has_oracle_provider_factory()
fac.ShouldBeType<System.Data.OracleClient.OracleClientFactory>();
}
}
#endif

#if (NET461 && _WINDOWS)
[Concern(typeof(TestableAccessDatabase))]
public class concern_for_AccessDatabase : concern_for_Database<TestableAccessDatabase>
{
Expand Down Expand Up @@ -173,6 +174,7 @@ public void has_npgsql_provider_factory()
}
}

#if _WINDOWS
[Concern(typeof(TestableSqliteDatabase))]
public class concern_for_SqliteDatabase : concern_for_Database<TestableSqliteDatabase>
{
Expand All @@ -183,6 +185,7 @@ public void has_sqlite_provider_factory()
fac.ShouldBeType<System.Data.SQLite.SQLiteFactory>();
}
}
#endif

[Concern(typeof(TestableSqlServer2000Database))]
public class concern_for_SqlServer2000Database : concern_for_Database<TestableSqlServer2000Database>
Expand All @@ -195,6 +198,7 @@ public void has_sqlite_provider_factory()
}
}

#if NET461
[Concern(typeof(TestableSqlServerCEDatabase))]
public class concern_for_SqlServerCEDatabase : concern_for_Database<TestableSqlServerCEDatabase>
{
Expand All @@ -205,7 +209,7 @@ public void has_sqlite_provider_factory()
fac.ShouldBeType<System.Data.SqlServerCe.SqlCeProviderFactory>();
}
}

#endif

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public void utf8_encoded_file_without_bom_should_read_correctly()
}
}

#if NET461
[Concern(typeof(DotNetFileSystemAccess))]
public class when_reading_files_with_different_formats_with_ansi_encoding_configuration : concern_for_file_system
{
Expand All @@ -133,5 +134,8 @@ public void ansi_encoded_file_shoul_read_correctly()
ansi_file.should_be_equal_to(string.Format("INSERT INTO [dbo].[timmy]([value]) VALUES('G{0}')", extended_ascii_character));
}
}

#endif

}
}
7 changes: 5 additions & 2 deletions product/roundhouse.tests/roundhouse.tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!--<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>-->
<TargetFramework>net461</TargetFramework>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<CLSCompliant>true</CLSCompliant>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<OutputType>Library</OutputType>
Expand All @@ -14,6 +13,10 @@
<OutputPath>bin\$(Configuration)\</OutputPath>
</PropertyGroup>

<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
<DefineConstants>_WINDOWS</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="log4net" Version="2.0.8" />
<PackageReference Include="Castle.Core" Version="4.4.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ public override void Context()
tsql_separator_regex_string = database.sql_statement_separator_regex_pattern;

#if NET461
database = new AccessDatabase();
access_sql_separator_regex_string = database.sql_statement_separator_regex_pattern;
database = new OracleDatabase();
plsql_separator_regex_string = database.sql_statement_separator_regex_pattern;
access_sql_separator_regex_string = AccessDatabase.default_sql_statement_separator_regex_pattern;
plsql_separator_regex_string = OracleDatabase.default_sql_statement_separator_regex_pattern;
#endif
}
}
Expand Down Expand Up @@ -588,6 +586,7 @@ public void should_not_replace_on_go_inside_of_comments_with_symbols_after_on_di

}

#if NET461
[Concern(typeof(StatementSplitter))]
public class when_replacing_plsql_statements_with_the_statement_splitters_match_evaluator : concern_for_StatementSplitter
{
Expand Down Expand Up @@ -655,6 +654,7 @@ public void should_not_replace_on_assigning_values_to_variables()
Assert.AreEqual(expected_scrubbed, sql_statement_scrubbed);
}
}
#endif
}
}

0 comments on commit 4937a25

Please sign in to comment.