Skip to content

Commit 6c748d2

Browse files
committed
test: Test the clang-scan-deps wrapper
1 parent 334794b commit 6c748d2

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ jobs:
266266
./build-all.sh $(pwd)/install/llvm-mingw --disable-clang-tools-extra --disable-lldb $ARGS
267267
.github/workflows/store-version.sh install/llvm-mingw/versions.txt
268268
./copy-msys-dependencies.sh $(pwd)/install/llvm-mingw ${{matrix.sys}}
269-
./test-libcxx-module.sh $(pwd)/install/llvm-mingw
269+
NATIVE=1 ./test-libcxx-module.sh $(pwd)/install/llvm-mingw
270270
./run-tests.sh $(pwd)/install/llvm-mingw
271271
cd install
272272
NAME=llvm-mingw-$TAG-ucrt-msys2-${{matrix.sys}}
@@ -362,7 +362,7 @@ jobs:
362362
- uses: actions/checkout@v4
363363
- name: Run tests
364364
run: |
365-
./test-libcxx-module.sh /llvm-mingw
365+
NATIVE=1 ./test-libcxx-module.sh /llvm-mingw
366366
./run-tests.sh /llvm-mingw
367367
./run-lldb-tests.sh /llvm-mingw
368368

test-libcxx-module.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,10 @@ for arch in $ARCHS; do
3030
# TODO: This should ideally use "$CXX -print-file-name=libc++.modules.json", then parse the json to find the relevant cppm file and include directory.
3131
$arch-w64-mingw32-clang++ -I$PREFIX/share/libc++/v1 -std=gnu++23 -Wno-reserved-module-identifier -x c++-module -fmodule-output=std.pcm -o std.cppm.obj -c $PREFIX/share/libc++/v1/std.cppm
3232
$arch-w64-mingw32-clang++ -I$PREFIX/share/libc++/v1 -std=gnu++23 -Wno-reserved-module-identifier -x c++-module -fmodule-output=std.compat.pcm -fmodule-file=std=std.pcm -o std.compat.cppm.obj -c $PREFIX/share/libc++/v1/std.compat.cppm
33+
$arch-w64-mingw32-clang-scan-deps -format=p1689 -- $arch-w64-mingw32-clang++ -std=c++23 -c test/test-scan-deps.cpp -DEXPECT_$arch
3334
done
35+
36+
if [ -n "$NATIVE" ]; then
37+
# Test the unprefixed clang-scan-deps wrapper.
38+
clang-scan-deps -format=p1689 -- clang++ -std=c++23 -c test/test-scan-deps.cpp -DEXPECT_$(clang++ -dumpmachine | sed 's/-.*//')
39+
fi

test/test-scan-deps.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) 2024 Martin Storsjo
3+
*
4+
* This file is part of llvm-mingw.
5+
*
6+
* Permission to use, copy, modify, and/or distribute this software for any
7+
* purpose with or without fee is hereby granted, provided that the above
8+
* copyright notice and this permission notice appear in all copies.
9+
*
10+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17+
*/
18+
19+
// Test that clang-scan-deps can locate c++ standard library headers
20+
#include <version>
21+
22+
// Test that we have set the expected architecture defines.
23+
#if defined(__x86_64__)
24+
#ifndef EXPECT_x86_64
25+
#include <intentionally-missing-header>
26+
#endif
27+
#elif defined(__i386__)
28+
#ifndef EXPECT_i686
29+
#include <intentionally-missing-header>
30+
#endif
31+
#elif defined(__aarch64__)
32+
#ifndef EXPECT_aarch64
33+
#include <intentionally-missing-header>
34+
#endif
35+
#elif defined(__arm__)
36+
#ifndef EXPECT_armv7
37+
#include <intentionally-missing-header>
38+
#endif
39+
#endif

0 commit comments

Comments
 (0)