Skip to content
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
31 changes: 29 additions & 2 deletions VinTest.Cake/ContextBase.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Xml.Linq;
using Cake.Common;
using Cake.Core;
Expand Down Expand Up @@ -85,6 +86,17 @@ public abstract class ContextBase : FrostingContext
/// </summary>
public string PidFilePath => Path.Combine(DataPath, TestResultsDirName, "vs.pid");

/// <summary>
/// Absolute path to VS executable (Vintagestory.exe on Windows, Vintagestory on Linux).
/// </summary>
public string VsExePath =>
Path.Combine(
VsPath,
RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? "Vintagestory.exe"
: "Vintagestory"
);

/// <inheritdoc/>
protected ContextBase(ICakeContext context)
: base(context)
Expand All @@ -110,8 +122,23 @@ protected ContextBase(ICakeContext context)
+ " or set VINTAGE_STORY environment variable."
);
VsPath = Path.GetFullPath(vspathCandidate);
if (!File.Exists(Path.Combine(VsPath, "VintageStory.exe")))
throw new CakeException($"Vintage Story executable not found in {VsPath}");

// Check if VintagestoryAPI.dll exists
string dllPath = Path.Combine(VsPath, "VintagestoryAPI.dll");
if (!File.Exists(dllPath))
throw new CakeException(
$"{VsPath} does not look like a valid Vintage Story installation"
+ " (missing VintagestoryAPI.dll)."
);

if (!File.Exists(VsExePath))
{
Log.Warning(
$"WARNING: Vintage Story executable '{VsExePath}' not found."
+ "\nCake Will not be able to run tests!"
);
Log.Information("This is OK in CI environments building against a vs_server.tar.gz");
}
DataPath = Path.GetFullPath(context.Argument("data-path", "../gamedata"));
TestWorldName = context.Argument("test-world", "autotest");
TestRunTimeoutSeconds = context.Argument("test-timeout", 300);
Expand Down
6 changes: 3 additions & 3 deletions VinTest.Cake/GameTestsTaskBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,13 @@ .. LogSuppressions.Select(s =>
/// </summary>
public sealed override void Run(TContext context)
{
var vsExe = Path.Combine(context.VsPath, "VintageStory.exe");

Cleanup(context);
WriteVintestConfig(context);
Prepare(context);
Build(context);
var proc = LaunchVintageStory(
context,
vsExe,
context.VsExePath,
GetModBinaryPaths(context),
GetAssetsPaths(context)
);
Expand Down Expand Up @@ -251,6 +249,8 @@ private static Process LaunchVintageStory(
IEnumerable<string> assetsPaths
)
{
if (!File.Exists(vsExe))
throw new CakeException($"Vintage Story executable does not exist: {vsExe}");
if (!modPaths.Any())
throw new CakeException("No valid mod paths provided");
var mods = ValidatePaths(modPaths, "MOD");
Expand Down