Skip to content

Commit

Permalink
enable build on Linux and fix test execution on Linux (#1784)
Browse files Browse the repository at this point in the history
* Add .NET Framework Assembly References to Build Properties

* Add Linux and MacOS to build pipeline

* fix build pipeline

* Update to new .NET Core preview + fix Linux build

* fix Manifest name

* Update nuget.config

* Update nuget version

* remove MacOS from build pipeline

* Fix some Runtime Tests for Linux

* Fix tests with windows-only paths under linux

* fix tests for net471

* fix tests for netcoreapp2.1

* Refactor Skip condition in UriValueRetriever

* Fix Generator Tests for Linux

* Fix Runtime Test Unit Test Provider Configuration

* Adapt Specs to .Net Core (for Linux)

* Refactor OS check + build Specs in .Net Core only

* update parameter from '/' to '-'

* add newline at end of build.ps1

* update Submodule

* fix build

* Update Specs .net core version to 3.0

* fix path to end with netcoreapp3.0

* update submodule

* update build and add Dockerfile

* update submodule

* use dotnet instead of msbuild and vstest

* update submodule

* update build

* fix dependencies of MSBuildSdkIntegrationTests and Specs

* update submodule

* update Dockerfile

* update submodule

* use dotnet build instead of msbuild per default

* update submodule

* fix typo from submodule

* adapt build.ps1

* replace dash with slash

* fix MSBuild command-line property

* remove old msbuild search and wrap appInsightsInstrumentationKey in quotes

* update submodule

* refactor scenario

* refactor compilation

* update submodule

* refactor to using new drivers

* update submodule

* update submodule

* update Dockerfile

* update submodule

* update MultiFeatureGenerator to generate tests for .NET Core 2.1 only on Windows

* add output of dotnet build command

* wrap value in quotes

* fix build script for windows

* reformat code

* include dotsettings in solution

* fix typo

* make MSBuildProjectReader non-static with interface

* make GeneratorContainerBuilder non-static

* reformat code

* use Result objects in analytics transmission

* refactor GenerateFeatureFileCodeBehindTask into smaller classes

* fix missing injection

* update submodule

* add abbreviations to dotsettings

* update base docker image

* make AssemblyHooks classes public

* fix whitespaces

* use CreateSpecFlowProject for step

* update submodule

* derive generated test class explicitly from object

* update name of isInterface field

* update submodule

* update submodule

* add RuntimeInformationProvider to specs

* update wording

* refactor steps for build systems

* refactor LanguageSupport.feature

* refactor MultipleSpecsProjects

* fix backslash

* adapt rules to use var when evident

* use var

* use Array.Empty

* work on PR feedback

* change async in analytics transmission

* make tests async
  • Loading branch information
SabotageAndi authored Dec 2, 2019
1 parent f125534 commit b6c4d72
Show file tree
Hide file tree
Showing 105 changed files with 1,452 additions and 1,009 deletions.
11 changes: 8 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<Import Project="macos.props" />


<PropertyGroup>
<LangVersion>7.3</LangVersion>
Expand All @@ -9,8 +9,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="all"/>
<PackageReference Include="Nerdbank.GitVersioning" Version="2.3.38" PrivateAssets="all"/>
<None Include="$(SolutionDir)/LICENSE.txt" Pack="true" PackagePath=""/>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0-preview.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<PropertyGroup>
Expand All @@ -37,14 +41,15 @@
<SpecFlow_Core_Test_TFM>netcoreapp2.1;netcoreapp3.0</SpecFlow_Core_Test_TFM>

<SpecFlow_FullFramework_Specs_TFM>net471</SpecFlow_FullFramework_Specs_TFM>
<SpecFlow_Core_Specs_TFM>netcoreapp3.0</SpecFlow_Core_Specs_TFM>

<SpecFlow_FullFramework_Tools_TFM>net471</SpecFlow_FullFramework_Tools_TFM>
<SpecFlow_Core_Tools_TFM>netcoreapp2.0</SpecFlow_Core_Tools_TFM>

<SpecFlow_Runtime_TFM>$(SpecFlow_FullFramework_Runtime_TFM);$(SpecFlow_Core_Runtime_TFM)</SpecFlow_Runtime_TFM>
<SpecFlow_Generator_TFM>$(SpecFlow_FullFramework_Generator_TFM);$(SpecFlow_Core_Generator_TFM)</SpecFlow_Generator_TFM>
<SpecFlow_Test_TFM>$(SpecFlow_FullFramework_Test_TFM);$(SpecFlow_Core_Test_TFM)</SpecFlow_Test_TFM>
<SpecFlow_Specs_TFM>$(SpecFlow_FullFramework_Specs_TFM)</SpecFlow_Specs_TFM>
<SpecFlow_Specs_TFM>$(SpecFlow_Core_Specs_TFM)</SpecFlow_Specs_TFM>
<SpecFlow_Tools_TFM>$(SpecFlow_FullFramework_Tools_TFM);$(SpecFlow_Core_Tools_TFM)</SpecFlow_Tools_TFM>

<SpecFlow_EnableStrongNameSigning>true</SpecFlow_EnableStrongNameSigning>
Expand Down
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM mcr.microsoft.com/dotnet/core/sdk:3.0.101-buster

RUN apt update \
&& apt install -y git mono-complete \
&& dotnet tool install --global PowerShell

RUN wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb \
&& apt update \
&& apt install apt-transport-https -y \
&& apt update
RUN apt install dotnet-sdk-2.1 -y

# RUN git clone --recurse-submodules--single-branch --branch updateLinuxBuild -j8 https://github.com/techtalk/SpecFlow.git /src \
# && ls -la

WORKDIR /src

COPY . .

RUN git clean -fdx

# build project
# RUN pwsh /src/build.ps1

RUN pwsh /src/build.ps1

#CMD /bin/sh
# CMD dotnet test /src/*.sln -v n --no-build --logger "trx;LogFileName=TestResults.trx"
# CMD dotnet test ./Tests/TechTalk.SpecFlow.Specs/TechTalk.SpecFlow.Specs.csproj -v n --no-build --logger "trx;LogFileName=TestResults.trx" --filter "BasicScenarioExecutionFeature_MSTest"
# CMD dotnet test TechTalk.SpecFlow.sln -v n --no-build --logger "trx;LogFileName=TestResults.trx" --filter "BasicScenarioExecutionFeature_MSTest" && /bin/sh
CMD /bin/sh
2 changes: 1 addition & 1 deletion ExternalRepositories/SpecFlow.TestProjectGenerator
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using global::TechTalk.SpecFlow;

[TestClass]
internal class PROJECT_ROOT_NAMESPACE_MSTestAssemblyHooks
public class PROJECT_ROOT_NAMESPACE_MSTestAssemblyHooks
{
[AssemblyInitialize]
public static void AssemblyInitialize(TestContext testContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Imports System.Reflection


<TestClass>
Friend NotInheritable Class PROJECT_ROOT_NAMESPACE_MSTestAssemblyHooks
Public NotInheritable Class PROJECT_ROOT_NAMESPACE_MSTestAssemblyHooks
<AssemblyInitialize>
Public Shared Sub AssemblyInitialize(testContext As TestContext)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using global::TechTalk.SpecFlow;

[SetUpFixture]
internal class PROJECT_ROOT_NAMESPACE_NUnitAssemblyHooks
public class PROJECT_ROOT_NAMESPACE_NUnitAssemblyHooks
{
[OneTimeSetUp]
public void AssemblyInitialize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Imports System
Imports System.Reflection

<SetUpFixture>
Friend NotInheritable Class PROJECT_ROOT_NAMESPACE_NUnitAssemblyHooks
Public NotInheritable Class PROJECT_ROOT_NAMESPACE_NUnitAssemblyHooks
<OneTimeSetUp>
Public Shared Sub AssemblyInitialize()
Dim currentAssembly As Assembly = GetType(PROJECT_ROOT_NAMESPACE_NUnitAssemblyHooks).Assembly
Expand Down
50 changes: 50 additions & 0 deletions SpecFlow.Tools.MsBuild.Generation/AssemblyResolveLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using System.Reflection;

namespace SpecFlow.Tools.MsBuild.Generation
{
public sealed class AssemblyResolveLogger : IAssemblyResolveLogger
{
private readonly ITaskLoggingWrapper _taskLoggingWrapper;
private bool _isDisposed;

public AssemblyResolveLogger(ITaskLoggingWrapper taskLoggingWrapper)
{
_taskLoggingWrapper = taskLoggingWrapper;
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
}

~AssemblyResolveLogger()
{
Dispose(false);
}

public Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
_taskLoggingWrapper.LogMessage(args.Name);

return null;
}

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

private void Dispose(bool disposing)
{
if (_isDisposed)
{
return;
}

if (disposing)
{
AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
}

_isDisposed = true;
}
}
}
17 changes: 17 additions & 0 deletions SpecFlow.Tools.MsBuild.Generation/AssemblyResolveLoggerFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace SpecFlow.Tools.MsBuild.Generation
{
public class AssemblyResolveLoggerFactory : IAssemblyResolveLoggerFactory
{
private readonly ITaskLoggingWrapper _taskLoggingWrapper;

public AssemblyResolveLoggerFactory(ITaskLoggingWrapper taskLoggingWrapper)
{
_taskLoggingWrapper = taskLoggingWrapper;
}

public IAssemblyResolveLogger Build()
{
return new AssemblyResolveLogger(_taskLoggingWrapper);
}
}
}
32 changes: 32 additions & 0 deletions SpecFlow.Tools.MsBuild.Generation/ExceptionTaskLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.IO;

namespace SpecFlow.Tools.MsBuild.Generation
{
public class ExceptionTaskLogger : IExceptionTaskLogger
{
private readonly ITaskLoggingWrapper _taskLoggingWrapper;

public ExceptionTaskLogger(ITaskLoggingWrapper taskLoggingWrapper)
{
_taskLoggingWrapper = taskLoggingWrapper;
}

public void LogException(Exception exception)
{
if (exception.InnerException is FileLoadException fileLoadException)
{
_taskLoggingWrapper.LogError($"FileLoadException Filename: {fileLoadException.FileName}");
_taskLoggingWrapper.LogError($"FileLoadException FusionLog: {fileLoadException.FusionLog}");
_taskLoggingWrapper.LogError($"FileLoadException Message: {fileLoadException.Message}");
}

if (exception.InnerException is Exception innerException)
{
_taskLoggingWrapper.LogError(innerException.ToString());
}

_taskLoggingWrapper.LogError(exception.ToString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public FeatureFileCodeBehindGenerator(TaskLoggingHelper log, FeatureCodeBehindGe

public TaskLoggingHelper Log { get; }

public IEnumerable<string> GenerateFilesForProject(
List<string> featureFiles,
string projectFolder,
public IEnumerable<string> GenerateFilesForProject(
IReadOnlyCollection<string> featureFiles,
string projectFolder,
string outputPath)
{
var codeBehindWriter = new CodeBehindWriter(null);
Expand All @@ -33,7 +33,7 @@ public IEnumerable<string> GenerateFilesForProject(

foreach (var featureFile in featureFiles)
{
var featureFileItemSpec = featureFile;
string featureFileItemSpec = featureFile;
var generatorResult = _featureCodeBehindGenerator.GenerateCodeBehindFile(featureFileItemSpec);

if (!generatorResult.Success)
Expand All @@ -55,13 +55,13 @@ public IEnumerable<string> GenerateFilesForProject(
continue;
}

var targetFilePath = _filePathGenerator.GenerateFilePath(
string targetFilePath = _filePathGenerator.GenerateFilePath(
projectFolder,
outputPath,
featureFile,
generatorResult.Filename);

var resultedFile = codeBehindWriter.WriteCodeBehindFile(targetFilePath, featureFile, generatorResult);
string resultedFile = codeBehindWriter.WriteCodeBehindFile(targetFilePath, featureFile, generatorResult);

yield return FileSystemHelper.GetRelativePath(resultedFile, projectFolder);
}
Expand Down
Loading

0 comments on commit b6c4d72

Please sign in to comment.