This repository was archived by the owner on Mar 28, 2026. It is now read-only.
forked from RoryDungan/Unity-CI-Example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunity-tests.ps1
More file actions
33 lines (27 loc) · 1.29 KB
/
Copy pathunity-tests.ps1
File metadata and controls
33 lines (27 loc) · 1.29 KB
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
# Set project source to the full path to the directory containing this script
$src = $PSScriptRoot
# Create temporary file for the Unity log.
# We need this because if multiple editor instances are open we can't rely on the contents of the default Editor.log
# containing output just from this instance.
$logfile = [System.IO.Path]::GetTempFileName()
# Path to Unity - change to match your install location
$unity = 'C:\Program Files\Unity\Hub\Editor\2018.3.7f1\Editor\Unity.exe'
Write-Host "Test run started:" (Get-Date).ToString()
$process = $null
try {
$unityArgs = "-nographics -batchmode -projectPath `"$src`" -logFile `"$logFile`" -runTests -testPlatform playmode"
$process = Start-Process -FilePath "$unity" -ArgumentList $unityArgs -PassThru
Wait-Process -Id $process.Id
# Write log output to standard output. TODO: Can we tail the file and output in real time as it's being written to?
Get-Content $logfile
}
finally {
# Kill Unity if this script was killed. This makes sure the build actually stops if we cancel the job in Jenkins.
if ($process -ne $null -And -Not $process.HasExited) {
Stop-Process $process.Id
}
# Remove temporary log file
Remove-Item $logfile
}
# Exit script with Unity exit code
Exit $process.ExitCode