Skip to content

Commit

Permalink
Merge pull request #1 from Miguel22247/feat/fs-25-support-and-misc-im…
Browse files Browse the repository at this point in the history
…provements

feat: Improve output sorting and update comments
  • Loading branch information
Miguel22247 authored Nov 21, 2024
2 parents 48bceb5 + 526f574 commit d2625c7
Showing 1 changed file with 45 additions and 34 deletions.
79 changes: 45 additions & 34 deletions execute_TestRunner.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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 and game path and outputPath.
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.
Expand All @@ -13,51 +13,62 @@ 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 = "D:\testingmods\TestRunner_public.exe"
# Define the path where the TestRunner is installed (Mandatory)
$testRunnerPath = ""

# Define the path where Farming Simulator 22 is installed (optional)
$gamePath = "D:\SteamLibrary\steamapps\common\Farming Simulator 22"
# Define the path where Farming Simulator is installed (Mandatory)
$gamePath = ""

# Define the base output folder (optional I think)
$outputBasePath = "D:\testingmods\testRunnerOutput"
# Define the base output folder (Mandatory)
$outputBasePath = ""

# Define the Giants Editor Path (optional)
$giantsEditorPath = "D:\GIANTS_Editor_9.0.6_64-bit\editor.exe"
# 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
} else {
# Create the output folder path
$outputFolderPath = Join-Path -Path $outputBasePath -ChildPath "$(($modFolderPath | Split-Path -Leaf) + '_Output')"

# Check if the output folder already exists, if not, create it
if (-not (Test-Path -Path $outputFolderPath -PathType Container)) {
New-Item -Path $outputFolderPath -ItemType Directory | Out-Null
} else {
# If the output folder exists, append a number to avoid conflicts
$counter = 1
while (Test-Path -Path $outputFolderPath -PathType Container) {
$outputFolderPath = Join-Path -Path $outputBasePath -ChildPath "$(($modFolderPath | Split-Path -Leaf) + '_Output_' + $counter)"
$counter++
}
New-Item -Path $outputFolderPath -ItemType Directory | Out-Null
}

Write-Host "Loading Giants TestRunner located on: $testRunnerPath, with GamePath: $gamePath, and output: $outputFolderPath for mod: $modFolderPath"

# Build the command
$command = "$testRunnerPath $modFolderPath -e '$giantsEditorPath' -g '$gamePath' --outputPath $outputFolderPath"

# Execute the command
Invoke-Expression -Command $command
}

# 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

0 comments on commit d2625c7

Please sign in to comment.