mirror of
https://github.com/actions/runner.git
synced 2025-12-11 21:06:55 +00:00
GitHub Actions Runner
This commit is contained in:
39
src/Test/L0/TestUtil.cs
Normal file
39
src/Test/L0/TestUtil.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using GitHub.Runner.Common.Util;
|
||||
using System.IO;
|
||||
using Xunit;
|
||||
using System;
|
||||
using GitHub.Runner.Sdk;
|
||||
|
||||
namespace GitHub.Runner.Common.Tests
|
||||
{
|
||||
public static class TestUtil
|
||||
{
|
||||
private const string Src = "src";
|
||||
private const string TestData = "TestData";
|
||||
|
||||
public static string GetProjectPath(string name = "Test")
|
||||
{
|
||||
ArgUtil.NotNullOrEmpty(name, nameof(name));
|
||||
string projectDir = Path.Combine(
|
||||
GetSrcPath(),
|
||||
name);
|
||||
Assert.True(Directory.Exists(projectDir));
|
||||
return projectDir;
|
||||
}
|
||||
|
||||
public static string GetSrcPath()
|
||||
{
|
||||
string srcDir = Environment.GetEnvironmentVariable("GITHUB_RUNNER_SRC_DIR");
|
||||
ArgUtil.Directory(srcDir, nameof(srcDir));
|
||||
Assert.Equal(Src, Path.GetFileName(srcDir));
|
||||
return srcDir;
|
||||
}
|
||||
|
||||
public static string GetTestDataPath()
|
||||
{
|
||||
string testDataDir = Path.Combine(GetProjectPath(), TestData);
|
||||
Assert.True(Directory.Exists(testDataDir));
|
||||
return testDataDir;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user