Skip to content

Commit

Permalink
resolve tests using samples approach
Browse files Browse the repository at this point in the history
add tests to build workflow
  • Loading branch information
mjkkirschner committed Jan 30, 2024
1 parent c0caa15 commit 3bbddbd
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 79 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
uses: actions/checkout@v4
with:
path: DSIronPython
repository: DynamoDS/DSIronPython
ref: ${{ github.ref }}
- name: Setup nuget
uses: nuget/[email protected]
- name: Setup msbuild
Expand All @@ -28,9 +28,17 @@ jobs:
} else {
Write-Error "python node dll was not found!"
}
- name: Get DynamoRuntime from s3
run: |
curl -o DynamoRuntime.zip https://dyn-builds-data.s3-us-west-2.amazonaws.com/DynamoCoreRuntime3.0.2.zip
ls
- name: Extract DynamoRuntime
run: |
7z x DynamoRuntime.zip -o${{ github.workspace }}\DSIronPython\IronPythonTests\bin\Release\DynamoRuntime
- name: Run test with the dotnet CLI
run: |
dotnet test ${{ github.workspace }}\DSIronPython --logger "trx;LogFileName=results.trx" --results-directory ${{ github.workspace }}\DSIronPython\TestResults
dotnet test ${{ github.workspace }}\DSIronPython -p:Configuration=Release --filter "TestCategory!=Failure" --logger "trx;LogFileName=results.trx" --results-directory ${{ github.workspace }}\DSIronPython\TestResults
- name: Upload build artifact
uses: actions/[email protected]
with:
Expand Down
13 changes: 6 additions & 7 deletions DSIronPython/DSIronPython.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
</ImportGroup>
<PropertyGroup>
<OutputPath>$(SolutionDir)\package_output\DSIronPython\extra\</OutputPath>
<ProjectGuid>{9EEF4F42-6B3B-4358-9A8A-C2701539A822}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DSIronPython</RootNamespace>
<AssemblyName>DSIronPython</AssemblyName>
<TargetFramework>net6.0</TargetFramework>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<TargetFramework>net8.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DynamoVisualProgramming.Core" Version="3.0.0-beta7023">
<IncludeAssets></IncludeAssets>

<PackageReference Include="DynamoVisualProgramming.Core" Version="3.1.0-beta3940">
<ExcludeAssets>runtime</ExcludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>

<PackageReference Include="IronPython" Version="2.7.12" />
<PackageReference Include="IronPython.StdLib" Version="2.7.12" />

Expand All @@ -30,6 +29,6 @@
</ItemGroup>

<Target Name="copypkgjson" AfterTargets="Build">
<Copy SourceFiles="pkg.json" DestinationFolder="$(OutputPath)..\"/>
<Copy SourceFiles="pkg.json" DestinationFolder="$(OutputPath)..\" />
</Target>
</Project>
2 changes: 1 addition & 1 deletion DSironPythonEmpty/DSIronPythonEmpty.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</ImportGroup>
<PropertyGroup>
<OutputPath>$(SolutionDir)\package_output\DSIronPython\bin\</OutputPath>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
5 changes: 2 additions & 3 deletions IronPythonExtension/IronPythonExtension.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
</ImportGroup>
<PropertyGroup>
<OutputPath>$(SolutionDir)\package_output\DSIronPython\extra\</OutputPath>
<ProjectGuid>{182FCA4E-B6EF-451F-9EC4-7BF2C622F4F7}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>IronPythonExtension</RootNamespace>
<AssemblyName>IronPythonExtension</AssemblyName>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Content Include="IronPythonExtension_ExtensionDefinition.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="DynamoVisualProgramming.Core" Version="3.0.0-beta7023" />
<PackageReference Include="DynamoVisualProgramming.Core" Version="3.0.2.7476" />
</ItemGroup>
<Target Name="AfterBuildOps" AfterTargets="Build">
<ItemGroup>
Expand Down
37 changes: 8 additions & 29 deletions IronPythonTests/IronPythonTests.csproj
Original file line number Diff line number Diff line change
@@ -1,38 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<ImportGroup Label="PropertySheets">
<Import Project="$(SolutionDir)Config\shared.props" />
</ImportGroup>
<PropertyGroup>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E6DF2FBD-7D4D-4465-94DC-D576D737E985}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>IronPythonTests</RootNamespace>
<AssemblyName>IronPythonTests</AssemblyName>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<TargetFramework>net8.0</TargetFramework>
<IsTestProject>true</IsTestProject>
<IsPackable>false</IsPackable>

