我有一个github操作,它想要测试是否已经创建了特定的路径,但我遇到了一个问题,其中github
USERNAME=runneradmin
TMP=C:\Users\RUNNER~1\AppData\Local\Temp测试脚本(由activate.bat脚本设置VIRTUAL_ENV):
echo on
set "WORKON_HOME=%TMP%\wo home %RANDOM%"
mkdir "%WORKON_HOME%"
cd /d "%WORKON_HOME%"
virtualenv "name with spaces"
cd "name with spaces"
call Scripts\activate.bat
if "%WORKON_HOME%\name with spaces"=="%VIRTUAL_ENV%" (
echo workon home and virtualenv are equal
) else (
echo. "%WORKON_HOME%\name with spaces" is not equal to "%VIRTUAL_ENV%"
)
if "%CD%"=="%VIRTUAL_ENV%" (
echo cd and virtualenv are equal
) else (
echo. "%CD%" is not equal to "%VIRTUAL_ENV%"
)
exit /b 1输出结果是(区别是RUNNER~1和runneradmin):
"C:\Users\RUNNER~1\AppData\Local\Temp\wo home 14549\name with spaces" is not equal to "C:\Users\runneradmin\AppData\Local\Temp\wo home 14549\name with spaces"
"C:\Users\RUNNER~1\AppData\Local\Temp\wo home 14549\name with spaces" is not equal to "C:\Users\runneradmin\AppData\Local\Temp\wo home 14549\name with spaces"动作yaml表示完整性:
name: BUG
on: [ push, pull_request, workflow_dispatch ]
jobs:
ci-test:
name: BUG
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- run: pip install virtualenv
- shell: cmd
run: set
- name: Run tests
shell: cmd
run: |
tests\bug.bat如何才能使路径比较相等?
发布于 2021-10-16 13:58:25
我使用子例程和%~s1魔术字符串找到了答案,以获得8.3版本的文件名:
echo on
set "WORKON_HOME=%TMP%\wo home %RANDOM%"
mkdir "%WORKON_HOME%"
cd /d "%WORKON_HOME%"
virtualenv "name with spaces"
cd "name with spaces"
call Scripts\activate.bat
call:shorten "%WORKON_HOME%\name with spaces",WO
call:shorten "%VIRTUAL_ENV%",VE
if "%WO%"=="%VE%" (
echo workon home and virtualenv are equal
) else (
echo. "%WORKON_HOME%\name with spaces" is not equal to "%VIRTUAL_ENV%"
)
goto:eof
:shorten
for %%T in ("%~s1") do set "%~2=%%T"
exit /b 0https://stackoverflow.com/questions/69575175
复制相似问题