Skip to content

Commit

Permalink
Updated build, test, and release scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jos Hickson committed Jan 23, 2018
1 parent ef8b56a commit 49066c6
Show file tree
Hide file tree
Showing 27 changed files with 101 additions and 9,909 deletions.
4 changes: 2 additions & 2 deletions AcceptanceTest/runat.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ if([string]::IsNullOrEmpty($tests)) {


if($release -eq "release") {
$dir = "bin\Release"
$dir = "bin\Release\net452"
}
elseif($release -eq "debug") {
$dir = "bin\Debug"
$dir = "bin\Debug\net452"
}
else { Usage }

Expand Down
2 changes: 1 addition & 1 deletion AcceptanceTest/setup.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
echo off
@echo off
set PORT=%1
echo [DEFAULT] > cfg\at.cfg
REM FIXME:
Expand Down
75 changes: 37 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,20 @@ System Setup
------------
This project requires the following:

**To build**
**To build and run tests**

* [Ruby (1.9.3 recommended)](http://rubyinstaller.org/) (used to generate message and field classes from the DataDictionary xml file)
* Visual Studio 2010 or higher

**To run tests**

* [NUnit](http://nunit.org)
* From the command-line: dotnet 2.0.0 or higher
* From Visual Studio: version 2017 or higher

Code Generation
---------------
To regenerate the message and field class source from the Data Dictionaries, you need Ruby and the Nokogiri gem:

```
gem install nokogiri -v 1.6.8.1
generate.bat
```

(Nokogiri versions 1.7+ require Ruby 2.0, so we must use this older version.)

Expand All @@ -34,67 +33,67 @@ Build
-----
To build the project, run:

build.bat

You can also override the default target, configuration, and .NET framework version by giving command line arguments:

build.bat Rebuild Release v3.5
```
build.bat
```

You can also override the default configuration (Release) by giving a command line argument:

The build.bat script expects MSBuild.exe to be on your PATH. If you run it
from a Visual Studio cmd shell, this should not be a problem. However, if you
run it from some other shell (e.g. cygwin), you may need to append something
like:
```
build.bat Debug
```

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319

to your PATH environment variable. (Note, this build tools dir does not mean that the project
will build for .NET 4.0; these are merely the build tools that come with VS 2010.)
The build.bat script expects dotnet to be on your PATH.

Alternatively, simply use the dotnet tools.

Unit Tests
----------
To run the NUnit tests, run:

unit_test.bat
```
unit_test.bat
```

(This script expects nunit-console.exe to be on your PATH. You may have to append
something like `C:\Program Files\NUnit 2.6.1\bin` to your PATH environment variable.)
(This script expects `dotnet` to be on your PATH.)

An HTML report of the test results will then be available here:
TRX reports of the test results (one each for NET Framework 4.5.2 and NET Standard 2.0) will then be available here:

```
UnitTests\TestResults
```

Alternatively, simply use `dotnet`:

UnitTests\bin\Release\UnitTests.html
```
dotnet test UnitTests
```

To run a Unit Test in the debugger (not sure if it works in VS Express):
To run a Unit Test in the debugger:

1. Right-click UnitTests project, click 'Properties'
2. Go to Debug tab
3. Change Start Action to 'Start external program: C:\Program Files\NUnit 2.6.1\bin\nunit.exe'
(change the path to what is appropriate for your system)
4. Set your 'Command line arguments' to 'C:\dev\quickfixn\UnitTests\bin\Debug\UnitTests.dll'
(change the path to what is appropriate for your system)
5. Set your 'Working directory' to 'C:\dev\quickfixn\UnitTests\bin\Debug\'
(change the path to what is appropriate for your system)
6. Open NUnit in debugger as follows:
Right-click UnitTests, choose Debug->Start New Instance
7. NUnit GUI will open and VS will be in debugger mode. You can choose and run tests.
If you recompile, you may need to close and relaunch NUnit.
1. Open the TestExplorer from Test -> Windows -> Test Explorer
2. Navigate to the test
3. Right-click and select "Debug Selected Tests"


Acceptance Tests
----------------
To run the full suite of acceptance tests:

acceptance_test.ps1
```
acceptance_test.ps1
```

An HTML report of the test results will then be available here:

AcceptanceTests\AcceptanceTests.html

To run one particular acceptance test, e.g. fix42\14e_IncorrectEnumValue.def:

```
cd AcceptanceTest
runat.ps1 release 5003 definitions\server\fix42\14e_IncorrectEnumValue.def cfg\at_42.cfg
```

(See acceptance_test.ps1 for the proper port numbers and config files to use in the above command.)

Expand Down
3 changes: 3 additions & 0 deletions UnitTests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TestResults/
store/
log/
13 changes: 8 additions & 5 deletions UnitTests/FileLogTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using NUnit.Framework;
Expand Down Expand Up @@ -48,15 +49,17 @@ public void testPrefixForSubsAndLocation()
[Test]
public void testGeneratedFileName()
{
if (System.IO.Directory.Exists("log"))
System.IO.Directory.Delete("log", true);
var logDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "log");

if (System.IO.Directory.Exists(logDirectory))
System.IO.Directory.Delete(logDirectory, true);

QuickFix.SessionID sessionID = new QuickFix.SessionID("FIX.4.2", "SENDERCOMP", "TARGETCOMP");
QuickFix.SessionSettings settings = new QuickFix.SessionSettings();

QuickFix.Dictionary config = new QuickFix.Dictionary();
config.SetString(QuickFix.SessionSettings.CONNECTION_TYPE, "initiator");
config.SetString(QuickFix.SessionSettings.FILE_LOG_PATH, "log");
config.SetString(QuickFix.SessionSettings.FILE_LOG_PATH, logDirectory);

settings.Set(sessionID, config);

Expand All @@ -67,8 +70,8 @@ public void testGeneratedFileName()
log.OnIncoming("some incoming");
log.OnOutgoing("some outgoing");

Assert.That(System.IO.File.Exists("log/FIX.4.2-SENDERCOMP-TARGETCOMP.event.current.log"));
Assert.That(System.IO.File.Exists("log/FIX.4.2-SENDERCOMP-TARGETCOMP.messages.current.log"));
Assert.That(System.IO.File.Exists(Path.Combine(logDirectory, "FIX.4.2-SENDERCOMP-TARGETCOMP.event.current.log")));
Assert.That(System.IO.File.Exists(Path.Combine(logDirectory, "FIX.4.2-SENDERCOMP-TARGETCOMP.messages.current.log")));
}

[Test]
Expand Down
20 changes: 13 additions & 7 deletions UnitTests/FileStoreTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using NUnit.Framework;
Expand All @@ -16,17 +17,21 @@ public class FileStoreTests
QuickFix.SessionSettings settings;
QuickFix.SessionID sessionID;

private string storeDirectory;

[SetUp]
public void setup()
{
if (System.IO.Directory.Exists("store"))
System.IO.Directory.Delete("store", true);
storeDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "store");

if (System.IO.Directory.Exists(storeDirectory))
System.IO.Directory.Delete(storeDirectory, true);

sessionID = new QuickFix.SessionID("FIX.4.2", "SENDERCOMP", "TARGETCOMP");

QuickFix.Dictionary config = new QuickFix.Dictionary();
config.SetString(QuickFix.SessionSettings.CONNECTION_TYPE, "initiator");
config.SetString(QuickFix.SessionSettings.FILE_STORE_PATH, "store");
config.SetString(QuickFix.SessionSettings.FILE_STORE_PATH, storeDirectory);

settings = new QuickFix.SessionSettings();
settings.Set(sessionID, config);
Expand All @@ -50,6 +55,7 @@ void rebuildStore()
public void teardown()
{
store.Dispose();
Directory.Delete(storeDirectory, true);
}

[Test]
Expand All @@ -65,10 +71,10 @@ public void testPrefixForSessionWithSubsAndLoc()
[Test]
public void generateFileNamesTest()
{
Assert.That(System.IO.File.Exists("store/FIX.4.2-SENDERCOMP-TARGETCOMP.seqnums"));
Assert.That(System.IO.File.Exists("store/FIX.4.2-SENDERCOMP-TARGETCOMP.body"));
Assert.That(System.IO.File.Exists("store/FIX.4.2-SENDERCOMP-TARGETCOMP.header"));
Assert.That(System.IO.File.Exists("store/FIX.4.2-SENDERCOMP-TARGETCOMP.session"));
Assert.That(System.IO.File.Exists(Path.Combine(storeDirectory, "FIX.4.2-SENDERCOMP-TARGETCOMP.seqnums")));
Assert.That(System.IO.File.Exists(Path.Combine(storeDirectory, "FIX.4.2-SENDERCOMP-TARGETCOMP.body")));
Assert.That(System.IO.File.Exists(Path.Combine(storeDirectory, "FIX.4.2-SENDERCOMP-TARGETCOMP.header")));
Assert.That(System.IO.File.Exists(Path.Combine(storeDirectory, "FIX.4.2-SENDERCOMP-TARGETCOMP.session")));
}

[Test]
Expand Down
13 changes: 7 additions & 6 deletions UnitTests/SessionDynamicTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
Expand Down Expand Up @@ -66,8 +67,7 @@ public SocketState(Socket s)
const string FIXMessageEnd = @"\x0110=\d{3}\x01";
const string FIXMessageDelimit = @"(8=FIX|\A).*?(" + FIXMessageEnd + @"|\z)";

const string LogPath = "log";

string _logPath;
SocketInitiator _initiator;
ThreadedSocketAcceptor _acceptor;
Dictionary<string, SocketState> _sessions;
Expand Down Expand Up @@ -113,7 +113,7 @@ void StartEngine(bool initiator)
IMessageStoreFactory storeFactory = new MemoryStoreFactory();
SessionSettings settings = new SessionSettings();
Dictionary defaults = new Dictionary();
defaults.SetString(QuickFix.SessionSettings.FILE_LOG_PATH, LogPath);
defaults.SetString(QuickFix.SessionSettings.FILE_LOG_PATH, _logPath);

// Put IP endpoint settings into default section to verify that that defaults get merged into
// session-specific settings not only for static sessions, but also for dynamic ones
Expand Down Expand Up @@ -303,17 +303,18 @@ void SendLogon(Socket s, string senderCompID)

void ClearLogs()
{
if (System.IO.Directory.Exists(LogPath))
if (System.IO.Directory.Exists(_logPath))
try
{
System.IO.Directory.Delete(LogPath, true);
System.IO.Directory.Delete(_logPath, true);
}
catch { }
}

[SetUp]
public void Setup()
{
_logPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "log");
_sessions = new Dictionary<string, SocketState>();
_loggedOnCompIDs = new HashSet<string>();
ClearLogs();
Expand Down Expand Up @@ -434,7 +435,7 @@ public void DynamicInitiator()
Assert.IsFalse(IsLoggedOn(StaticInitiatorCompID), "Session still logged on after being removed");

// Check that log directory default setting has been effective
Assert.Greater(System.IO.Directory.GetFiles(LogPath, QuickFix.Values.BeginString_FIX42 + "*.log").Length, 0);
Assert.Greater(System.IO.Directory.GetFiles(_logPath, QuickFix.Values.BeginString_FIX42 + "*.log").Length, 0);
}
}
}
12 changes: 8 additions & 4 deletions UnitTests/SessionStateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using QuickFix;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading;

