mirror of
https://github.com/actions/runner.git
synced 2025-12-10 12:36:23 +00:00
detect source file path without using env. (#257)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user