Skip to content

Miscellaneous fixes #695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ShowBuildMenu.bat
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ echo ========================= NHIBERNATE BUILD MENU ==========================
echo --- TESTING ---
echo B. (Step 1) Set up a new test configuration for a particular database.
echo C. (Step 2) Activate a test configuration.
echo D. (Step 3) Run tests using active configuration.
echo D. (Step 3) Run tests using active configuration (Needs built in Visual Studio).
echo.
echo --- BUILD ---
echo E. Build NHibernate (Debug)
Expand Down Expand Up @@ -165,7 +165,9 @@ echo Configuration activated.
goto main-menu

:test-run
start "nunit3-console" cmd /K %NUNIT% --x86 --agents=1 --process=separate NHibernate.nunit
SET NUNITPLATFORM=
IF /I "%PLATFORM%" NEQ "x64" set NUNITPLATFORM=--x86
start "nunit3-console" cmd /K %NUNIT% %NUNITPLATFORM% --agents=1 --process=separate NHibernate.nunit
Copy link
Member

@fredericDelaporte fredericDelaporte Oct 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PLATFORM environment variable looks harmful, it causes build failures due to MsBuild using it if defined, as in here.

It seems anyway that its default is to be not defined, it is just unfortunately set by this ShowBuildMenu when setting up test configuration, causing then build failures (especially on async file generation).

So I wonder if this change works as expected. I think in most cases we are still running nunit as a 32 bits process, even on x64 boxes. Maybe should be changed to use a logic like here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NUnit does run in x64 with this change...

The PLATFORM environment variable may be interacting with the async generation elsewhere, but it's not 'harmful' on this line in the ShowBuildMenu.bat. This pull request didn't set the PLATFORM, just tested its value.

Copy link
Member

@fredericDelaporte fredericDelaporte Oct 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NUnit does run in x64 with this change...

Maybe on your machine, not on mine. This PLATFORM environment variable is not a standard thing. Most boxes do not have it. So your change may mostly works on your machine, not elsewhere. That is why I have linked an alternate way using environment variables documented for this usage. (No official doc, but at least many references, like here and other places.)

Copy link
Contributor Author

@ngbrown ngbrown Oct 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point of this wasn't for general use x64 unit testing, it was only for enabling the testing of the x64 configurations in the build menu (of which there are ones for Firebird, SQLite, and SQL Server Compact). I agree that even at this task it's imperfect as the configurations needs to be created and then the tests ran in the same session of ShowBuildMenu.bat.

It's not about my machine or your machine, as none of my machines ever have PLATFORM set at a machine or user profile level. It was intended to be entirely within the ShowBuildMenu.bat. PLATFORM has been set in the ShowBuildMenu.bat since 2011:

set PLATFORM=x64

Maybe a better solution would have two separate Run tests using active configuration one for each of x64 and x86.

An even better solution would use NuGet packages of the ADO.NET drivers where both sets of native binaries are included in the build process and don't have to be selected at the configuration level, but based on the word size of the currently running process.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it is worst than imperfect, since it is a "work only once" solution. Usually we do not re-create configurations for each test run, we just activate the one we want. And activation is not setting this variable.
By the way it cannot work when creating a SQL Server Compact test configuration either: this one put AnyCpu in this variable whatever its bitness.

So yes I agree that two options is the way to go. But that will require a letter shift, like moving B&C to A&B.

About NuGet, see #1401.

Firebird and SQLite data providers are CPU agnostic nowadays anyway. SQL Server CE is still an issue and this one will likely be solved only by dropping it. Oracle stays a special case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was reacting to the comment that this pull request was somehow 'harmful', not that it only barely helps/works.

I think that adding to your #1401 pull request separate menu options to run tests in both x86 and x64 is a good idea.

goto main-menu

