Skip to content

Commit 654eb22

Browse files
committed
splitted build.bat into several parts (same as bash scripts)
1 parent 7f79714 commit 654eb22

File tree

5 files changed

+437
-226
lines changed

5 files changed

+437
-226
lines changed

project/scripts/bootstrapCmdTests.bat

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
@echo off
2+
3+
rem ##########################################################################
4+
rem ## This batch file is based on shell script project/scripts/bootstrapCmdTests
5+
6+
setlocal enabledelayedexpansion
7+
8+
rem only for interactive debugging
9+
set _DEBUG=0
10+
11+
rem ##########################################################################
12+
rem ## Environment setup
13+
14+
set _BASENAME=%~n0
15+
16+
set _EXITCODE=0
17+
18+
for %%f in ("%~dp0..\..") do set _ROOT_DIR=%%~sf
19+
set _SCRIPTS_DIR=%_ROOT_DIR%\project\scripts
20+
set _BIN_DIR=%_ROOT_DIR%\bin
21+
22+
if not defined __COMMON__ (
23+
if %_DEBUG%==1 echo [%_BASENAME%] call %_SCRIPTS_DIR%\common.bat
24+
call %_SCRIPTS_DIR%\common.bat
25+
if not !_EXITCODE!==0 goto end
26+
)
27+
28+
rem ##########################################################################
29+
rem ## Main
30+
31+
rem # check that benchmarks can run
32+
if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" "dotty-bench/jmh:run 1 1 tests/pos/alias.scala"
33+
call "%_SBT_CMD%" "dotty-bench/jmh:run 1 1 tests/pos/alias.scala"
34+
if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end )
35+
36+
rem # The above is here as it relies on the bootstrapped library.
37+
call "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 tests/pos/alias.scala"
38+
call "%_SBT_CMD%" "dotty-bench-bootstrapped/jmh:run 1 1 -with-compiler compiler/src/dotty/tools/dotc/core/Types.scala"
39+
40+
echo testing scala.quoted.Expr.run from sbt dotr
41+
call "%_SBT_CMD%" ";dotty-compiler-bootstrapped/dotc tests/run-with-compiler/quote-run.scala; dotty-compiler-bootstrapped/dotr -with-compiler Test" > "%_TMP_FILE%"
42+
call :grep "val a: scala.Int = 3" "%_TMP_FILE%"
43+
if not %_EXITCODE%==0 goto end
44+
45+
rem # setup for `dotc`/`dotr` script tests
46+
if %_DEBUG%==1 echo [%_BASENAME%] "%_SBT_CMD%" dist-bootstrapped/pack
47+
call "%_SBT_CMD%" dist-bootstrapped/pack
48+
if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end )
49+
50+
rem # check that `dotc` compiles and `dotr` runs it
51+
echo testing ./bin/dotc and ./bin/dotr
52+
call :clear_out "%_OUT_DIR%"
53+
if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotc.bat "%_SOURCE%" -d "%_OUT_DIR%"
54+
call %_BIN_DIR%\dotc.bat "%_SOURCE%" -d "%_OUT_DIR%"
55+
if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotr.bat -classpath "%_OUT_DIR%" "%_MAIN%" ^> "%_TMP_FILE%"
56+
call %_BIN_DIR%\dotr.bat -classpath "%_OUT_DIR%" "%_MAIN%" > "%_TMP_FILE%"
57+
if %_DEBUG%==1 echo [%_BASENAME%] call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%"
58+
call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%"
59+
if not %_EXITCODE%==0 goto end
60+
61+
rem # check that `dotc -from-tasty` compiles and `dotr` runs it
62+
echo testing ./bin/dotc -from-tasty and dotr -classpath
63+
call :clear_out "%_OUT1_DIR%"
64+
if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotc.bat -from-tasty -classpath "%_OUT_DIR%" -d "%_OUT1_DIR%" "%_MAIN%"
65+
call %_BIN_DIR%\dotc.bat -from-tasty -classpath "%_OUT_DIR%" -d "%_OUT1_DIR%" "%_MAIN%"
66+
if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotr.bat -classpath "%_OUT1_DIR%" "%_MAIN%" ^> "%_TMP_FILE%"
67+
call %_BIN_DIR%\dotr.bat -classpath "%_OUT1_DIR%" "%_MAIN%" > "%_TMP_FILE%"
68+
if %_DEBUG%==1 echo [%_BASENAME%] call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%"
69+
call :test_pattern "%_EXPECTED_OUTPUT%" "%_TMP_FILE%"
70+
if not %_EXITCODE%==0 goto end
71+
72+
rem # echo ":quit" | ./dist-bootstrapped/target/pack/bin/dotr # not supported by CI
73+
74+
echo testing ./bin/dotd
75+
call :clear_out "%_OUT_DIR%"
76+
if %_DEBUG%==1 echo [%_BASENAME%] call %_BIN_DIR%\dotd.bat -project Hello -siteroot "%_OUT_DIR%" "%_SOURCE%"
77+
call %_BIN_DIR%\dotd.bat -project Hello -siteroot "%_OUT_DIR%" "%_SOURCE%"
78+
if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end )
79+
80+
goto end
81+
82+
rem ##########################################################################
83+
rem ## Subroutines
84+
85+
:clear_out
86+
set __OUT_DIR=%~1
87+
88+
if exist "%__OUT_DIR%\" (
89+
if %_DEBUG%==1 echo [%_BASENAME%] del /s /q "%__OUT_DIR%\*" 1^>NUL
90+
del /s /q "%__OUT_DIR%\*" 1>NUL
91+
)
92+
goto :eof
93+
94+
:grep
95+
set __PATTERN=%~1
96+
set __FILE=%~2
97+
98+
if %_DEBUG%==1 echo [%_BASENAME%] findstr "%__PATTERN%" "%__FILE%"
99+
findstr "%__PATTERN%" "%__FILE%"
100+
if not %ERRORLEVEL%==0 (
101+
echo Error: Failed to find pattern "%__PATTERN%" in file %__FILE% 1>&2
102+
set _EXITCODE=1
103+
goto :eof
104+
)
105+
goto :eof
106+
107+
:test_pattern
108+
set __PATTERN=%~1
109+
set __FILE=%~2
110+
111+
set /p __PATTERN2=<"%__FILE%"
112+
if not "%__PATTERN2%"=="%__PATTERN%" (
113+
echo Error: Failed to find pattern "%__PATTERN%" in file %__FILE% 1>&2
114+
set _EXITCODE=1
115+
goto :eof
116+
)
117+
goto :eof
118+
119+
rem ##########################################################################
120+
rem ## Cleanups
121+
122+
:end
123+
if %_DEBUG%==1 echo [%_BASENAME%] _EXITCODE=%_EXITCODE%
124+
exit /b %_EXITCODE%
125+
endlocal

0 commit comments

Comments
 (0)