Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve Dynamo test deps using samples approach #5

Merged
merged 5 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 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 @@ -30,7 +30,7 @@ jobs:
}
- 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
43 changes: 15 additions & 28 deletions IronPythonTests/IronPythonTests.csproj
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
<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" />
</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>
<None Update="TestServices.dll.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
</Project>

<Target Name="DownloadDynamoAndUnzip" BeforeTargets="Build">
<DownloadFile SourceUrl="https://dyn-builds-data.s3-us-west-2.amazonaws.com/DynamoCoreRuntime_3.1.0.3952_20240131T0007.zip" DestinationFolder="$(MSBuildProjectDirectory)" />
<Unzip SourceFiles="DynamoCoreRuntime_3.1.0.3952_20240131T0007.zip" DestinationFolder="$(OutputPath)\" OverwriteReadOnlyFiles="true" />
</Target>
</Project>
90 changes: 69 additions & 21 deletions IronPythonTests/Setup.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,85 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Globalization;
using System.IO;
using System.Reflection;
using Dynamo.Utilities;
using NUnit.Framework;

namespace IronPythonTests

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

[OneTimeSetUp]
public void RunBeforeAllTests()
{
private AssemblyHelper assemblyHelper;
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}");
}

[OneTimeSetUp]
public void RunBeforeAllTests()
resolutionPaths = new List<string>
{
var assemblyPath = Assembly.GetExecutingAssembly().Location;
var moduleRootFolder = Path.GetDirectoryName(assemblyPath);
// Search for nodes
Path.Combine(moduleRootFolder, "nodes"),
Path.Combine(moduleRootFolder, "en-us")
};
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; ;
}

var resolutionPaths = new[]
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))
{
// These tests need "CoreNodeModelsWpf.dll" under "nodes" folder.
Path.Combine(moduleRootFolder, "nodes")
};
return Assembly.LoadFrom(assemblyPath);
}

assemblyHelper = new AssemblyHelper(moduleRootFolder, resolutionPaths);
AppDomain.CurrentDomain.AssemblyResolve += assemblyHelper.ResolveAssembly;
}
// Then check all additional resolution paths
foreach (var resolutionPath in resolutionPaths)
{
assemblyPath = Path.Combine(resolutionPath, targetAssemblyName);
if (File.Exists(assemblyPath))
{
return Assembly.LoadFrom(assemblyPath);
}
}

[OneTimeTearDown]
public void RunAfterAllTests()
return null;
}
catch (Exception ex)
{
AppDomain.CurrentDomain.AssemblyResolve -= assemblyHelper.ResolveAssembly;
assemblyHelper = null;
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;
}
}
7 changes: 7 additions & 0 deletions IronPythonTests/TestServices.dll.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="DynamoBasePath" value="."/>
<add key="RequestedLibraryVersion2" value=""/>
</appSettings>
</configuration>
Binary file removed extern/DSCoreNodes.dll
Binary file not shown.
Binary file removed extern/FFITarget.dll
Binary file not shown.
Loading