detect source file path without using env. (#257)

This commit is contained in:
Tingluo Huang
2020-01-06 12:56:15 -05:00
committed by GitHub
parent 06292aa118
commit abc65839f3
3 changed files with 11 additions and 7 deletions

View File

@@ -1,8 +1,7 @@
using GitHub.Runner.Common.Util;
using System.IO;
using System.IO;
using Xunit;
using System;
using GitHub.Runner.Sdk;
using System.Runtime.CompilerServices;
namespace GitHub.Runner.Common.Tests
{
@@ -21,9 +20,16 @@ namespace GitHub.Runner.Common.Tests
return projectDir;
}
public static string GetTestFilePath([CallerFilePath] string path = null)
{
return path;
}
public static string GetSrcPath()
{
string srcDir = Environment.GetEnvironmentVariable("GITHUB_RUNNER_SRC_DIR");
string L0dir = Path.GetDirectoryName(GetTestFilePath());
string testDir = Path.GetDirectoryName(L0dir);
string srcDir = Path.GetDirectoryName(testDir);
ArgUtil.Directory(srcDir, nameof(srcDir));
Assert.Equal(Src, Path.GetFileName(srcDir));
return srcDir;

View File

@@ -125,7 +125,7 @@ namespace GitHub.Runner.Common.Tests.Worker
Directory.CreateDirectory(Path.GetDirectoryName(watermarkFile));
File.WriteAllText(watermarkFile, DateTime.UtcNow.ToString());
Directory.CreateDirectory(Path.Combine(Path.GetDirectoryName(watermarkFile), "notexist"));
File.Copy(Path.Combine(Environment.GetEnvironmentVariable("GITHUB_RUNNER_SRC_DIR"), "Test", TestDataFolderName, "dockerfileaction.yml"), Path.Combine(Path.GetDirectoryName(watermarkFile), "notexist", "action.yml"));
File.Copy(Path.Combine(TestUtil.GetSrcPath(), "Test", TestDataFolderName, "dockerfileaction.yml"), Path.Combine(Path.GetDirectoryName(watermarkFile), "notexist", "action.yml"));
//Act
await _actionManager.PrepareActionsAsync(_ec.Object, actions);

View File

@@ -137,8 +137,6 @@ function runtest ()
ulimit -n 1024
fi
export GITHUB_RUNNER_SRC_DIR=${SCRIPT_DIR}
dotnet msbuild -t:test -p:PackageRuntime="${RUNTIME_ID}" -p:BUILDCONFIG="${BUILD_CONFIG}" -p:RunnerVersion="${RUNNER_VERSION}" ./dir.proj || failed "failed tests"
}