Skip to content

Commit

Permalink
Removed Test.Common project file.
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed Jun 12, 2022
1 parent d5f3bd5 commit e80c0e7
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 84 deletions.
7 changes: 0 additions & 7 deletions il2c.sln
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Core.Test.BasicTypes",
{2CBC90EC-5581-452F-8231-086E4553D20E} = {2CBC90EC-5581-452F-8231-086E4553D20E}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Core.Test.Common", "tests\IL2C.Core.Test.Common\IL2C.Core.Test.Common.csproj", "{6811E378-50B3-4206-BB48-1E56A2F2D90E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IL2C.Core.Test.ILConverters", "tests\IL2C.Core.Test.ILConverters\IL2C.Core.Test.ILConverters.csproj", "{DC306000-300C-4E65-826C-2E41C6445CA9}"
ProjectSection(ProjectDependencies) = postProject
{BB7FA204-433A-416B-B9D0-9A79DF874284} = {BB7FA204-433A-416B-B9D0-9A79DF874284}
Expand Down Expand Up @@ -146,10 +144,6 @@ Global
{A6072CD1-A526-45F2-BB88-D1040AC3A7E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A6072CD1-A526-45F2-BB88-D1040AC3A7E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A6072CD1-A526-45F2-BB88-D1040AC3A7E8}.Release|Any CPU.Build.0 = Release|Any CPU
{6811E378-50B3-4206-BB48-1E56A2F2D90E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6811E378-50B3-4206-BB48-1E56A2F2D90E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6811E378-50B3-4206-BB48-1E56A2F2D90E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6811E378-50B3-4206-BB48-1E56A2F2D90E}.Release|Any CPU.Build.0 = Release|Any CPU
{DC306000-300C-4E65-826C-2E41C6445CA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DC306000-300C-4E65-826C-2E41C6445CA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DC306000-300C-4E65-826C-2E41C6445CA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -192,7 +186,6 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{A6072CD1-A526-45F2-BB88-D1040AC3A7E8} = {5710A57F-57F8-4D50-8C78-82E2DFDCB613}
{6811E378-50B3-4206-BB48-1E56A2F2D90E} = {5710A57F-57F8-4D50-8C78-82E2DFDCB613}
{DC306000-300C-4E65-826C-2E41C6445CA9} = {5710A57F-57F8-4D50-8C78-82E2DFDCB613}
{E397A251-4373-4A8E-AA13-3891282DEDC7} = {5710A57F-57F8-4D50-8C78-82E2DFDCB613}
{C26C4683-9840-4307-8774-F1F952E3591B} = {D105E6CD-626A-4C04-8AF6-0AA34A4E9CF4}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<OutputType>Library</OutputType>
<Optimize>False</Optimize>
<Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<DefineConstants>$(DefineConstants);$(OS)</DefineConstants>

<AssemblyName>IL2C.Core.Test.BasicTypes</AssemblyName>
Expand All @@ -38,10 +39,12 @@

<ItemGroup>
<ProjectReference Include="..\..\src\IL2C.Interop\IL2C.Interop.csproj" />
<ProjectReference Include="..\..\src\IL2C.Core\IL2C.Core.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\IL2C.Core.Test.Common\*.cs" />
<EmbeddedResource Include="..\IL2C.Core.Test.Common\Templates\*" LinkBase="Templates" />
</ItemGroup>

<!-- ====================================================== -->
Expand Down
19 changes: 0 additions & 19 deletions tests/IL2C.Core.Test.Common/IL2C.Core.Test.Common.csproj

This file was deleted.

50 changes: 50 additions & 0 deletions tests/IL2C.Core.Test.Common/Templates/TestMain.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
////////////////////////////////////////////////////////////////////////////
//
// IL2C - A translator for ECMA-335 CIL/MSIL to C language.
// Copyright (c) Kouji Matsui (@kozy_kekyo, @[email protected])
//
// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
////////////////////////////////////////////////////////////////////////////

using System;

namespace IL2C.Tests
{
public static class TestMain
{
public static int Main()
{
try
{
#if {mainIsVoid}
////////////////////////
// Execute target function.

{mainSymbol}();
#else
////////////////////////
// Execute target function.

var actual = {mainSymbol}();

////////////////////////
// Check result.

if (actual != {expected})
{
Console.WriteLine(actual?.ToString());
return 1;
}
#endif
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return 2;
}

return 0;
}
}
}
61 changes: 4 additions & 57 deletions tests/IL2C.Core.Test.Common/TestCaseAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ public RunOnOSs RunOnOSs
this.runOnOSs = value;

var ignores = new List<string>();
if (Utilities.IsRunningOnWindows &&
if (TestUtilities.IsRunningOnWindows &&
!value.HasFlag(RunOnOSs.Windows))
{
ignores.Add("NotWindows");
}
if (!Utilities.IsRunningOnWindows &&
if (!TestUtilities.IsRunningOnWindows &&
!value.HasFlag(RunOnOSs.Posix))
{
ignores.Add("NotPosix");
Expand Down Expand Up @@ -195,12 +195,12 @@ public RunOnPlatforms RunOnPlatforms
this.runOnPlatforms = value;

var ignores = new List<string>();
if (!Utilities.IsRunningOnMono &&
if (!TestUtilities.IsRunningOnMono &&
!value.HasFlag(RunOnPlatforms.DotNet))
{
ignores.Add("NotDotNet");
}
if (Utilities.IsRunningOnMono &&
if (TestUtilities.IsRunningOnMono &&
!value.HasFlag(RunOnPlatforms.Mono))
{
ignores.Add("NotMono");
Expand Down Expand Up @@ -237,58 +237,5 @@ public void AfterTest(ITest test)
{
// TODO: delegates to test native code.
}

#if false
private static object?[] ConvertToArgumentsType(object?[] args, Type[] argumentTypes) =>
args.Zip(argumentTypes, ConvertToArgumentType).ToArray();

private static object? ConvertToArgumentType(object? value, Type argumentType)
{
// This is helper function that convert between raw value type and argument type.
// Because .NET attribute can't have complex type arguments.
if (value == null)
{
return null;
}
else if (value.GetType() == argumentType)
{
return value;
}
else if (argumentType == typeof(IntPtr))
{
if (value is int)
{
return new IntPtr((int)value);
}
else if (value is long)
{
return new IntPtr((long)value);
}
else
{
throw new InvalidCastException();
}
}
else if (argumentType == typeof(UIntPtr))
{
if (value is uint)
{
return new UIntPtr((uint)value);
}
else if (value is ulong)
{
return new UIntPtr((ulong)value);
}
else
{
throw new InvalidCastException();
}
}
else
{
return Convert.ChangeType(value, argumentType);
}
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace IL2C
{
[IgnoreTranslation]
public static class Utilities
public static class TestUtilities
{
public static readonly bool IsRunningOnWindows =
Environment.OSVersion.Platform == PlatformID.Win32NT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<OutputType>Library</OutputType>
<Optimize>False</Optimize>
<Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<DefineConstants>$(DefineConstants);$(OS)</DefineConstants>

<AssemblyName>IL2C.Core.Test.ILConverters</AssemblyName>
Expand All @@ -38,6 +39,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\IL2C.Interop\IL2C.Interop.csproj" />
<ProjectReference Include="..\..\src\IL2C.Core\IL2C.Core.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<OutputType>Library</OutputType>
<Optimize>False</Optimize>
<Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<DefineConstants>$(DefineConstants);$(OS)</DefineConstants>

<AssemblyName>IL2C.Core.Test.RuntimeSystems</AssemblyName>
Expand All @@ -38,6 +39,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\IL2C.Interop\IL2C.Interop.csproj" />
<ProjectReference Include="..\..\src\IL2C.Core\IL2C.Core.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit e80c0e7

Please sign in to comment.