</PropertyGroup>
<ItemGroup>
<PackageReference Include="DynamoVisualProgramming.LibG_230_0_0" Version="3.0.0.3171" />
<PackageReference Include="DynamoVisualProgramming.Tests" Version="3.0.0-beta7023" />
<PackageReference Include="IronPython" Version="2.7.12" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="DynamoVisualProgramming.Tests" Version="3.1.0-beta3940"></PackageReference>
<PackageReference Include="IronPython" Version="2.7.12" />
<PackageReference Include="DynamoVisualProgramming.Core" Version="3.1.0-beta3940">
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DSIronPython\DSIronPython.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="DSCoreNodes">
<HintPath>..\extern\DSCoreNodes.dll</HintPath>
</Reference>
<Reference Include="FFITarget">
<HintPath>..\extern\FFITarget.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
</Project>
37 changes: 0 additions & 37 deletions IronPythonTests/Setup.cs

This file was deleted.

85 changes: 85 additions & 0 deletions IronPythonTests/Setups.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Globalization;
using System.IO;
using System.Reflection;
using NUnit.Framework;


[SetUpFixture]
public class Setup
{
private string moduleRootFolder;
List<string> resolutionPaths;

[OneTimeSetUp]
public void RunBeforeAllTests()
{
var thisDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var configPath = Path.Combine(thisDir, "TestServices.dll.config");

// Adjust the config file map because the config file
// might not always be in the same directory as the dll.
var map = new ExeConfigurationFileMap { ExeConfigFilename = configPath };
var config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);

var element = config.AppSettings.Settings["DynamoBasePath"];
moduleRootFolder = element?.Value ?? string.Empty;

if (string.IsNullOrEmpty(moduleRootFolder))
{
throw new Exception($"Missing DynamoBasePath in TestServices.dll.config. Please set the DynamoBasePath to a valid Dynamo bin folder. DynamoBasePath is set to {moduleRootFolder}");
}
else if (!File.Exists(Path.Combine(moduleRootFolder, "DynamoCore.dll")))
{
throw new Exception($"Invalid DynamoBasePath in TestServices.dll.config. Please set the DynamoBasePath to a valid Dynamo bin folder. DynamoBasePath is set to {moduleRootFolder}");
}

resolutionPaths = new List<string>
{
// Search for nodes
Path.Combine(moduleRootFolder, "nodes"),
Path.Combine(moduleRootFolder, "en-us")
};
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; ;
}

private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
try
{
var targetAssemblyName = new AssemblyName(args.Name).Name + ".dll";

// First check the core path
string assemblyPath = Path.Combine(moduleRootFolder, targetAssemblyName);
if (File.Exists(assemblyPath))
{
return Assembly.LoadFrom(assemblyPath);
}

// Then check all additional resolution paths
foreach (var resolutionPath in resolutionPaths)
{
assemblyPath = Path.Combine(resolutionPath, targetAssemblyName);
if (File.Exists(assemblyPath))
{
return Assembly.LoadFrom(assemblyPath);
}
}

return null;
}
catch (Exception ex)
{
throw new Exception(string.Format("There location of the assembly, " +
"{0} could not be resolved for loading.", args.Name), ex);
}
}

[OneTimeTearDown]
public void RunAfterAllTests()
{
AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
}
}
Binary file removed extern/DSCoreNodes.dll
Binary file not shown.
Binary file removed extern/FFITarget.dll
Binary file not shown.

0 comments on commit 3bbddbd

Please sign in to comment.