namespace UnitTests
Expand Down Expand Up @@ -131,15 +132,16 @@ public void WithinHeartbeat()
[Test]
public void ThreadSafeSetAndGet() {
//Set up store
if (System.IO.Directory.Exists("store")) {
System.IO.Directory.Delete("store", true);
}
var storeDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "store");

if (System.IO.Directory.Exists(storeDirectory))
System.IO.Directory.Delete(storeDirectory, true);

SessionID sessionId = new SessionID("FIX.4.2", "SENDERCOMP", "TARGETCOMP");

Dictionary config = new Dictionary();
config.SetString(SessionSettings.CONNECTION_TYPE, "initiator");
config.SetString(SessionSettings.FILE_STORE_PATH, "store");
config.SetString(SessionSettings.FILE_STORE_PATH, storeDirectory);

SessionSettings settings = new SessionSettings();
settings.Set(sessionId, config);
Expand Down Expand Up @@ -215,6 +217,8 @@ public void ThreadSafeSetAndGet() {
//Tear down filestore
state.Dispose();
store.Dispose();

Directory.Delete(storeDirectory, true);
}
}
}
12 changes: 3 additions & 9 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
echo off

set TARGET=%1
set CONFIGURATION=%2
set NET_VERSION=%3
set TOOLS_VERSION=%4
set CONFIGURATION=%1