rem :build-test
Expand Down
138 changes: 69 additions & 69 deletions default.build
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,19 @@
<!-- Tests -->
<copy file="${bin.dir}/TestEmbeddedConfig.cfg.xml" todir="${bin-pack.tests}"/>
<copy file="${bin.dir}/ABC.hbm.xml" todir="${bin-pack.tests}"/>
<copy todir="${bin-pack.tests}/DbScripts">
<fileset basedir="${root.dir}/src/NHibernate.Test/DbScripts">
<include name="*.sql" />
</fileset>
</copy>
<copy todir="${bin-pack.tests}">
<copy todir="${bin-pack.tests}/DbScripts">
<fileset basedir="${root.dir}/src/NHibernate.Test/DbScripts">
<include name="*.sql" />
</fileset>
</copy>
<copy todir="${bin-pack.tests}">
<fileset basedir="${bin.dir}">
<include name="nunit*" />
<include name="SharpTestsEx*" />
<include name="NHibernate.Domain*" />
<include name="SharpTestsEx*" />
<include name="NHibernate.Domain*" />
<include name="NHibernate.Test*" />
<include name="log4net*" />
</fileset>
<include name="log4net*" />
</fileset>
</copy>
</target>

Expand Down Expand Up @@ -241,65 +241,65 @@

</target>

<fileset id="nugetfiles.all" basedir="src">
<include name="NHibernate/NHibernate.build" />
</fileset>

<target name="nuspec" depends="init nuget.set-properties" description="Create nuspec files">
<nant target="nuspec">
<buildfiles refid="nugetfiles.all" />
</nant>
</target>
<target name="nuget" depends="init binaries nuget.set-properties nuspec"
description="Creates files for the release on nuget gallery.">
<fileset id="nugetfiles.all" basedir="src">
<include name="NHibernate/NHibernate.build" />
</fileset>

<target name="nuspec" depends="init nuget.set-properties" description="Create nuspec files">
<nant target="nuspec">
<buildfiles refid="nugetfiles.all" />
</nant>
</target>
<target name="nuget" depends="init binaries nuget.set-properties nuspec"
description="Creates files for the release on nuget gallery.">

<nant target="nuget">
<buildfiles refid="nugetfiles.all" />
</nant>

<mkdir dir="${nuget.nupackages.dir}" />
<move todir="${nuget.nupackages.dir}">
<fileset basedir="${nuget.workingdir}">
<include name="*.nupkg" />
</fileset>
</move>
</target>
<target name="nugetpushbat" depends="init binaries common.download-nuget nuget.set-properties nuspec nuget"
description="Creates files for the release on nuget gallery.">

<copy file="${tools.dir}/NuGet.exe" todir="${nuget.nupackages.dir}"/>

<echo message="rem In order to use this bat you have to be sure you have executed 'nuget SetApiKey' ${environment::newline()}" file="${nuget.nupackages.pushbatfile}" append="false"/>
<foreach item="File" property="filename">
<in>
<items>
<include name="${nuget.nupackages.dir}/*.nupkg"/>
</items>
</in>
<do>
<echo message="nuget push ${filename} ${environment::newline()}" file="${nuget.nupackages.pushbatfile}" append="true"/>
</do>
</foreach>
</target>
<target name="nugetpush" depends="init binaries common.download-nuget nuget.set-properties nuspec nuget"
description="Push packages on nuget gallery.">
<!-- In order to use this task you have to be sure you have executed 'nuget SetApiKey' -->
<foreach item="File" property="filename">
<in>
<items>
<include name="${nuget.nupackages.dir}/*.nupkg"/>
</items>
</in>
<do>
<exec basedir="${tools.dir}" workingdir="${nuget.nupackages.dir}" program="NuGet.exe">
<arg value="push" />
<arg value="${filename}" />
</exec>
</do>
</foreach>
</target>
<nant target="nuget">
<buildfiles refid="nugetfiles.all" />
</nant>

<mkdir dir="${nuget.nupackages.dir}" />
<move todir="${nuget.nupackages.dir}">
<fileset basedir="${nuget.workingdir}">
<include name="*.nupkg" />
</fileset>
</move>
</target>
<target name="nugetpushbat" depends="init binaries common.download-nuget nuget.set-properties nuspec nuget"
description="Creates files for the release on nuget gallery.">

<copy file="${tools.dir}/NuGet.exe" todir="${nuget.nupackages.dir}"/>

