Skip to content

Commit 83c8f76

Browse files
committed
Merge branch 'ps/ci-meson'
The meson-build procedure is integrated into CI to catch and prevent bitrotting. * ps/ci-meson: ci: wire up Meson builds t: introduce compatibility options to clar-based tests t: fix out-of-tree tests for some git-p4 tests Makefile: detect missing Meson tests meson: detect missing tests at configure time t/unit-tests: rename clar-based unit tests to have a common prefix Makefile: drop -DSUPPRESS_ANNOTATED_LEAKS ci/lib: support custom output directories when creating test artifacts
2 parents e9a4054 + eab5dba commit 83c8f76

17 files changed

+195
-74
lines changed

.github/workflows/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ jobs:
282282
- jobname: osx-gcc
283283
cc: gcc-13
284284
pool: macos-13
285+
- jobname: osx-meson
286+
cc: clang
287+
pool: macos-13
285288
- jobname: linux-gcc-default
286289
cc: gcc
287290
pool: ubuntu-latest
@@ -294,11 +297,15 @@ jobs:
294297
- jobname: linux-asan-ubsan
295298
cc: clang
296299
pool: ubuntu-latest
300+
- jobname: linux-meson
301+
cc: gcc
302+
pool: ubuntu-latest
297303
env:
298304
CC: ${{matrix.vector.cc}}
299305
CC_PACKAGE: ${{matrix.vector.cc_package}}
300306
jobname: ${{matrix.vector.jobname}}
301307
distro: ${{matrix.vector.pool}}
308+
TEST_OUTPUT_DIRECTORY: ${{github.workspace}}/t
302309
runs-on: ${{matrix.vector.pool}}
303310
steps:
304311
- uses: actions/checkout@v4

.gitlab-ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ test:linux:
2020
- saas-linux-medium-amd64
2121
variables:
2222
CUSTOM_PATH: "/custom"
23+
TEST_OUTPUT_DIRECTORY: "/tmp/test-output"
2324
before_script:
2425
- ./ci/install-dependencies.sh
2526
script:
@@ -31,6 +32,7 @@ test:linux:
3132
if test "$CI_JOB_STATUS" != 'success'
3233
then
3334
sudo --preserve-env --set-home --user=builder ./ci/print-test-failures.sh
35+
mv "$TEST_OUTPUT_DIRECTORY"/failed-test-artifacts t/
3436
fi
3537
parallel:
3638
matrix:
@@ -67,6 +69,9 @@ test:linux:
6769
image: fedora:latest
6870
- jobname: linux-musl
6971
image: alpine:latest
72+
- jobname: linux-meson
73+
image: ubuntu:latest
74+
CC: gcc
7075
artifacts:
7176
paths:
7277
- t/failed-test-artifacts
@@ -104,6 +109,9 @@ test:osx:
104109
- jobname: osx-reftable
105110
image: macos-14-xcode-15
106111
CC: clang
112+
- jobname: osx-meson
113+
image: macos-14-xcode-15
114+
CC: clang
107115
artifacts:
108116
paths:
109117
- t/failed-test-artifacts

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,8 +1344,8 @@ THIRD_PARTY_SOURCES += sha1dc/%
13441344
THIRD_PARTY_SOURCES += $(UNIT_TEST_DIR)/clar/%
13451345
THIRD_PARTY_SOURCES += $(UNIT_TEST_DIR)/clar/clar/%
13461346

1347-
CLAR_TEST_SUITES += ctype
1348-
CLAR_TEST_SUITES += strvec
1347+
CLAR_TEST_SUITES += u-ctype
1348+
CLAR_TEST_SUITES += u-strvec
13491349
CLAR_TEST_PROG = $(UNIT_TEST_BIN)/unit-tests$(X)
13501350
CLAR_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(CLAR_TEST_SUITES))
13511351
CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/clar/clar.o
@@ -1490,7 +1490,6 @@ ifneq ($(filter undefined,$(SANITIZERS)),)
14901490
BASIC_CFLAGS += -DSHA1DC_FORCE_ALIGNED_ACCESS
14911491
endif
14921492
ifneq ($(filter leak,$(SANITIZERS)),)
1493-
BASIC_CFLAGS += -DSUPPRESS_ANNOTATED_LEAKS
14941493
BASIC_CFLAGS += -O0
14951494
SANITIZE_LEAK = YesCompiledWithIt
14961495
endif

