Skip to content

Commit

Permalink
test: Test the clang-scan-deps wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
mstorsjo committed May 2, 2024
1 parent 334794b commit 6c748d2
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ jobs:
./build-all.sh $(pwd)/install/llvm-mingw --disable-clang-tools-extra --disable-lldb $ARGS
.github/workflows/store-version.sh install/llvm-mingw/versions.txt
./copy-msys-dependencies.sh $(pwd)/install/llvm-mingw ${{matrix.sys}}
./test-libcxx-module.sh $(pwd)/install/llvm-mingw
NATIVE=1 ./test-libcxx-module.sh $(pwd)/install/llvm-mingw
./run-tests.sh $(pwd)/install/llvm-mingw
cd install
NAME=llvm-mingw-$TAG-ucrt-msys2-${{matrix.sys}}
Expand Down Expand Up @@ -362,7 +362,7 @@ jobs:
- uses: actions/checkout@v4
- name: Run tests
run: |
./test-libcxx-module.sh /llvm-mingw
NATIVE=1 ./test-libcxx-module.sh /llvm-mingw
./run-tests.sh /llvm-mingw
./run-lldb-tests.sh /llvm-mingw
Expand Down
6 changes: 6 additions & 0 deletions test-libcxx-module.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,10 @@ for arch in $ARCHS; do
# 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.
$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
$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
$arch-w64-mingw32-clang-scan-deps -format=p1689 -- $arch-w64-mingw32-clang++ -std=c++23 -c test/test-scan-deps.cpp -DEXPECT_$arch
done

if [ -n "$NATIVE" ]; then
# Test the unprefixed clang-scan-deps wrapper.
clang-scan-deps -format=p1689 -- clang++ -std=c++23 -c test/test-scan-deps.cpp -DEXPECT_$(clang++ -dumpmachine | sed 's/-.*//')
fi
39 changes: 39 additions & 0 deletions test/test-scan-deps.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2024 Martin Storsjo
*
* This file is part of llvm-mingw.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

// Test that clang-scan-deps can locate c++ standard library headers
#include <version>

// Test that we have set the expected architecture defines.
#if defined(__x86_64__)
#ifndef EXPECT_x86_64
#include <intentionally-missing-header>
#endif
#elif defined(__i386__)
#ifndef EXPECT_i686
#include <intentionally-missing-header>
#endif
#elif defined(__aarch64__)
#ifndef EXPECT_aarch64
#include <intentionally-missing-header>
#endif
#elif defined(__arm__)
#ifndef EXPECT_armv7
#include <intentionally-missing-header>
#endif
#endif

0 comments on commit 6c748d2

Please sign in to comment.