-
Notifications
You must be signed in to change notification settings - Fork 0
/
execute_TestRunner.ps1
74 lines (56 loc) · 2.27 KB
/
execute_TestRunner.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<#
.SYNOPSIS
This script executes a command to run a test runner for a Farming Simulator 22 mod.
.DESCRIPTION
The script executes the TestRunner_public.exe command with the specified mod folder path, game path, and output path.
.PARAMETER modFolderPath
Specifies the path to the mod folder.
.NOTES
File Name : execute_TestRunner.ps1
Author : Miguel Pacheco
Prerequisite : PowerShell 3.0 or later
License : MIT
#>
param (
[string]$modFolderPath
)
# Define the path where the TestRunner is installed (Mandatory)
$testRunnerPath = ""
# Define the path where Farming Simulator is installed (Mandatory)
$gamePath = ""
# Define the base output folder (Mandatory)
$outputBasePath = ""
# Define the Giants Editor Path (Mandatory)
$giantsEditorPath = ""
# Check if the mod folder path is provided
if (-not $modFolderPath) {
Write-Host "Please provide the path to the mod folder."
exit
}
# Extract the mod name from the provided mod folder path
$modName = $modFolderPath | Split-Path -Leaf
# Create the mod-specific output folder
$modOutputFolderPath = Join-Path -Path $outputBasePath -ChildPath $modName
# Check if the mod-specific output folder exists; if not, create it
if (-not (Test-Path -Path $modOutputFolderPath -PathType Container)) {
New-Item -Path $modOutputFolderPath -ItemType Directory | Out-Null
}
# Generate a timestamp for the current run
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
# Create a new run folder with a unique run number and timestamp
$counter = 1
do {
$runFolderPath = Join-Path -Path $modOutputFolderPath -ChildPath "Test_${counter}_$timestamp"
$counter++
} while (Test-Path -Path $runFolderPath -PathType Container)
# Create the run folder
New-Item -Path $runFolderPath -ItemType Directory | Out-Null
# Display information about the paths being used
Write-Host "Loading Giants TestRunner located on: $testRunnerPath"
Write-Host "Using GamePath: $gamePath"
Write-Host "Mod Folder: $modFolderPath"
Write-Host "Output Path: $runFolderPath"
# Build the command to execute the test runner
$command = "$testRunnerPath $modFolderPath -e '$giantsEditorPath' -g '$gamePath' --outputPath $runFolderPath"
# Execute the command
Invoke-Expression -Command $command