if "%1" == "" set TARGET=Rebuild
if "%2" == "" set CONFIGURATION=Release
if "%3" == "" set NET_VERSION=v4.5.2
if "%4" == "" set TOOLS_VERSION=14.0
if "%1" == "" set CONFIGURATION=Release

set BUILD_CMD=MSBuild.exe QuickFIXn.sln /t:%TARGET% /p:Configuration=%CONFIGURATION%;TargetFrameworkVersion=%NET_VERSION% /tv:%TOOLS_VERSION%
set BUILD_CMD=dotnet build -c %CONFIGURATION%
echo Build command: %BUILD_CMD%
%BUILD_CMD%
8 changes: 2 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#!/bin/sh

TARGET=$1
CONFIGURATION=$2
NET_VERSION=$3
CONFIGURATION=$1

[ -z $TARGET ] && TARGET=Rebuild
[ -z $CONFIGURATION ] && CONFIGURATION=Release
[ -z $NET_VERSION ] && NET_VERSION=v4.5.2

BUILD_CMD="xbuild QuickFIXn.sln /t:${TARGET} /p:Configuration=${CONFIGURATION};TargetFrameworkVersion=${NET_VERSION}"
BUILD_CMD="dotnet build -c ${CONFIGURATION}"
echo "Build command: $BUILD_CMD"
exec $BUILD_CMD
8 changes: 4 additions & 4 deletions package_release.bat
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ echo tag version: %TAG_VERSION%
echo