<echo message="rem In order to use this bat you have to be sure you have executed 'nuget SetApiKey' ${environment::newline()}" file="${nuget.nupackages.pushbatfile}" append="false"/>
<foreach item="File" property="filename">
<in>
<items>
<include name="${nuget.nupackages.dir}/*.nupkg"/>
</items>
</in>
<do>
<echo message="nuget push ${filename} ${environment::newline()}" file="${nuget.nupackages.pushbatfile}" append="true"/>
</do>
</foreach>
</target>
<target name="nugetpush" depends="init binaries common.download-nuget nuget.set-properties nuspec nuget"
description="Push packages on nuget gallery.">
<!-- In order to use this task you have to be sure you have executed 'nuget SetApiKey' -->
<foreach item="File" property="filename">
<in>
<items>
<include name="${nuget.nupackages.dir}/*.nupkg"/>
</items>
</in>
<do>
<exec basedir="${tools.dir}" workingdir="${nuget.nupackages.dir}" program="NuGet.exe">
<arg value="push" />
<arg value="${filename}" />
</exec>
</do>
</foreach>
</target>

</project>
17 changes: 16 additions & 1 deletion src/NHibernate.Everything.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.3
VisualStudioVersion = 15.0.26730.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Support", "Support", "{9BDB5C84-14EC-4384-B423-9E319675B3CA}"
ProjectSection(SolutionItems) = preProject
Expand Down Expand Up @@ -73,6 +73,8 @@ Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "NHibernate.Test.VisualBasic
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NHibernate.Example.Web", "NHibernate.Example.Web\NHibernate.Example.Web.csproj", "{B291C1C1-599B-418E-8591-8A8CF1CAA188}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NHibernate.TestDatabaseSetup", "NHibernate.TestDatabaseSetup\NHibernate.TestDatabaseSetup.csproj", "{783DB85E-2EED-4377-8EF4-8D6EFE042007}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|.NET = Debug|.NET
Expand Down Expand Up @@ -144,6 +146,18 @@ Global
{B291C1C1-599B-418E-8591-8A8CF1CAA188}.Release|Any CPU.Build.0 = Release|Any CPU
{B291C1C1-599B-418E-8591-8A8CF1CAA188}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{B291C1C1-599B-418E-8591-8A8CF1CAA188}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{783DB85E-2EED-4377-8EF4-8D6EFE042007}.Debug|.NET.ActiveCfg = Debug|Any CPU
{783DB85E-2EED-4377-8EF4-8D6EFE042007}.Debug|.NET.Build.0 = Debug|Any CPU
{783DB85E-2EED-4377-8EF4-8D6EFE042007}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{783DB85E-2EED-4377-8EF4-8D6EFE042007}.Debug|Any CPU.Build.0 = Debug|Any CPU
{783DB85E-2EED-4377-8EF4-8D6EFE042007}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{783DB85E-2EED-4377-8EF4-8D6EFE042007}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{783DB85E-2EED-4377-8EF4-8D6EFE042007}.Release|.NET.ActiveCfg = Release|Any CPU
{783DB85E-2EED-4377-8EF4-8D6EFE042007}.Release|.NET.Build.0 = Release|Any CPU
{783DB85E-2EED-4377-8EF4-8D6EFE042007}.Release|Any CPU.ActiveCfg = Release|Any CPU
{783DB85E-2EED-4377-8EF4-8D6EFE042007}.Release|Any CPU.Build.0 = Release|Any CPU
{783DB85E-2EED-4377-8EF4-8D6EFE042007}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{783DB85E-2EED-4377-8EF4-8D6EFE042007}.Release|Mixed Platforms.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -159,6 +173,7 @@ Global
{7AEE5B37-C552-4E59-9B6F-88755BCB5070} = {094F74CD-2DD7-496F-BC48-A6D357BF33FD}
{446E148D-A9D5-4D7D-A706-BEDD45B2BC7D} = {92509065-DAEA-4457-8300-C7B64CD0E9F4}
{7C2EF610-BCA0-4D1F-898A-DE9908E4970C} = {094F74CD-2DD7-496F-BC48-A6D357BF33FD}
{783DB85E-2EED-4377-8EF4-8D6EFE042007} = {094F74CD-2DD7-496F-BC48-A6D357BF33FD}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A41913C2-EDEB-440A-BBDE-0AEB56C1CBA6}
Expand Down
4 changes: 2 additions & 2 deletions src/NHibernate.Test/DynamicProxyTests/PeVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public PeVerifier(string assemblyFileName)

var dir = Path.GetDirectoryName(_assemlyLocation);

