theme: improve tests #685

by
- removing duplicate code
- make it runnable from foreign Hugo project repos
This commit is contained in:
Sören Weber 2023-10-13 22:30:30 +02:00
parent c2a71738e0
commit b0c3f96b29
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
4 changed files with 35 additions and 39 deletions

31
exampleSite/test-hugo.bat Normal file
View file

@ -0,0 +1,31 @@
@echo off
setlocal enabledelayedexpansion
set hugo_prefix=
set hugo_version=
if not "%~1"=="" (
set hugo_prefix=.hugo
set hugo_version=.%1
)
set "versionFile=..\layouts\partials\version.txt"
if not exist "%versionFile%" (
set "versionFile=..\hugo-theme-relearn\layouts\partials\version.txt"
)
set /p version=<"%versionFile%"
echo %version%>"metrics.%version%%hugo_prefix%%hugo_version%.log"
hugo%hugo_version% --environment testing --templateMetrics --templateMetricsHints --cleanDestinationDir --destination "public.%version%%hugo_prefix%%hugo_version%" >> "metrics.%version%%hugo_prefix%%hugo_version%.log"
set "start_dir=%CD%\public.%version%%hugo_prefix%%hugo_version%"
set "output_file=dir.%version%%hugo_prefix%%hugo_version%.log"
if exist "%output_file%" del "%output_file%"
for /r "%start_dir%" %%F in (*) do (
set "file=%%F"
echo !file:%start_dir%\=! >> "%output_file%"
)
move /Y "dir.%version%%hugo_prefix%%hugo_version%.log" "public.%version%%hugo_prefix%%hugo_version%\dir.log" 2>&1 >NUL
move /Y "metrics.%version%%hugo_prefix%%hugo_version%.log" "public.%version%%hugo_prefix%%hugo_version%\metrics.log" 2>&1 >NUL
For /F "UseBackQ Delims==" %%A In ("public.%version%%hugo_prefix%%hugo_version%\metrics.log") Do Set "lastline=%%A"
echo %lastline%

View file

@ -0,0 +1,4 @@
@echo off
setlocal enabledelayedexpansion
call "test-hugo.bat" 0.95.0

View file

@ -1,18 +0,0 @@
@echo off
setlocal enabledelayedexpansion
set /p version=<..\layouts\partials\version.txt
echo %version%>metrics.%version%.log
hugo --environment testing --templateMetrics --templateMetricsHints --cleanDestinationDir --destination public.%version% >> metrics.%version%.log
set "start_dir=%CD%\public.%version%"
set "output_file=dir.%version%.log"
if exist "%output_file%" del "%output_file%"
for /r "%start_dir%" %%F in (*) do (
set "file=%%F"
echo !file:%start_dir%\=! >> "%output_file%"
)
move /Y dir.%version%.log public.%version%\dir.log 2>&1 >NUL
move /Y metrics.%version%.log public.%version%\metrics.log 2>&1 >NUL
For /F "UseBackQ Delims==" %%A In ("public.%version%\metrics.log") Do Set "lastline=%%A"
echo %lastline%

View file

@ -1,21 +0,0 @@
@echo off
setlocal enabledelayedexpansion
set hugo_major=0
set hugo_minor=95
set hugo_patch=0
set /p version=<..\layouts\partials\version.txt
echo %version%>metrics.%version%.hugo.%hugo_major%.%hugo_minor%.%hugo_patch%.log
hugo.%hugo_major%.%hugo_minor%.%hugo_patch% --environment testing --templateMetrics --templateMetricsHints --cleanDestinationDir --destination public.%version%.hugo.%hugo_major%.%hugo_minor%.%hugo_patch% >> metrics.%version%.hugo.%hugo_major%.%hugo_minor%.%hugo_patch%.log
set "start_dir=%CD%\public.%version%.hugo.%hugo_major%.%hugo_minor%.%hugo_patch%"
set "output_file=dir.%version%.hugo.%hugo_major%.%hugo_minor%.%hugo_patch%.log"
if exist "%output_file%" del "%output_file%"
for /r "%start_dir%" %%F in (*) do (
set "file=%%F"
echo !file:%start_dir%\=! >> "%output_file%"
)
move /Y dir.%version%.hugo.%hugo_major%.%hugo_minor%.%hugo_patch%.log public.%version%.hugo.%hugo_major%.%hugo_minor%.%hugo_patch%\dir.log 2>&1 >NUL
move /Y metrics.%version%.hugo.%hugo_major%.%hugo_minor%.%hugo_patch%.log public.%version%.hugo.%hugo_major%.%hugo_minor%.%hugo_patch%\metrics.log 2>&1 >NUL
For /F "UseBackQ Delims==" %%A In ("public.%version%.hugo.%hugo_major%.%hugo_minor%.%hugo_patch%\metrics.log") Do Set "lastline=%%A"
echo %lastline%