Skip to content

Commit 04d35b8

Browse files
devhawkHarry
andauthored
Fix Tests (#36)
* add logs * fix log * For TestMSBuild tests, force debug build Co-authored-by: Harry <harrypierson@outlook.com>
1 parent b640686 commit 04d35b8

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ env:
99

1010
jobs:
1111
build:
12-
if: startsWith(github.ref, 'refs/heads/release/')
1312
runs-on: ubuntu-latest
1413
steps:
1514
- uses: actions/checkout@v2
@@ -36,6 +35,7 @@ jobs:
3635
name: packages
3736
path: ./out
3837
- name: Create Release
38+
if: startsWith(github.ref, 'refs/heads/release/')
3939
uses: marvinpinto/action-automatic-releases@v1.1.1
4040
with:
4141
repo_token: "${{ secrets.GITHUB_TOKEN }}"
@@ -45,10 +45,14 @@ jobs:
4545
files: |
4646
./out/*
4747
- name: Push to Nuget.org
48+
if: startsWith(github.ref, 'refs/heads/release/')
4849
run: dotnet nuget push ${{ format('./out/Neo.Assertions.{0}.nupkg', steps.nbgv.outputs.NuGetPackageVersion) }} --api-key ${{ secrets.NUGET_ORG_TOKEN }} --source https://api.nuget.org/v3/index.json
4950
- name: Push to Nuget.org
51+
if: startsWith(github.ref, 'refs/heads/release/')
5052
run: dotnet nuget push ${{ format('./out/Neo.BuildTasks.{0}.nupkg', steps.nbgv.outputs.NuGetPackageVersion) }} --api-key ${{ secrets.NUGET_ORG_TOKEN }} --source https://api.nuget.org/v3/index.json
5153
- name: Push to Nuget.org
54+
if: startsWith(github.ref, 'refs/heads/release/')
5255
run: dotnet nuget push ${{ format('./out/Neo.Test.Harness.{0}.nupkg', steps.nbgv.outputs.NuGetPackageVersion) }} --api-key ${{ secrets.NUGET_ORG_TOKEN }} --source https://api.nuget.org/v3/index.json
5356
- name: Push to Nuget.org
57+
if: startsWith(github.ref, 'refs/heads/release/')
5458
run: dotnet nuget push ${{ format('./out/Neo.Test.Runner.{0}.nupkg', steps.nbgv.outputs.NuGetPackageVersion) }} --api-key ${{ secrets.NUGET_ORG_TOKEN }} --source https://api.nuget.org/v3/index.json

test/test-build-tasks/Extensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.IO;
34
using System.Linq;
45
using Microsoft.Build.Utilities.ProjectCreation;
@@ -53,7 +54,8 @@ public static void RunThrow(this IProcessRunner @this, string command, string ar
5354

5455
public static ProjectCreator AssertBuild(this ProjectCreator @this, ITestOutputHelper? output = null)
5556
{
56-
@this.TryBuild(restore: true, out bool result, out BuildOutput buildOutput);
57+
var globalProperties = new Dictionary<string, string>() { ["Configuration"] = "Debug" };
58+
@this.TryBuild(restore: true, globalProperties, out bool result, out BuildOutput buildOutput);
5759
if (!result)
5860
{
5961
if (output != null)
@@ -77,7 +79,7 @@ public static ProjectCreator AssertBuild(this ProjectCreator @this, ITestOutputH
7779
public static ProjectCreator ImportNeoBuildTools(this ProjectCreator @this)
7880
{
7981
var buildTasksPath = typeof(NeoCsc).Assembly.Location;
80-
var testBuildAssmblyDirectory = Path.GetDirectoryName(typeof(TestBuild).Assembly.Location)
82+
var testBuildAssmblyDirectory = Path.GetDirectoryName(typeof(TestMSBuild).Assembly.Location)
8183
?? throw new Exception("Couldn't get directory name of TestBuild assembly");
8284
var targetsPath = Path.Combine(testBuildAssmblyDirectory, "build", "Neo.BuildTasks.targets");
8385

test/test-build-tasks/TestBuild.TestRootPath.cs renamed to test/test-build-tasks/TestMSBuild.TestRootPath.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace build_tasks
55
{
6-
public partial class TestBuild
6+
public partial class TestMSBuild
77
{
88
internal class TestRootPath : IDisposable
99
{
Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
namespace build_tasks
99
{
10-
public partial class TestBuild : MSBuildTestBase
10+
public partial class TestMSBuild : MSBuildTestBase
1111
{
1212
readonly ITestOutputHelper output;
1313

14-
public TestBuild(ITestOutputHelper output)
14+
public TestMSBuild(ITestOutputHelper output)
1515
{
1616
this.output = output;
1717
}
@@ -94,8 +94,7 @@ void test_NeoContractGeneration(string testRootPath, string manifest, string con
9494
.ItemInclude("NeoContractGeneration", "registrar", metadata: metadata)
9595
.AssertBuild(output);
9696

97-
var generatedCodePath = Path.Combine(testRootPath, "obj/Debug/net6.0/registrar.contract-interface.cs");
98-
Assert.True(File.Exists(generatedCodePath), "contract interface not generated");
97+
CheckGeneratedPath(testRootPath, "obj/Debug/net6.0/registrar.contract-interface.cs");
9998
}
10099

101100
[Fact]
@@ -140,8 +139,20 @@ void test_NeoContractReference(string testRootPath, string source, string contra
140139
.ItemInclude("NeoContractReference", srcCreator.FullPath, metadata: metadata)
141140
.AssertBuild(output);
142141

143-
var generatedCodePath = Path.Combine(testRootPath, "test/obj/Debug/net6.0/registrar.contract-interface.cs");
144-
Assert.True(File.Exists(generatedCodePath), "contract interface not generated");
142+
CheckGeneratedPath(testRootPath, "test/obj/Debug/net6.0/registrar.contract-interface.cs");
143+
}
144+
145+
void CheckGeneratedPath(string testRootPath, string relativeGeneratedPath)
146+
{
147+
var generatedCodePath = Path.Combine(testRootPath, relativeGeneratedPath);
148+
if (!File.Exists(generatedCodePath))
149+
{
150+
foreach (var file in Directory.EnumerateFiles(testRootPath, "", SearchOption.AllDirectories))
151+
{
152+
output.WriteLine(file);
153+
}
154+
throw new FileNotFoundException("contract interface not generated", generatedCodePath);
155+
}
145156
}
146157

147158
public static ProjectCreator CreateDotNetSixProject(string directory, string projectName = "project.csproj")

0 commit comments

Comments
 (0)