Skip to content

Commit b2a8b7b

Browse files
committed
Merge branch 'ps/ci-gitlab-msvc-updates' into next
CI update. * ps/ci-gitlab-msvc-updates: gitlab-ci: handle failed tests on MSVC+Meson job gitlab-ci: use "run-test-slice-meson.sh" ci: make test slicing consistent across Meson/Make github: fix Meson tests not executing at all meson: fix MERGE_TOOL_DIR with "--no-bin-wrappers" ci: don't skip smallest test slice in GitLab ci: handle failures of test-slice helper
2 parents 1d5f62e + 5133837 commit b2a8b7b

6 files changed

Lines changed: 36 additions & 16 deletions

File tree

.github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ jobs:
150150
- uses: git-for-windows/setup-git-for-windows-sdk@v1
151151
- name: test
152152
shell: bash
153-
run: . /etc/profile && ci/run-test-slice.sh ${{matrix.nr}} 10
153+
run: . /etc/profile && ci/run-test-slice.sh $((${{matrix.nr}} + 1)) 10
154154
- name: print test failures
155155
if: failure() && env.FAILED_TEST_ARTIFACTS != ''
156156
shell: bash
@@ -237,7 +237,7 @@ jobs:
237237
shell: bash
238238
env:
239239
NO_SVN_TESTS: 1
240-
run: . /etc/profile && ci/run-test-slice.sh ${{matrix.nr}} 10
240+
run: . /etc/profile && ci/run-test-slice.sh $((${{matrix.nr}} + 1)) 10
241241
- name: print test failures
242242
if: failure() && env.FAILED_TEST_ARTIFACTS != ''
243243
shell: bash
@@ -297,8 +297,8 @@ jobs:
297297
name: windows-meson-artifacts
298298
path: build
299299
- name: Test
300-
shell: pwsh
301-
run: ci/run-test-slice-meson.sh build ${{matrix.nr}} 10
300+
shell: bash
301+
run: ci/run-test-slice-meson.sh build $((${{matrix.nr}} + 1)) 10
302302
- name: print test failures
303303
if: failure() && env.FAILED_TEST_ARTIFACTS != ''
304304
shell: bash

.gitlab-ci.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,22 @@ test:mingw64:
157157
parallel: 10
158158

159159
.msvc-meson:
160+
variables:
161+
TEST_OUTPUT_DIRECTORY: "C:/Git-Test"
160162
tags:
161163
- saas-windows-medium-amd64
162164
before_script:
163165
- *windows_before_script
164166
- choco install -y git meson ninja rust-ms
165167
- Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
166168
- refreshenv
169+
- New-Item -Path $env:TEST_OUTPUT_DIRECTORY -ItemType Directory
167170

168171
build:msvc-meson:
169172
extends: .msvc-meson
170173
stage: build
171174
script:
172-
- meson setup build --vsenv -Dperl=disabled -Dbackend_max_links=1 -Dcredential_helpers=wincred
175+
- meson setup build --vsenv -Dperl=disabled -Dbackend_max_links=1 -Dcredential_helpers=wincred -Dtest_output_directory="$TEST_OUTPUT_DIRECTORY"
173176
- meson compile -C build
174177
artifacts:
175178
paths:
@@ -183,11 +186,21 @@ test:msvc-meson:
183186
- job: "build:msvc-meson"
184187
artifacts: true
185188
script:
186-
- meson test -C build --no-rebuild --print-errorlogs --slice $Env:CI_NODE_INDEX/$Env:CI_NODE_TOTAL
189+
- |
190+
& "C:/Program Files/Git/usr/bin/bash.exe" -l -c 'ci/run-test-slice-meson.sh build $CI_NODE_INDEX $CI_NODE_TOTAL'
191+
after_script:
192+
- |
193+
if ($env:CI_JOB_STATUS -ne "success") {
194+
& "C:/Program Files/Git/usr/bin/bash.exe" -l -c 'ci/print-test-failures.sh'
195+
Move-Item -Path "$env:TEST_OUTPUT_DIRECTORY/failed-test-artifacts" -Destination t/
196+
}
187197
parallel: 10
188198
artifacts:
199+
paths:
200+
- t/failed-test-artifacts
189201
reports:
190202
junit: build/meson-logs/testlog.junit.xml
203+
when: on_failure
191204

192205
test:fuzz-smoke-tests:
193206
image: ubuntu:latest

ci/run-test-slice-meson.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99

1010
group "Run tests" \
1111
meson test -C "$1" --no-rebuild --print-errorlogs \
12-
--test-args="$GIT_TEST_OPTS" --slice "$((1+$2))/$3" ||
12+
--test-args="$GIT_TEST_OPTS" --slice "$(($2))/$3" ||
1313
handle_failed_tests

ci/run-test-slice.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
. ${0%/*}/lib.sh
77

8-
group "Run tests" make --quiet -C t T="$(cd t &&
9-
./helper/test-tool path-utils slice-tests "$1" "$2" t[0-9]*.sh |
10-
tr '\n' ' ')" ||
8+
TESTS=$(cd t && ./helper/test-tool path-utils slice-tests "$1" "$2" t[0-9]*.sh)
9+
10+
group "Run tests" make --quiet -C t T="$(echo "$TESTS" | tr '\n' ' ')" ||
1111
handle_failed_tests
1212

1313
# We only have one unit test at the moment, so run it in the first slice

t/helper/test-path-utils.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -477,22 +477,28 @@ int cmd__path_utils(int argc, const char **argv)
477477

478478
if (argc > 5 && !strcmp(argv[1], "slice-tests")) {
479479
int res = 0;
480-
long offset, stride, i;
480+
long slice, slices_total, i;
481481
struct string_list list = STRING_LIST_INIT_NODUP;
482482
struct stat st;
483483

484-
offset = strtol(argv[2], NULL, 10);
485-
stride = strtol(argv[3], NULL, 10);
486-
if (stride < 1)
487-
stride = 1;
484+
slices_total = strtol(argv[3], NULL, 10);
485+
if (slices_total < 1)
486+
die("there must be at least one slice, got '%s'",
487+
argv[3]);
488+
489+
slice = strtol(argv[2], NULL, 10);
490+
if (1 > slice || slice > slices_total)
491+
die("slice must be in the range 1 <= slice <= %ld, got '%s'",
492+
slices_total, argv[2]);
493+
488494
for (i = 4; i < argc; i++)
489495
if (stat(argv[i], &st))
490496
res = error_errno("Cannot stat '%s'", argv[i]);
491497
else
492498
string_list_append(&list, argv[i])->util =
493499
(void *)(intptr_t)st.st_size;
494500
QSORT(list.items, list.nr, cmp_by_st_size);
495-
for (i = offset; i < list.nr; i+= stride)
501+
for (i = slice - 1; i < list.nr; i+= slices_total)
496502
printf("%s\n", list.items[i].string);
497503

498504
return !!res;

t/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,7 @@ endif
12131213

12141214
test_environment = script_environment
12151215
test_environment.set('GIT_BUILD_DIR', git_build_dir)
1216+
test_environment.set('MERGE_TOOLS_DIR', meson.project_source_root() / 'mergetools')
12161217

12171218
foreach integration_test : integration_tests
12181219
test(fs.stem(integration_test), shell,

0 commit comments

Comments
 (0)