Skip to content

Commit c34872e

Browse files
Jamesclaude
authored andcommitted
Put all 39 compile and 50 run .bat scripts under Windows CI, and fix what that found
windows-bat covered four demos. It now covers every one, in three phases: compile all 39 compile_<demo>.bat; launch all 50 run_<demo>.bat with no arguments, which proves each script's class name still resolves; then drive four with real arguments and check their output. Running the whole set for the first time turned up four faults, none of which anything would ever have noticed: 1. Two scripts still compiled src\main\java\demos\*.java, a directory the package rename deleted. The earlier bulk repair rewrote src\main\java\demos\<name> and its pattern did not match the bare wildcard form, so compile_analyzescript.bat and compile_gettablecolumns.bat kept a path to nothing. 2. compile_analyzesp.bat in the nested sybase folder had a doubled path, analyzesp\sybase\sybase\Analyze_SP.java. That one is mine: the same bulk repair substituted the script's own directory for a prefix that was itself a prefix of it. It was the only instance; every .bat path is now checked against the filesystem. 3. Both run_columnImpact.bat named gudusoft.gsqlparser.demos.columnImpact, a package that stopped existing when ColumnImpact moved under antiSQLInjection. There are two ColumnImpact classes and each script now names its own. The dlineageBasic one was deleted: that class has no main(), so the script had never been able to run it -- before the rename it was reaching the other folder's class. 4. Seven demos could not compile at all, because these scripts hand javac only their own folder while the classes import across demos -- columnAnalyze and plannerAnalyze pull in ColumnImpact, visitors and sqltranslator pull in JoinConverter. Adding -sourcepath src\main\java to all 39 lets javac resolve the rest, which is what the Maven build does anyway. Also deleted TGetTableColumn_notUsed.java. It duplicated myMetaDB, TInfoRecord and SortIgnoreCase from the TGetTableColumn.java beside it, so it broke any wildcard compile of that folder -- which is exactly how compile_gettablecolumns.bat compiles it. pom.xml had excluded it for the same reason; that exclusion is gone with it. Every one of these was reproduced and verified locally against JDK 8, the toolchain CI uses, by simulating each script's javac and java invocation: 39/39 compile, 50/50 launch. mvn clean test: 144 tests, the same 3 known analyzespTest failures. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012qPRpoD8exYRrUmbfXXWXj
1 parent 4951c00 commit c34872e

44 files changed

Lines changed: 124 additions & 971 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,57 @@ jobs:
128128
echo ::error::fetch-parser.bat produced no parser jar
129129
exit /b 1
130130
131+
# Phase 1: every compile_<demo>.bat must succeed. This is the check that
132+
# matters, and the one that would have caught the whole family going stale
133+
# when the demos moved directory. `pause` at the end of each script would
134+
# block forever on a runner with no keyboard, so stdin is fed from NUL.
135+
- name: Compile all 39 demos via compile_*.bat
136+
shell: cmd
137+
run: |
138+
setlocal enabledelayedexpansion
139+
set FAILED=0
140+
set COUNT=0
141+
for /r "%GITHUB_WORKSPACE%\src\main\java" %%s in (compile_*.bat) do (
142+
set /a COUNT+=1
143+
pushd "%%~dps"
144+
call "%%~nxs" < NUL > "%GITHUB_WORKSPACE%\c.txt" 2>&1
145+
findstr /i /c:"error" /c:"file not found" /c:"no source files" "%GITHUB_WORKSPACE%\c.txt" >NUL && (
146+
echo ::error::%%~nxs failed
147+
type "%GITHUB_WORKSPACE%\c.txt"
148+
set /a FAILED+=1
149+
) || echo ok %%~nxs
150+
popd
151+
)
152+
echo.
153+
echo compiled !COUNT! demos, !FAILED! failed
154+
if not !FAILED!==0 exit /b 1
155+
156+
# Phase 2: every run_<demo>.bat must at least start its class. Run with no
157+
# arguments, so most print their own usage line; what this proves is that
158+
# the class name in the script still resolves and the classpath is right.
159+
# A stale class name after a package move shows up here as
160+
# ClassNotFoundException, which is exactly what had happened.
161+
- name: Launch all 50 demos via run_*.bat
162+
shell: cmd
163+
run: |
164+
setlocal enabledelayedexpansion
165+
set FAILED=0
166+
set COUNT=0
167+
for /r "%GITHUB_WORKSPACE%\src\main\java" %%s in (run_*.bat) do (
168+
set /a COUNT+=1
169+
pushd "%%~dps"
170+
call "%%~nxs" < NUL > "%GITHUB_WORKSPACE%\r.txt" 2>&1
171+
findstr /c:"ClassNotFoundException" /c:"NoClassDefFoundError" /c:"Main method not found" "%GITHUB_WORKSPACE%\r.txt" >NUL && (
172+
echo ::error::%%~nxs could not launch its class
173+
type "%GITHUB_WORKSPACE%\r.txt"
174+
set /a FAILED+=1
175+
) || echo ok %%~nxs
176+
popd
177+
)
178+
echo.
179+
echo launched !COUNT! demos, !FAILED! failed
180+
if not !FAILED!==0 exit /b 1
181+
131182
# `pause` at the end of each script would block forever on a runner with
132183
# no keyboard, so stdin is fed from NUL.
133184
#
@@ -136,7 +187,9 @@ jobs:
136187
# directory deeper (so its cd depth differs). They are generated from one
137188
# template and go stale as a set, which is exactly what happened when the
138189
# demos moved directory, so this is a canary rather than full coverage.
139-
- name: Run the .bat scripts
190+
# Phase 3: a few demos driven with real arguments and checked against a
191+
# string their output must contain, so this is not only a smoke test.
192+
- name: Run four demos with real arguments
140193
shell: cmd
141194
run: |
142195
echo SELECT a.id FROM ta a; > "%GITHUB_WORKSPACE%\q.sql"

