Debian Codegraph @

windows/run-psexec-nonadmin-tests.bat

raw
1 @echo off
2 REM CI wrapper: create a non-admin user, run tests via PsExec, print log.
3 setlocal
4 cd /d "%~dp0.."
5 set "REPO=%CD%"
6 set "BB_TEST_USER=BleachBitTest"
7 set "BB_TEST_PASS=Not-Real-Password_CiTest_9Xv4_73Qa"
8 set "LOG=%REPO%\psexec_nonadmin_tests.log"
9 if exist "%LOG%" del /q "%LOG%"
10 if exist "%REPO%\.coverage.nonadmin" del /q "%REPO%\.coverage.nonadmin"
11
12 net user %BB_TEST_USER% /delete /y >nul 2>&1
13 net user %BB_TEST_USER% %BB_TEST_PASS% /add /y
14 if errorlevel 1 (
15 echo ERROR: Failed to create test user %BB_TEST_USER%
16 exit /b 1
17 )
18
19 icacls "%REPO%" /grant "%BB_TEST_USER%:(OI)(CI)M" /T >nul
20 if errorlevel 1 (
21 echo ERROR: Failed to grant write access on %REPO%
22 exit /b 1
23 )
24
25 if not defined PYTHON_EXE (
26 echo ERROR: PYTHON_EXE is not set
27 exit /b 1
28 )
29
30 REM PsExec -u does not inherit the build agent's environment. Write a small
31 REM launcher to avoid fragile nested quoting in cmd /c.
32 set "LAUNCH=%REPO%\windows\psexec-nonadmin-launch.bat"
33 (
34 echo @echo off
35 echo set "PYTHON_EXE=%PYTHON_EXE%"
36 echo set "PYTHON_HOME=%PYTHON_HOME%"
37 echo set "DESTRUCTIVE_TESTS=T"
38 echo set "PYTHONWARNINGS=error"
39 echo set "GITHUB_ACTIONS=true"
40 echo call "%REPO%\windows\psexec-nonadmin-tests.bat"
41 ) > "%LAUNCH%"
42
43 psexec.exe -accepteula -i -u %BB_TEST_USER% -p %BB_TEST_PASS% -w "%REPO%" cmd /c "%LAUNCH%"
44 set EXITCODE=%ERRORLEVEL%
45
46 net user %BB_TEST_USER% /delete /y >nul 2>&1
47
48 echo.
49 echo === psexec non-admin exit code: %EXITCODE% ===
50 if exist "%LOG%" (
51 echo === psexec non-admin test log ===
52 type "%LOG%"
53 ) else (
54 echo Log not found: %LOG%
55 if exist "%LAUNCH%" (
56 echo Launcher still present - PsExec may not have started the inner script.
57 type "%LAUNCH%"
58 )
59 )
60
61 if exist "%LAUNCH%" del /q "%LAUNCH%"
62
63 exit /b %EXITCODE%