diff --git a/cmd/five/main.go b/cmd/five/main.go index 08d6163..4d59d58 100644 --- a/cmd/five/main.go +++ b/cmd/five/main.go @@ -324,6 +324,24 @@ func buildPRGWithIncludes(prgFile, output string, includes []string) { // buildMultiPRGWithIncludes is buildMultiPRG with -I support. func buildMultiPRGWithIncludes(prgFiles []string, output string, includes []string) { + // Multi-file builds bring along sibling PRGs whose own #include + // references a .ch file living next to them (e.g. FiveSqlDef.ch + // in _FiveSql2/src/). Each file's PP only adds its OWN dir by + // default, so a test under _FiveSql2/test/ couldn't find a .ch + // kept in _FiveSql2/src/. Promote every input file's dir into + // the shared user-include list so siblings can resolve each + // other's headers. + seen := map[string]bool{} + for _, dir := range includes { + seen[dir] = true + } + for _, f := range prgFiles { + dir := filepath.Dir(f) + if dir != "" && !seen[dir] { + seen[dir] = true + includes = append(includes, dir) + } + } userIncludeDirs = includes buildMultiPRG(prgFiles, output) } diff --git a/tests/std_ch/run.sh b/tests/std_ch/run.sh index 0abf7c9..5fbbb52 100755 --- a/tests/std_ch/run.sh +++ b/tests/std_ch/run.sh @@ -32,6 +32,7 @@ TESTS=( test_block_comma test_compound_lhs test_join_hash + test_sql_standards ) work="$(mktemp -d)" @@ -41,8 +42,17 @@ pass=0 fail=0 for name in "${TESTS[@]}"; do src="$ROOT/tests/std_ch/${name}.prg" + # test_sql_standards lives in our suite but its `#include + # "FiveSqlDef.ch"` resolves only when the FiveSql2 src files + # are part of the same build (they sit alongside the .ch). + # Other tests build standalone. + extras=() + if [ "$name" = "test_sql_standards" ]; then + src="$ROOT/_FiveSql2/test/test_sql_standards.prg" + extras=( $ROOT/_FiveSql2/src/*.prg ) + fi bin="$work/${name}" - if ! "$FIVE" build "$src" -o "$bin" >/dev/null 2>"$work/${name}.err"; then + if ! "$FIVE" build "$src" "${extras[@]}" -o "$bin" >/dev/null 2>"$work/${name}.err"; then echo "FAIL build $name" cat "$work/${name}.err" | sed 's/^/ /' fail=$((fail+1))