-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from TorchAPI/jenkins
Testing Project and Auto Versioning
- Loading branch information
Showing
13 changed files
with
352 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<ProjectGuid>{53EFDFD0-9BCA-4E67-ABB2-628715E3F74B}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Concealment.Tests</RootNamespace> | ||
<AssemblyName>Concealment.Tests</AssemblyName> | ||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<TargetFrameworkProfile /> | ||
<NuGetPackageImportStamp> | ||
</NuGetPackageImportStamp> | ||
<NoWarn>1591,0649</NoWarn> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>$(SolutionDir)\bin-test\x64\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<DebugType>full</DebugType> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> | ||
<OutputPath>$(SolutionDir)\bin-test\x64\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<Optimize>true</Optimize> | ||
<DebugType>pdbonly</DebugType> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
<DocumentationFile>$(SolutionDir)\bin-test\x64\Release\Concealment.Tests.xml</DocumentationFile> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\NLog.4.4.12\lib\net45\NLog.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath> | ||
</Reference> | ||
<Reference Include="xunit.assert, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll</HintPath> | ||
</Reference> | ||
<Reference Include="xunit.core, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="xunit.execution.desktop, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Torch"> | ||
<HintPath>$(SolutionDir)\TorchBinaries\Torch.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Torch.API"> | ||
<HintPath>$(SolutionDir)\TorchBinaries\Torch.API.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="..\Versioning\AssemblyVersion.cs"> | ||
<Link>Properties\AssemblyVersion.cs</Link> | ||
</Compile> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="ReflectionTestManager.cs" /> | ||
<Compile Include="TestUtils.cs" /> | ||
<Compile Include="TorchReflectionTest.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Concealment\Concealment.csproj"> | ||
<Project>{E5C0184B-7DC4-43D8-872E-2F71162748AA}</Project> | ||
<Name>Concealment</Name> | ||
<Private>True</Private> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
[assembly: AssemblyTitle("Torch Tests")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("Torch")] | ||
[assembly: AssemblyCopyright("Copyright © Torch API 2017")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
[assembly: ComVisible(false)] | ||
|
||
#if DEBUG | ||
[assembly: AssemblyConfiguration("Debug")] | ||
#else | ||
[assembly: AssemblyConfiguration("Release")] | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using Torch.Utils; | ||
|
||
namespace Torch.Tests | ||
{ | ||
public class ReflectionTestManager | ||
{ | ||
#region FieldProvider | ||
public struct FieldRef | ||
{ | ||
public FieldInfo Field; | ||
|
||
public FieldRef(FieldInfo f) | ||
{ | ||
Field = f; | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
if (Field == null) | ||
return "Ignored"; | ||
return Field.DeclaringType?.FullName + "." + Field.Name; | ||
} | ||
} | ||
|
||
private readonly HashSet<object[]> _getters = new HashSet<object[]>(); | ||
private readonly HashSet<object[]> _setters = new HashSet<object[]>(); | ||
private readonly HashSet<object[]> _invokers = new HashSet<object[]>(); | ||
|
||
public ReflectionTestManager() | ||
{ | ||
_getters.Add(new object[] { new FieldRef(null) }); | ||
_setters.Add(new object[] { new FieldRef(null) }); | ||
_invokers.Add(new object[] { new FieldRef(null) }); | ||
} | ||
|
||
public ReflectionTestManager Init(Assembly asm) | ||
{ | ||
foreach (Type type in asm.GetTypes()) | ||
Init(type); | ||
return this; | ||
} | ||
|
||
public ReflectionTestManager Init(Type type) | ||
{ | ||
foreach (FieldInfo field in type.GetFields(BindingFlags.Static | | ||
BindingFlags.Instance | | ||
BindingFlags.Public | | ||
BindingFlags.NonPublic)) | ||
{ | ||
if (field.GetCustomAttribute<ReflectedMethodAttribute>() != null) | ||
_invokers.Add(new object[] { new FieldRef(field) }); | ||
if (field.GetCustomAttribute<ReflectedGetterAttribute>() != null) | ||
_getters.Add(new object[] { new FieldRef(field) }); | ||
if (field.GetCustomAttribute<ReflectedSetterAttribute>() != null) | ||
_setters.Add(new object[] { new FieldRef(field) }); | ||
} | ||
return this; | ||
} | ||
|
||
public IEnumerable<object[]> Getters => _getters; | ||
|
||
public IEnumerable<object[]> Setters => _setters; | ||
|
||
public IEnumerable<object[]> Invokers => _invokers; | ||
|
||
#endregion | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Torch.Utils; | ||
|
||
namespace Torch.Tests | ||
{ | ||
public sealed class TestUtils | ||
{ | ||
public static void Init() | ||
{ | ||
if (_torchResolver == null) | ||
_torchResolver = new TorchAssemblyResolver(GetGameBinaries()); | ||
} | ||
|
||
private static string GetGameBinaries() | ||
{ | ||
string dir = Environment.CurrentDirectory; | ||
while (!string.IsNullOrWhiteSpace(dir)) | ||
{ | ||
string gameBin = Path.Combine(dir, "GameBinaries"); | ||
if (Directory.Exists(gameBin)) | ||
return gameBin; | ||
|
||
dir = Path.GetDirectoryName(dir); | ||
} | ||
throw new Exception("GetGameBinaries failed to find a folder named GameBinaries in the directory tree"); | ||
} | ||
|
||
private static TorchAssemblyResolver _torchResolver; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using Torch.Tests; | ||
using Torch.Utils; | ||
using Xunit; | ||
|
||
namespace Concealment.Tests | ||
{ | ||
public class TorchReflectionTest | ||
{ | ||
static TorchReflectionTest() | ||
{ | ||
TestUtils.Init(); | ||
} | ||
|
||
private static ReflectionTestManager _manager; | ||
|
||
private static ReflectionTestManager Manager() | ||
{ | ||
TestUtils.Init(); | ||
if (_manager != null) | ||
return _manager; | ||
return _manager = new ReflectionTestManager().Init(typeof(ConcealmentPlugin).Assembly); | ||
} | ||
|
||
public static IEnumerable<object[]> Getters => Manager().Getters; | ||
|
||
public static IEnumerable<object[]> Setters => Manager().Setters; | ||
|
||
public static IEnumerable<object[]> Invokers => Manager().Invokers; | ||
|
||
#region Binding | ||
[Theory] | ||
[MemberData(nameof(Getters))] | ||
public void TestBindingGetter(ReflectionTestManager.FieldRef field) | ||
{ | ||
if (field.Field == null) | ||
return; | ||
Assert.True(ReflectedManager.Process(field.Field)); | ||
if (field.Field.IsStatic) | ||
Assert.NotNull(field.Field.GetValue(null)); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(Setters))] | ||
public void TestBindingSetter(ReflectionTestManager.FieldRef field) | ||
{ | ||
if (field.Field == null) | ||
return; | ||
Assert.True(ReflectedManager.Process(field.Field)); | ||
if (field.Field.IsStatic) | ||
Assert.NotNull(field.Field.GetValue(null)); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(Invokers))] | ||
public void TestBindingInvoker(ReflectionTestManager.FieldRef field) | ||
{ | ||
if (field.Field == null) | ||
return; | ||
Assert.True(ReflectedManager.Process(field.Field)); | ||
if (field.Field.IsStatic) | ||
Assert.NotNull(field.Field.GetValue(null)); | ||
} | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Mono.TextTransform" version="1.0.0" targetFramework="net461" /> | ||
<package id="NLog" version="4.4.12" targetFramework="net461" /> | ||
<package id="xunit" version="2.2.0" targetFramework="net461" /> | ||
<package id="xunit.abstractions" version="2.0.1" targetFramework="net461" /> | ||
<package id="xunit.assert" version="2.2.0" targetFramework="net461" /> | ||
<package id="xunit.core" version="2.2.0" targetFramework="net461" /> | ||
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net461" /> | ||
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net461" /> | ||
<package id="xunit.runner.console" version="2.2.0" targetFramework="net461" developmentDependency="true" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.