README.md

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -445,26 +445,35 @@ They had been stale for years — compiling `src\main\java\demos\<demo>\` and
445445
`cd`-ing up five levels, both correct only before the demos moved under
446446
`gudusoft/gsqlparser/demos/`. Nothing noticed, because nothing ran them.
447447

448-
The `windows-bat` job in `.github/workflows/build.yml` now does, on
449-
`windows-latest`. It first asserts that **no parser jar is committed** and that
450-
`fetch-parser.bat` can bootstrap one, then compiles and runs four demos, each
451-
checked against a string its output must contain:
452-
453-
| demo | shape it covers |
454-
|------|-----------------|
455-
| `checksyntax` | `/f <file> /t <vendor>` |
456-
| `formatsql` | bare filename |
457-
| `listGSPInfo` | no arguments at all |
458-
| `modifysql` | compile and run scripts named differently (`compile_modifysql.bat` builds the folder, `run_replaceTablename.bat` runs one class) |
448+
The `windows-bat` job in `.github/workflows/build.yml` runs them on
449+
`windows-latest`, in three phases:
450+
451+
1. **Bootstrap** — assert no parser jar is committed, then let
452+
`fetch-parser.bat` pull one into `external_lib/`.
453+
2. **Compile all 39** `compile_<demo>.bat`. This is the check that matters: it
454+
is what would have caught the whole family going stale when the demos moved
455+
directory.
456+
3. **Launch all 50** `run_<demo>.bat` with no arguments, so most print their own
457+
usage line. What this proves is that each script's class name still resolves
458+
— a stale name after a package move surfaces here as
459+
`ClassNotFoundException`, which is exactly what had happened.
460+
4. **Drive four with real arguments** and check their output contains what it
461+
should: `checksyntax` (`/f <file> /t <vendor>`), `formatsql` (bare filename),
462+
`listGSPInfo` (no arguments), and `modifysql`, whose compile and run scripts
463+
are named differently (`compile_modifysql.bat` builds the folder,
464+
`run_replaceTablename.bat` runs one class).
459465

460466
Each script ends with `pause`, so CI feeds their stdin from `NUL` to keep them
461467
from blocking on a runner with no keyboard.
462468

463-
Four demos, not all 45, is a deliberate stopping point: they are generated from
464-
one template and go stale as a set, which is exactly what happened when the
465-
demos moved directory. The four cover the distinct argument shapes, so a change
466-
that breaks the template shows up here.
467-
469+
Bringing all 39 under CI turned up four things that were broken and invisible:
470+
two scripts still compiled `src\main\java\demos\*.java`, a directory deleted
471+
in the package rename; `compile_analyzesp.bat` in the nested `sybase` folder had
472+
picked up a doubled `sybase\sybase\` path; both `run_columnImpact.bat` files
473+
named a package that no longer existed; and seven demos could not compile at all
474+
because their scripts pass only their own folder to `javac` while the classes
475+
import across demos — fixed by adding `-sourcepath src\main\java`, which lets
476+
`javac` resolve the rest.
468477

469478
## Building the dlineage demo on its own
470479

pom.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,12 @@
223223
Everything else in their packages still builds. -->
224224
<exclude>gudusoft/gsqlparser/demos/gettablecolumns/runGetTableColumn.java</exclude>
225225

226-
<!-- Redefines myMetaDB / TInfoRecord / SortIgnoreCase,
226+
<!-- TGetTableColumn_notUsed.java was excluded here. It
227+
redefined myMetaDB / TInfoRecord / SortIgnoreCase,
227228
which the retained TGetTableColumn.java in the same
228-
package already provides. Its name records that it
229-
is dead. -->
230-
<exclude>gudusoft/gsqlparser/demos/gettablecolumns/TGetTableColumn_notUsed.java</exclude>
229+
package already provides, so it also broke any
230+
wildcard compile of that folder -- which is how
231+
compile_gettablecolumns.bat compiles it. Deleted. -->
231232
<exclude>gudusoft/gsqlparser/demos/columninspect/ColumnInspect.java</exclude>
232233
<exclude>gudusoft/gsqlparser/demos/dlineage/DataFlowAnalyzer.java</exclude>
233234
</excludes>

src/main/java/gudusoft/gsqlparser/demos/analyzescript/compile_analyzescript.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ REM # Compile the gsp demo
3535
REM # javac -d needs the output directory to already exist.
3636
if not exist %targetdir% mkdir %targetdir%
3737

38-
%JAVAC_CMD% -d %targetdir% -classpath %CLASSPATH% src\main\java\demos\*.java src\main\java\gudusoft\gsqlparser\demos\analyzescript\*.java
38+
%JAVAC_CMD% -d %targetdir% -sourcepath src\main\java -classpath %CLASSPATH% src\main\java\gudusoft\gsqlparser\demos\analyzescript\*.java
3939

4040
echo Completed.
4141

src/main/java/gudusoft/gsqlparser/demos/analyzesp/compile_analyzesp.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ REM # Compile the gsp demo
3535
REM # javac -d needs the output directory to already exist.
3636
if not exist %targetdir% mkdir %targetdir%
3737

38-
%JAVAC_CMD% -d %targetdir% -classpath %CLASSPATH% src\main\java\gudusoft\gsqlparser\demos\analyzesp\Analyze_SP.java
38+
%JAVAC_CMD% -d %targetdir% -sourcepath src\main\java -classpath %CLASSPATH% src\main\java\gudusoft\gsqlparser\demos\analyzesp\Analyze_SP.java
3939

4040
echo Completed.
4141

src/main/java/gudusoft/gsqlparser/demos/analyzesp/sybase/compile_analyzesp.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ REM # Compile the gsp demo
3535
REM # javac -d needs the output directory to already exist.
3636
if not exist %targetdir% mkdir %targetdir%
3737

38-
%JAVAC_CMD% -d %targetdir% -classpath %CLASSPATH% src\main\java\gudusoft\gsqlparser\demos\analyzesp\sybase\sybase\Analyze_SP.java
38+
%JAVAC_CMD% -d %targetdir% -sourcepath src\main\java -classpath %CLASSPATH% src\main\java\gudusoft\gsqlparser\demos\analyzesp\sybase\Analyze_SP.java
3939

4040
echo Completed.
4141

src/main/java/gudusoft/gsqlparser/demos/analyzeview/compile_analyzeview.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ REM # Compile the gsp demo
3535
REM # javac -d needs the output directory to already exist.
3636
if not exist %targetdir% mkdir %targetdir%
3737

38-
%JAVAC_CMD% -d %targetdir% -classpath %CLASSPATH% src\main\java\gudusoft\gsqlparser\demos\analyzeview\Analyze_View.java
38+
%JAVAC_CMD% -d %targetdir% -sourcepath src\main\java -classpath %CLASSPATH% src\main\java\gudusoft\gsqlparser\demos\analyzeview\Analyze_View.java
3939

4040
echo Completed.
4141

src/main/java/gudusoft/gsqlparser/demos/antiSQLInjection/columnImpact/compile_columnImpact.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ REM # Compile the gsp demo
3535
REM # javac -d needs the output directory to already exist.
3636
if not exist %targetdir% mkdir %targetdir%
3737

38-
%JAVAC_CMD% -d %targetdir% -classpath %CLASSPATH% src\main\java\gudusoft\gsqlparser\demos\antiSQLInjection\columnImpact\*.java
38+
%JAVAC_CMD% -d %targetdir% -sourcepath src\main\java -classpath %CLASSPATH% src\main\java\gudusoft\gsqlparser\demos\antiSQLInjection\columnImpact\*.java
3939

4040
echo Completed.
4141

src/main/java/gudusoft/gsqlparser/demos/antiSQLInjection/columnImpact/run_columnImpact.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ call setenv\setenv.bat
2626
)
2727

2828
REM # Run the gsp demo
29-
%JAVA_CMD% -cp %CLASSPATH% gudusoft.gsqlparser.demos.columnImpact.ColumnImpact %1 %2 %3 %4 %5 %6 %7 %8 %9
29+
%JAVA_CMD% -cp %CLASSPATH% gudusoft.gsqlparser.demos.antiSQLInjection.columnImpact.ColumnImpact %1 %2 %3 %4 %5 %6 %7 %8 %9
3030

3131
REM # Change back to the original directory
3232
cd src\main\java\gudusoft\gsqlparser\demos\antiSQLInjection\columnImpact

src/main/java/gudusoft/gsqlparser/demos/antiSQLInjection/compile_antiSQLInjection.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ REM # Compile the gsp demo
3535
REM # javac -d needs the output directory to already exist.
3636
if not exist %targetdir% mkdir %targetdir%
3737

38-
%JAVAC_CMD% -d %targetdir% -classpath %CLASSPATH% src\main\java\gudusoft\gsqlparser\demos\antiSQLInjection\*.java
38+
%JAVAC_CMD% -d %targetdir% -sourcepath src\main\java -classpath %CLASSPATH% src\main\java\gudusoft\gsqlparser\demos\antiSQLInjection\*.java
3939

4040
echo Completed.
4141

0 commit comments

Comments
 (0)