ci/install-dependencies.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ ubuntu-*|ubuntu32-*|debian-*)
5858
make libssl-dev libcurl4-openssl-dev libexpat-dev wget sudo default-jre \
5959
tcl tk gettext zlib1g-dev perl-modules liberror-perl libauthen-sasl-perl \
6060
libemail-valid-perl libio-pty-perl libio-socket-ssl-perl libnet-smtp-ssl-perl libdbd-sqlite3-perl libcgi-pm-perl \
61+
libpcre2-dev meson ninja-build pkg-config \
6162
${CC_PACKAGE:-${CC:-gcc}} $PYTHON_PACKAGE
6263

6364
case "$distro" in
@@ -90,6 +91,12 @@ macos-*)
9091
sudo xattr -d com.apple.quarantine "$CUSTOM_PATH/p4" "$CUSTOM_PATH/p4d" 2>/dev/null || true
9192
rm helix-core-server.tgz
9293

94+
case "$jobname" in
95+
osx-meson)
96+
brew install meson ninja pcre2
97+
;;
98+
esac
99+
93100
if test -n "$CC_PACKAGE"
94101
then
95102
BREW_PACKAGE=${CC_PACKAGE/-/@}

ci/lib.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ handle_failed_tests () {
181181
}
182182

183183
create_failed_test_artifacts () {
184-
mkdir -p t/failed-test-artifacts
184+
mkdir -p "${TEST_OUTPUT_DIRECTORY:-t}"/failed-test-artifacts
185185

186-
for test_exit in t/test-results/*.exit
186+
for test_exit in "${TEST_OUTPUT_DIRECTORY:-t}"/test-results/*.exit
187187
do
188188
test 0 != "$(cat "$test_exit")" || continue
189189

@@ -192,11 +192,11 @@ create_failed_test_artifacts () {
192192
printf "\\e[33m\\e[1m=== Failed test: ${test_name} ===\\e[m\\n"
193193
echo "The full logs are in the 'print test failures' step below."
194194
echo "See also the 'failed-tests-*' artifacts attached to this run."
195-
cat "t/test-results/$test_name.markup"
195+
cat "${TEST_OUTPUT_DIRECTORY:-t}/test-results/$test_name.markup"
196196

197-
trash_dir="t/trash directory.$test_name"
198-
cp "t/test-results/$test_name.out" t/failed-test-artifacts/
199-
tar czf t/failed-test-artifacts/"$test_name".trash.tar.gz "$trash_dir"
197+
trash_dir="${TEST_OUTPUT_DIRECTORY:-t}/trash directory.$test_name"
198+
cp "${TEST_OUTPUT_DIRECTORY:-t}/test-results/$test_name.out" "${TEST_OUTPUT_DIRECTORY:-t}"/failed-test-artifacts/
199+
tar czf "${TEST_OUTPUT_DIRECTORY:-t}/failed-test-artifacts/$test_name.trash.tar.gz" "$trash_dir"
200200
done
201201
}
202202

@@ -237,7 +237,7 @@ then
237237
CC="${CC_PACKAGE:-${CC:-gcc}}"
238238
DONT_SKIP_TAGS=t
239239
handle_failed_tests () {
240-
echo "FAILED_TEST_ARTIFACTS=t/failed-test-artifacts" >>$GITHUB_ENV
240+
echo "FAILED_TEST_ARTIFACTS=${TEST_OUTPUT_DIRECTORY:-t}/failed-test-artifacts" >>$GITHUB_ENV
241241
create_failed_test_artifacts
242242
return 1
243243
}

ci/print-test-failures.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ do
4646
;;
4747
github-actions)
4848
mkdir -p failed-test-artifacts
49-
echo "FAILED_TEST_ARTIFACTS=t/failed-test-artifacts" >>$GITHUB_ENV
49+
echo "FAILED_TEST_ARTIFACTS=${TEST_OUTPUT_DIRECTORY:t}/failed-test-artifacts" >>$GITHUB_ENV
5050
cp "${TEST_EXIT%.exit}.out" failed-test-artifacts/
5151
tar czf failed-test-artifacts/"$test_name".trash.tar.gz "$trash_dir"
5252
continue

ci/run-build-and-tests.sh

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,29 @@ pedantic)
4848
;;
4949
esac
5050

51-
group Build make
52-
if test -n "$run_tests"
53-
then
54-
group "Run tests" make test ||
55-
handle_failed_tests
56-
fi
57-
check_unignored_build_artifacts
51+
case "$jobname" in
52+
*-meson)
53+
group "Configure" meson setup build . \
54+
--warnlevel 2 --werror \
55+
--wrap-mode nofallback
56+
group "Build" meson compile -C build --
57+
if test -n "$run_tests"
58+
then
59+
group "Run tests" meson test -C build --print-errorlogs --test-args="$GIT_TEST_OPTS" || (
60+
./t/aggregate-results.sh "${TEST_OUTPUT_DIRECTORY:-t}/test-results"
61+
handle_failed_tests
62+
)
63+
fi
64+
;;
65+
*)
66+
group Build make
67+
if test -n "$run_tests"
68+
then
69+
group "Run tests" make test ||
70+
handle_failed_tests
71+
fi
72+
;;
73+
esac
5874

75+
check_unignored_build_artifacts
5976
save_good_tree

meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,6 @@ else
712712
build_options_config.set('SANITIZE_ADDRESS', '')
713713
endif
714714
if get_option('b_sanitize').contains('leak')
715-
libgit_c_args += '-DSUPPRESS_ANNOTATED_LEAKS'
716715
build_options_config.set('SANITIZE_LEAK', 'YesCompiledWithIt')
717716
else
718717
build_options_config.set('SANITIZE_LEAK', '')

parse-options.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,18 @@ struct option {
353353
.callback = parse_opt_noop_cb, \
354354
}
355355

356+
static char *parse_options_noop_ignored_value MAYBE_UNUSED;
357+
#define OPT_NOOP_ARG(s, l) { \
358+
.type = OPTION_CALLBACK, \
359+
.short_name = (s), \
360+
.long_name = (l), \
361+
.value = &parse_options_noop_ignored_value, \
362+
.argh = "ignored", \
363+
.help = N_("no-op (backward compatibility)"), \
364+
.flags = PARSE_OPT_HIDDEN, \
365+
.callback = parse_opt_noop_cb, \
366+
}
367+
356368
#define OPT_ALIAS(s, l, source_long_name) { \
357369
.type = OPTION_ALIAS, \
358370
.short_name = (s), \

t/Makefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ CHAINLINTSUPPRESS = GIT_TEST_EXT_CHAIN_LINT=0 && export GIT_TEST_EXT_CHAIN_LINT
5959

6060
all:: $(DEFAULT_TEST_TARGET)
6161

62-
test: pre-clean check-chainlint $(TEST_LINT)
62+
test: pre-clean check-chainlint check-meson $(TEST_LINT)
6363
$(CHAINLINTSUPPRESS) $(MAKE) aggregate-results-and-cleanup
6464

6565
failed:
@@ -114,6 +114,22 @@ check-chainlint:
114114
{ $(CHAINLINT) --emit-all '$(CHAINLINTTMP_SQ)'/tests >'$(CHAINLINTTMP_SQ)'/actual || true; } && \
115115
diff -u '$(CHAINLINTTMP_SQ)'/expect '$(CHAINLINTTMP_SQ)'/actual
116116

117+
check-meson:
118+
@# awk acts up when trying to match single quotes, so we use \047 instead.
119+
@printf "%s\n" \
120+
"integration_tests t[0-9][0-9][0-9][0-9]-*.sh" \
121+
"unit_test_programs unit-tests/t-*.c" \
122+
"clar_test_suites unit-tests/u-*.c" | \
123+
while read -r variable pattern; do \
124+
meson_tests=$$(awk "/^$$variable = \[\$$/ {flag=1 ; next } /^]$$/ { flag=0 } flag { gsub(/^ \047/, \"\"); gsub(/\047,\$$/, \"\"); print }" meson.build) && \
125+
actual_tests=$$(ls $$pattern) && \
126+
if test "$$meson_tests" != "$$actual_tests"; then \
127+
echo "Meson tests differ from actual tests:"; \
128+
diff -u <(echo "$$meson_tests") <(echo "$$actual_tests"); \
129+
exit 1; \
130+
fi; \
131+
done
132+
117133
test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \
118134
test-lint-filenames
119135
ifneq ($(GIT_TEST_CHAIN_LINT),0)

0 commit comments

Comments
 (0)