Fix unit tests and run them in CI
This commit is contained in:
Родитель
10d055187e
Коммит
a268ef6fee
|
@ -10,6 +10,7 @@ obj
|
|||
Test/UnitTests/bin
|
||||
Test/UnitTests/obj
|
||||
Test/lib
|
||||
Test/tmp
|
||||
packages
|
||||
|
||||
# Ide stuff
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
<NoWarn>1574;1591</NoWarn>
|
||||
<ConsolePause>False</ConsolePause>
|
||||
<OutputPath>..\bin</OutputPath>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<RootNamespace>CommandExtension</RootNamespace>
|
||||
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
||||
<TargetFrameworks>$(DotNetCoreTarget)</TargetFrameworks>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<RootNamespace>FileContentExtension</RootNamespace>
|
||||
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
||||
<TargetFrameworks>$(DotNetCoreTarget)</TargetFrameworks>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<RootNamespace>FileExtender</RootNamespace>
|
||||
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
||||
<TargetFrameworks>$(DotNetCoreTarget)</TargetFrameworks>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<RootNamespace>HelloWorldExtension</RootNamespace>
|
||||
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
||||
<TargetFrameworks>$(DotNetCoreTarget)</TargetFrameworks>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
<RootNamespace>MultiAssemblyAddin</RootNamespace>
|
||||
<AssemblyName>MultiAssemblyAddin</AssemblyName>
|
||||
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
||||
<TargetFrameworks>$(DotNetCoreTarget)</TargetFrameworks>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
<RootNamespace>OptionalModule</RootNamespace>
|
||||
<AssemblyName>OptionalModule</AssemblyName>
|
||||
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
||||
<TargetFrameworks>$(DotNetCoreTarget)</TargetFrameworks>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
<RootNamespace>SecondAssembly</RootNamespace>
|
||||
<AssemblyName>SecondAssembly</AssemblyName>
|
||||
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
||||
<TargetFrameworks>$(DotNetCoreTarget)</TargetFrameworks>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<RootNamespace>SystemInfoExtension</RootNamespace>
|
||||
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
||||
<TargetFrameworks>$(DotNetCoreTarget)</TargetFrameworks>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
|
|
|
@ -9,8 +9,6 @@ namespace UnitTests
|
|||
{
|
||||
public class TestBase
|
||||
{
|
||||
static bool firstRun = true;
|
||||
|
||||
public static string TempDir {
|
||||
get {
|
||||
string dir = new Uri (typeof(TestBase).Assembly.CodeBase).LocalPath;
|
||||
|
@ -25,23 +23,19 @@ namespace UnitTests
|
|||
AddinManager.AddinLoaded += OnLoad;
|
||||
AddinManager.AddinUnloaded += OnUnload;
|
||||
|
||||
if (firstRun) {
|
||||
if (Directory.Exists (TempDir))
|
||||
Directory.Delete (TempDir, true);
|
||||
Directory.CreateDirectory (TempDir);
|
||||
}
|
||||
if (Directory.Exists (TempDir))
|
||||
Directory.Delete (TempDir, true);
|
||||
Directory.CreateDirectory (TempDir);
|
||||
|
||||
var configDir = Path.Combine(TempDir, "config");
|
||||
Directory.CreateDirectory(configDir);
|
||||
|
||||
// Provide the current assembly as startup assembly, otherwise it will pick the
|
||||
// unit test runner as startup assembly
|
||||
|
||||
AddinManager.AddinEngine.Initialize (GetType().Assembly, null, TempDir, null, null);
|
||||
AddinManager.AddinEngine.Initialize (GetType().Assembly, null, configDir, null, null);
|
||||
|
||||
if (firstRun)
|
||||
AddinManager.Registry.Update (new ConsoleProgressStatus (true));
|
||||
else
|
||||
AddinManager.Registry.ResetConfiguration ();
|
||||
|
||||
firstRun = false;
|
||||
AddinManager.Registry.Update (new ConsoleProgressStatus (true));
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace UnitTests
|
|||
{
|
||||
setup = new SetupService ();
|
||||
baseDir = Path.GetDirectoryName (new Uri (typeof(TestBase).Assembly.CodeBase).LocalPath);
|
||||
addinsDir = new DirectoryInfo (baseDir).Parent.Parent.Parent.FullName;
|
||||
addinsDir = new DirectoryInfo (baseDir).Parent.Parent.Parent.Parent.FullName;
|
||||
addinsDir = Path.Combine (addinsDir, "lib");
|
||||
|
||||
repoDir = Path.Combine (TempDir, "repo");
|
||||
|
|
|
@ -2,25 +2,14 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\TargetFrameworks.props" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<ProjectGuid>{1CD51E61-1985-4D22-9BFA-D14C8FC61B46}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AssemblyName>UnitTests</AssemblyName>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<RootNamespace>UnitTests</RootNamespace>
|
||||
<SignAssembly>True</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>..\..\mono-addins.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||
<TargetFrameworks>net472;net6.0</TargetFrameworks>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
<DebugType>embedded</DebugType>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
|
@ -28,6 +17,7 @@
|
|||
<Reference Include="System.Core" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
|
||||
<PackageReference Include="Microsoft.Net.Test.Sdk" Version="17.3.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Mono.Addins\Mono.Addins.csproj" />
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace UnitTests
|
|||
public static string TestsRootDir {
|
||||
get {
|
||||
if (rootDir == null)
|
||||
rootDir = Path.GetFullPath (Path.Combine (Path.GetDirectoryName (typeof(Util).Assembly.Location), "..", "..", ".."));
|
||||
rootDir = Path.GetFullPath (Path.Combine (Path.GetDirectoryName (typeof(Util).Assembly.Location), "..", "..", "..", ".."));
|
||||
return rootDir;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<Addins>
|
||||
<Directory>../../../lib</Directory>
|
||||
<Directory>../../../lib/extras</Directory>
|
||||
<Directory>../../../../lib</Directory>
|
||||
<Directory>../../../../lib/extras</Directory>
|
||||
<Directory>SampleAddins</Directory>
|
||||
</Addins>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
pool:
|
||||
vmImage: 'macOS-10.15'
|
||||
vmImage: 'macos-latest'
|
||||
|
||||
variables:
|
||||
- name: BuildConfiguration
|
||||
|
@ -52,20 +52,11 @@ steps:
|
|||
nobuild: true
|
||||
workingDirectory: $(Build.SourcesDirectory)
|
||||
|
||||
#- task: MSBuild@1
|
||||
# displayName: 'Test Assemblies Test\UnitTests\bin\Debug\UnitTests.dll'
|
||||
# inputs:
|
||||
# solution: 'Test/UnitTests/UnitTests.csproj'
|
||||
# platform: '$(BuildPlatform)'
|
||||
# configuration: '$(BuildConfiguration)'
|
||||
# msbuildArguments: '/t:Test'
|
||||
#
|
||||
#- task: PublishTestResults@2
|
||||
# displayName: 'Publish Test Results Test\UnitTests\TestResult.xml'
|
||||
# inputs:
|
||||
# testResultsFormat: 'NUnit'
|
||||
# testResultsFiles: 'Test/UnitTests/TestResult.xml'
|
||||
# failTaskOnFailedTests: true
|
||||
- task: DotNetCoreCLI@2
|
||||
displayName: Test
|
||||
inputs:
|
||||
command: 'test'
|
||||
workingDirectory: '$(Build.SourcesDirectory)/Test/UnitTests'
|
||||
|
||||
- task: Bash@3
|
||||
displayName: 'Generate package file list'
|
||||
|
|
Загрузка…
Ссылка в новой задаче