Skip to content

Commit

Permalink
Update Fixie to latest version. Separate integration tests into their…
Browse files Browse the repository at this point in the history
… own assembly. Integration tests use a custom convention, in which new test cases can be added simply by dropping a *.rook and *.rook.out file into the project.
  • Loading branch information
plioi committed Mar 21, 2014
1 parent fe8b58b commit 371cb8d
Show file tree
Hide file tree
Showing 40 changed files with 257 additions and 192 deletions.
3 changes: 2 additions & 1 deletion default.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ properties {
task default -depends Test

task Test -depends Compile {
$fixieRunner = join-path $src "packages\Fixie.0.0.1.133\lib\net45\Fixie.Console.exe"
$fixieRunner = join-path $src "packages\Fixie.0.0.1.144\lib\net45\Fixie.Console.exe"
exec { & $fixieRunner $src\$project.Test\bin\$configuration\$project.Test.dll }
exec { & $fixieRunner $src\$project.IntegrationTest\bin\$configuration\$project.IntegrationTest.dll }
}

task Compile -depends CommonAssemblyInfo {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions src/Rook.IntegrationTest/IntegrationTestConvention.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.IO;
using System.Linq;
using Fixie;
using Fixie.Conventions;

namespace Rook.IntegrationTest
{
public class IntegrationTestConvention : Convention
{
public IntegrationTestConvention()
{
Classes
.Where(type => type == typeof(IntegrationTests));

Methods
.Where(method => method.IsVoid());

Parameters(method => Directory.GetFiles(Directory.GetCurrentDirectory())
.Where(file => file.EndsWith(".rook"))
.Select(Path.GetFileName)
.Select(file => file.Substring(0, file.Length - ".rook".Length))
.Select(file => new object[] {file}));
}
}
}
45 changes: 45 additions & 0 deletions src/Rook.IntegrationTest/IntegrationTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.IO;
using System.Linq;
using System.Reflection;
using Fixie;
using Rook.Compiling;
using Should;

namespace Rook.IntegrationTest
{
public class IntegrationTests
{
public void ProgramShouldHaveExpectedOutput(string programName)
{
var expectedOutput = File.ReadAllText(programName + ".rook.out");
var actualOutput = Execute(Build(File.ReadAllText(programName + ".rook"))).ToString();

actualOutput.ShouldEqual(expectedOutput);
}

private static Assembly Build(string rookCode)
{
var result = new RookCompiler(CompilerParameters.ForBasicEvaluation()).Build(rookCode);

if (result.Errors.Any())
Fail.WithErrors(result.Errors);

return result.CompiledAssembly;
}

private static object Execute(Assembly assembly)
{
using (var console = new RedirectedConsole())
{
var result = assembly.Execute();

var writerResult = console.Output;

if ((result == null || result == Core.Void.Value) && writerResult != "")
return writerResult;

return result;
}
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions src/Rook.IntegrationTest/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
using System.Reflection;
[assembly: AssemblyTitle("Rook.IntegrationTest")]
File renamed without changes.
File renamed without changes.
168 changes: 168 additions & 0 deletions src/Rook.IntegrationTest/Rook.IntegrationTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A593DA5E-1ADE-4CDC-85B5-C1F8B39C082B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Rook.IntegrationTest</RootNamespace>
<AssemblyName>Rook.IntegrationTest</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Fixie">
<HintPath>..\packages\Fixie.0.0.1.144\lib\net45\Fixie.dll</HintPath>
</Reference>
<Reference Include="Should">
<HintPath>..\packages\Should.1.1.20\lib\Should.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\CommonAssemblyInfo.cs">
<Link>Properties\CommonAssemblyInfo.cs</Link>
</Compile>
<Compile Include="IntegrationTestConvention.cs" />
<Compile Include="IntegrationTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="ArithmeticExpression.rook">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ArithmeticExpression.rook.out">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="BlockExpression.rook">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="BlockExpression.rook.out">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="BooleanExpression.rook">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="BooleanExpression.rook.out">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Classes.rook">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Classes.rook.out">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Closure.rook">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Closure.rook.out">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Enumerable.rook">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Enumerable.rook.out">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="FunctionCall.rook">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="FunctionCall.rook.out">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="IndexerOverloading.rook">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="IndexerOverloading.rook.out">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="MethodInvocation.rook">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="MethodInvocation.rook.out">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="MutualRecursion.rook">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="MutualRecursion.rook.out">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Nullable.rook">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Nullable.rook.out">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Recursion.rook">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Recursion.rook.out">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="String.rook">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="String.rook.out">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Vector.rook">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Vector.rook.out">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Void.rook">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Void.rook.out">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Rook.Compiling\Rook.Compiling.csproj">
<Project>{DD4E13B5-E96D-4DBF-9821-9908839ECDD4}</Project>
<Name>Rook.Compiling</Name>
</ProjectReference>
<ProjectReference Include="..\Rook.Core\Rook.Core.csproj">
<Project>{646BF299-17FE-4B59-BC83-5D28AF7D5A48}</Project>
<Name>Rook.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Rook.Test\Rook.Test.csproj">
<Project>{1F93496B-9601-4EA7-86A7-B1615E5847A9}</Project>
<Name>Rook.Test</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions src/Rook.IntegrationTest/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Fixie" version="0.0.1.144" targetFramework="net45" />
<package id="Should" version="1.1.20" targetFramework="net45" />
</packages>
95 changes: 0 additions & 95 deletions src/Rook.Test/Integration/IntegrationTests.cs

This file was deleted.

Loading

0 comments on commit 371cb8d

Please sign in to comment.