Skip to content

Commit 94b0438

Browse files
test: fix build executable name mismatch
1 parent e8c2842 commit 94b0438

File tree

3 files changed

+46
-22
lines changed

3 files changed

+46
-22
lines changed

sample/Assets/Editor/WindowsBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
public class WindowsBuilder
1010
{
11-
private const string DefaultBuildPath = "Builds/Windows64/SampleApp.exe";
11+
private static readonly string DefaultBuildPath = $"Builds/Windows64/{Application.productName}.exe";
1212

1313
static void Build()
1414
{

sample/Tests/test/test_windows_helpers.py

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
2-
import sys
2+
import re
33
import subprocess
4+
import sys
45
import time
56
from pathlib import Path
67

@@ -18,6 +19,26 @@
1819
# Add chrome.exe to environment variable
1920
# Download chrome driver and add to environment variable
2021

22+
def get_product_name():
23+
"""Get the product name from ProjectSettings.asset"""
24+
project_settings_path = Path(__file__).resolve().parent.parent.parent / 'ProjectSettings' / 'ProjectSettings.asset'
25+
26+
if not project_settings_path.exists():
27+
print(f"Warning: ProjectSettings.asset not found at {project_settings_path}")
28+
return "SampleApp" # Fallback to default
29+
30+
with open(project_settings_path, 'r') as f:
31+
content = f.read()
32+
33+
# Extract productName using regex
34+
match = re.search(r'productName: (.+)', content)
35+
if match:
36+
product_name = match.group(1).strip()
37+
return product_name
38+
39+
# If regex fails, return default
40+
return "SampleApp"
41+
2142
def login():
2243
print("Connect to Chrome")
2344
# Set up Chrome options to connect to the existing Chrome instance
@@ -80,37 +101,40 @@ def login():
80101
driver.quit()
81102

82103
def open_sample_app():
83-
print("Opening Unity sample app...")
84-
subprocess.Popen(["SampleApp.exe"], shell=True)
104+
product_name = get_product_name()
105+
print(f"Opening {product_name}...")
106+
subprocess.Popen([f"{product_name}.exe"], shell=True)
85107
time.sleep(10)
86-
print("Unity sample app opened successfully.")
108+
print(f"{product_name} opened successfully.")
87109

88110
def stop_sample_app():
89-
print("Stopping sample app...")
90-
powershell_command = """
91-
$process = Get-Process -Name "SampleApp" -ErrorAction SilentlyContinue
92-
if ($process) {
111+
product_name = get_product_name()
112+
print(f"Stopping {product_name}...")
113+
powershell_command = f"""
114+
$process = Get-Process -Name "{product_name}" -ErrorAction SilentlyContinue
115+
if ($process) {{
93116
Stop-Process -Id $process.Id
94-
Write-Output "SampleApp.exe has been closed."
95-
} else {
96-
Write-Output "SampleApp.exe is not running."
97-
}
117+
Write-Output "{product_name}.exe has been closed."
118+
}} else {{
119+
Write-Output "{product_name}.exe is not running."
120+
}}
98121
"""
99122
subprocess.run(["powershell.exe", "-Command", powershell_command], check=True)
100123
time.sleep(5)
101-
print("Stopped sample app.")
124+
print(f"{product_name} stopped successfully.")
102125

103126
def bring_sample_app_to_foreground():
127+
product_name = get_product_name()
104128
powershell_script_path = "./switch-app.ps1"
105-
106-
print("Bring Unity sample app to the foreground.")
107-
129+
130+
print(f"Bring {product_name} to the foreground.")
131+
108132
command = [
109-
"powershell.exe",
110-
"-Command",
111-
f"Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process; & '{powershell_script_path}' -appName 'Immutable Sample'"
133+
"powershell.exe",
134+
"-Command",
135+
f"Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process; & '{powershell_script_path}' -appName '{product_name}'"
112136
]
113-
137+
114138
subprocess.run(command, check=True)
115139
time.sleep(10)
116140

src/Packages/Passport/Runtime/Scripts/Private/Helpers/WindowsDeepLink.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ private static string GetGameExecutablePath(string suffix)
261261
return Path.Combine(Application.persistentDataPath, exeName).Replace("/", "\\");
262262
#else
263263
// Returns game root directory in build
264-
var exePath = Application.dataPath.Replace("/Data", "").Replace($"/{Application.productName}_Data", "");
264+
var exePath = Path.Combine(Application.dataPath, "../");
265265
return Path.Combine(exePath, exeName).Replace("/", "\\");
266266
#endif
267267
}

0 commit comments

Comments
 (0)