Skip to content

Commit

Permalink
Working on new test utility
Browse files Browse the repository at this point in the history
  • Loading branch information
someone-with-default-username committed Sep 3, 2012
1 parent ea99170 commit ee54589
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 11 deletions.
26 changes: 17 additions & 9 deletions snippets/Nemerle.Test/Nemerle.Compiler.Test/Main.n
Expand Up @@ -147,16 +147,24 @@ internal module Program
| None() => None()
};
def mainExecutionListener = NccTestExecutionListener(outputWriter);
mutable listeners = [mainExecutionListener];
unless(string.IsNullOrEmpty(teamCityTestSuite))
listeners ::= TeamCityExecutionListener(teamCityTestSuite, false, output);
unless(string.IsNullOrEmpty(visualStudioTestSuite))
listeners ::= VisualStudioExecutionListener(visualStudioTestSuite, visualStudioSummaryResult);
def runner = Runner(match(listeners)
def listener =
{
| [one] => one
| many => MulticastExecutionListener(many)
});
mutable listeners = [mainExecutionListener];
unless(string.IsNullOrEmpty(teamCityTestSuite))
listeners ::= TeamCityExecutionListener(teamCityTestSuite, false, output);
unless(string.IsNullOrEmpty(visualStudioTestSuite))
listeners ::= VisualStudioExecutionListener(visualStudioTestSuite, visualStudioSummaryResult);
match(listeners)
{
| [one] => one
| many => MulticastExecutionListener(many)
}
};
def runner =
if(ncc is HostedNcc && typeof(object).GetType().FullName == "System.RuntimeType")
ThreadRunner(listener, 20 * 1024 * 1024 * if (IntPtr.Size == 8) 4 else 1)
else
Runner(listener);
def tests = FileSearcher.Search(testFiles).Select(NccTest(_, outputWriter, ncc, referencies, verifier, processStartFactory));
runner.Run(tests);
mainExecutionListener.GetExitCode()
Expand Down
Expand Up @@ -25,6 +25,9 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<StartProgram />
<WorkingDirectory />
<CmdArgs>C:\!Proj\nemerle\ncc\testsuite\positive\array.n</CmdArgs>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
Expand All @@ -51,6 +54,11 @@
<HintPath>$(Nemerle)\Nemerle.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Nemerle.Macros">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(Nemerle)\Nemerle.Macros.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Nemerle.Compiler">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(Nemerle)\Nemerle.Compiler.dll</HintPath>
Expand Down Expand Up @@ -82,6 +90,9 @@
<Compile Include="ProcessExtensions.n">
<SubType>Code</SubType>
</Compile>
<Compile Include="ThreadRunner.n">
<SubType>Code</SubType>
</Compile>
<Compile Include="UnixColorizedOutputWriter.n">
<SubType>Code</SubType>
</Compile>
Expand Down
36 changes: 36 additions & 0 deletions snippets/Nemerle.Test/Nemerle.Compiler.Test/ThreadRunner.n
@@ -0,0 +1,36 @@
using Nemerle;
using Nemerle.Assertions;
using Nemerle.Collections;
using Nemerle.Text;
using Nemerle.Utility;

using Nemerle.Test.Framework;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;

namespace Nemerle.Compiler.Test
{
/// <summary>
/// Description of ThreadRunner.
/// </summary>
internal sealed class ThreadRunner : Runner
{
public this([NotNull] executionListener : ExecutionListener, stackSize : int)
{
base(executionListener);
_stackSize = stackSize;
}

public override Run([NotNull] tests : IEnumerable[Test]) : void
{
def thread = Thread(fun() { base.Run(tests) }, _stackSize);
thread.Start();
thread.Join();
}

private _stackSize : int;
}
}
4 changes: 2 additions & 2 deletions snippets/Nemerle.Test/Nemerle.Test.Framework/Runner.n
Expand Up @@ -11,14 +11,14 @@ using System.Linq;

namespace Nemerle.Test.Framework
{
public sealed class Runner
public class Runner
{
public this([NotNull] executionListener : ExecutionListener)
{
_executionListener = executionListener;
}

public Run(tests : IEnumerable[Test]) : void
public virtual Run([NotNull] tests : IEnumerable[Test]) : void
{
def timer = Stopwatch();
_executionListener.Start();
Expand Down

0 comments on commit ee54589

Please sign in to comment.