Skip to content

Commit c874317

Browse files
committed
Add debug output
1 parent d7dfc4f commit c874317

2 files changed

Lines changed: 48 additions & 2 deletions

File tree

constructor/briefcase/run_installation.bat

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,29 @@ echo {{ message }}
1717

1818
{% macro install_env(env) %}
1919
{{ tee("Setting up " ~ env.name ~ " environment...") }}
20+
{{ tee("DEBUG: env.prefix=" ~ env.prefix) }}
21+
{{ tee("DEBUG: env.shortcuts=" ~ env.shortcuts) }}
2022
set "CONDA_CHANNELS={{ env.channels }}"
2123
if "%OPTION_ENABLE_SHORTCUTS%"=="1" (
2224
"%CONDA_EXE%" install --offline -yp "{{ env.prefix }}" --file "{{ env.lockfile }}" {{ env.shortcuts }} {{ no_rcs_arg }} --log-file "%LOG%"
2325
) else (
2426
"%CONDA_EXE%" install --offline -yp "{{ env.prefix }}" --file "{{ env.lockfile }}" --no-shortcuts {{ no_rcs_arg }} --log-file "%LOG%"
2527
)
26-
if errorlevel 1 ( exit /b %errorlevel% )
28+
set "INSTALL_ERRORLEVEL=%errorlevel%"
29+
if %INSTALL_ERRORLEVEL% neq 0 ( exit /b %INSTALL_ERRORLEVEL% )
30+
rem Debug: Check Menu JSON files for $schema to determine new-style vs legacy
31+
if exist "{{ env.prefix }}\Menu\*.json" (
32+
for %%F in ("{{ env.prefix }}\Menu\*.json") do (
33+
findstr /C:"$schema" "%%F" >nul 2>&1
34+
if errorlevel 1 (
35+
echo DEBUG: %%~nxF uses LEGACY menuinst (no $schema) - checks .nonadmin
36+
>> "%LOG%" echo DEBUG: %%~nxF uses LEGACY menuinst (no $schema) - checks .nonadmin
37+
) else (
38+
echo DEBUG: %%~nxF uses NEW menuinst (has $schema) - elevate_as_needed decorator
39+
>> "%LOG%" echo DEBUG: %%~nxF uses NEW menuinst (has $schema) - elevate_as_needed decorator
40+
)
41+
)
42+
)
2743
{% endmacro %}
2844

2945
rem Assign INSTDIR and normalize the path
@@ -111,10 +127,21 @@ if errorlevel 1 ( exit /b %errorlevel% )
111127

112128
rem Create .nonadmin marker file for user-scoped installs inside BASE_PATH.
113129
rem This is used by the uninstaller (and menuinst) to determine the install mode.
130+
echo DEBUG: ALLUSERS=%ALLUSERS%
131+
>> "%LOG%" echo DEBUG: ALLUSERS=%ALLUSERS%
114132
if "%ALLUSERS%"=="0" (
133+
echo DEBUG: Creating .nonadmin marker file
134+
>> "%LOG%" echo DEBUG: Creating .nonadmin marker file
115135
echo. > "%BASE_PATH%\.nonadmin"
116136
if errorlevel 1 ( exit /b %errorlevel% )
117137
)
138+
if exist "%BASE_PATH%\.nonadmin" (
139+
echo DEBUG: .nonadmin file EXISTS at %BASE_PATH%\.nonadmin
140+
>> "%LOG%" echo DEBUG: .nonadmin file EXISTS at %BASE_PATH%\.nonadmin
141+
) else (
142+
echo DEBUG: .nonadmin file DOES NOT EXIST
143+
>> "%LOG%" echo DEBUG: .nonadmin file DOES NOT EXIST
144+
)
118145

119146
rem Install packages for each environment
120147
{%- for env in setup_envs %}

tests/test_examples.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,20 @@ def _read_briefcase_log_tail(path: Path, last_digits: int) -> str:
380380
return text[last_digits:]
381381

382382

383+
def _read_install_log(path: Path) -> str:
384+
"""Read install.log with proper encoding handling.
385+
Windows batch file >> redirection creates UTF-16 files.
386+
"""
387+
if not path or not path.exists():
388+
return f"(log not found: {path})"
389+
390+
# Try UTF-16 first (Windows batch >> redirection), fallback to UTF-8
391+
try:
392+
return path.read_text(encoding="utf-16", errors="replace")
393+
except UnicodeError:
394+
return path.read_text(encoding="utf-8", errors="replace")
395+
396+
383397
@dataclass
384398
class InstallationFailure(RuntimeError):
385399
cmd: list[str]
@@ -1007,13 +1021,18 @@ def test_example_shortcuts(tmp_path, request):
10071021
break
10081022
else:
10091023
# Debug: list what's actually in the Start Menu
1024+
print(f"\n=== Shortcut check failed for {installer.name} ===")
10101025
for key in ("ProgramData", "AppData"):
10111026
start_menu = Path(os.environ[key]) / "Microsoft/Windows/Start Menu/Programs"
10121027
if start_menu.exists():
10131028
print(f"{key} Start Menu contents: {list(start_menu.iterdir())}")
10141029
else:
10151030
print(f"{key} Start Menu path does not exist: {start_menu}")
1016-
raise AssertionError("No shortcuts found!")
1031+
# Print install.log if available
1032+
install_log = install_dir / "install.log"
1033+
print(f"\n=== install.log from {install_dir} ===")
1034+
print(_read_install_log(install_log))
1035+
raise AssertionError(f"No shortcuts found for {installer.name}!")
10171036
if installer.suffix == ".msi":
10181037
_run_uninstaller_msi(installer, install_dir)
10191038
else:

0 commit comments

Comments
 (0)