rem Update the assembly version
ruby scripts\update_assembly_version.rb %TAG_VERSION% QuickFIXn\Properties\AssemblyInfo.cs
ruby scripts\update_assembly_version.rb %TAG_VERSION% QuickFIXn\QuickFix.csproj
if %errorlevel% neq 0 echo "update_assembly_version.rb failed" && exit /b %errorlevel%
echo * AssemblyInfo updated for new version number.
echo * QuickFix.csproj updated for new version number.

rem commit the version file, so it will be part of the tag
call git add QuickFIXn\Properties\AssemblyInfo.cs
call git add QuickFIXn\QuickFix.csproj
call git commit -m "version number for version %TAG_VERSION%"
echo * Version number committed.

Expand Down Expand Up @@ -52,7 +52,7 @@ mkdir tmp\%QF_DIR%
mkdir tmp\%QF_DIR%\bin
mkdir tmp\%QF_DIR%\spec
mkdir tmp\%QF_DIR%\config
copy QuickFIXn\bin\Release\QuickFix.dll tmp\%QF_DIR%\bin
copy QuickFIXn\bin\Release\net452\QuickFix.dll tmp\%QF_DIR%\bin
xcopy spec tmp\%QF_DIR%\spec /e /y
copy config\sample_acceptor.cfg tmp\%QF_DIR%\config\
copy config\sample_initiator.cfg tmp\%QF_DIR%\config\
Expand Down
Binary file removed resources/nunit/failure.jpg
Binary file not shown.
Binary file removed resources/nunit/ignored.jpg
Binary file not shown.
Binary file removed resources/nunit/nunit-console-runner.dll
Binary file not shown.
Binary file removed resources/nunit/nunit-gui-runner.dll
Binary file not shown.
Binary file removed resources/nunit/nunit.core.dll
Binary file not shown.
Binary file removed resources/nunit/nunit.core.interfaces.dll
Binary file not shown.
Binary file removed resources/nunit/nunit.framework.dll
Binary file not shown.
Loading

0 comments on commit 49066c6

Please sign in to comment.