while (!Directory.Exists(Path.Combine(dir, "Tools/PEVerify")))
while (!Directory.Exists(Path.Combine(dir, "Tools", "PEVerify")))
{
if (Directory.GetParent(dir) == null)
throw new Exception(string.Format("Could not find Tools/PEVerify directory in ancestor of {0}", _assemlyLocation));
Expand All @@ -35,7 +35,7 @@ public PeVerifier(string assemblyFileName)
if (Environment.Version.Major == 2)
versionFolder = "3.5";

_peVerifyPath = Path.Combine(dir, "Tools/PEVerify/" + versionFolder + "/PEVerify.exe");
_peVerifyPath = Path.Combine(dir, "Tools", "PEVerify", versionFolder, "PEVerify.exe");

if (!File.Exists(_peVerifyPath))
throw new Exception(string.Format("Could not find PEVerify.exe at {0}", _peVerifyPath));
Expand Down
9 changes: 3 additions & 6 deletions src/NHibernate.Test/NHSpecificTest/Logs/LogsFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void WillGetSessionIdFromSessionLogs()

s.Get<Person>(1);//will execute some sql

var loggingEvent = spy.Events[0];
var loggingEvent = spy.GetWholeLog();
Assert.That(loggingEvent.Contains(sessionId.ToString()), Is.True);
}
}
Expand Down Expand Up @@ -78,12 +78,9 @@ public TextLogSpy(string loggerName, string pattern)
loggerImpl.Level = Level.All;
}

public string[] Events
public string GetWholeLog()
{
get
{
return stringBuilder.ToString().Split(new[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries);
}
return stringBuilder.ToString();
}

public void Dispose()
Expand Down
38 changes: 24 additions & 14 deletions src/NHibernate.Test/UtilityTest/WeakHashtableFixture.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.CompilerServices;

using NHibernate.Util;
using NUnit.Framework;
Expand All @@ -11,11 +10,30 @@ namespace NHibernate.Test.UtilityTest
[TestFixture]
public class WeakHashtableFixture
{
protected WeakHashtable Create()
private static WeakHashtable Create()
{
return new WeakHashtable();
}

// NoInlining to keep temporary variables' lifetime from being extended.
[MethodImpl(MethodImplOptions.NoInlining)]
private static WeakHashtable CreateWithTwoObjects()
{
var table = Create();

table[new object()] = new object();
table[new object()] = new object();

return table;
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static WeakRefWrapper CreateWeakRefWrapper()
{
object obj = new object();
return new WeakRefWrapper(obj);
}

[Test]
public void Basic()
{
Expand All @@ -33,10 +51,8 @@ public void Basic()
[Test]
public void WeakReferenceGetsFreedButHashCodeRemainsConstant()
{
object obj = new object();
WeakRefWrapper wr = new WeakRefWrapper(obj);
WeakRefWrapper wr = CreateWeakRefWrapper();
int hashCode = wr.GetHashCode();
obj = null;

GC.Collect();

Expand All @@ -48,10 +64,7 @@ public void WeakReferenceGetsFreedButHashCodeRemainsConstant()
[Test]
public void Scavenging()
{
WeakHashtable table = Create();

table[new object()] = new object();
table[new object()] = new object();
WeakHashtable table = CreateWithTwoObjects();

GC.Collect();
table.Scavenge();
Expand All @@ -62,10 +75,7 @@ public void Scavenging()
[Test]
public void IterationAfterGC()
{
WeakHashtable table = Create();

table[new object()] = new object();
table[new object()] = new object();
WeakHashtable table = CreateWithTwoObjects();

GC.Collect();

Expand Down
10 changes: 7 additions & 3 deletions src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,21 @@ private static void SetupFirebird(Cfg.Configuration cfg)

private static void SetupSqlServerCe(Cfg.Configuration cfg)
{
var connStr = cfg.Properties[Cfg.Environment.ConnectionString];

try
{
if (File.Exists("NHibernate.sdf"))
File.Delete("NHibernate.sdf");
var connStrBuilder = new SqlCeConnectionStringBuilder(connStr);
var dataSource = connStrBuilder.DataSource;
if (File.Exists(dataSource))
File.Delete(dataSource);
}
catch (Exception e)
{
Console.WriteLine(e);
}

using (var en = new SqlCeEngine("DataSource=\"NHibernate.sdf\""))
using (var en = new SqlCeEngine(connStr))
{
en.CreateDatabase();
}
Expand Down
Loading