Skip to content

Commit cb4029a

Browse files
committed
dev
1 parent 3f21ce8 commit cb4029a

File tree

4 files changed

+154
-95
lines changed

4 files changed

+154
-95
lines changed

.github/workflows/ci.yml

Lines changed: 143 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -25,114 +25,165 @@ env:
2525

2626
defaults:
2727
run:
28-
shell: bash
28+
shell: bash --noprofile --norc -CeEuxo pipefail {0}
2929

3030
concurrency:
3131
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
3232
cancel-in-progress: true
3333

3434
jobs:
35-
deny:
36-
uses: taiki-e/github-actions/.github/workflows/deny.yml@main
37-
miri:
38-
uses: taiki-e/github-actions/.github/workflows/miri.yml@main
39-
msrv:
40-
uses: taiki-e/github-actions/.github/workflows/msrv.yml@main
41-
with:
42-
event_name: ${{ github.event_name }}
43-
release-dry-run:
44-
uses: taiki-e/github-actions/.github/workflows/release-dry-run.yml@main
45-
tidy:
46-
uses: taiki-e/github-actions/.github/workflows/tidy.yml@main
35+
# deny:
36+
# uses: taiki-e/github-actions/.github/workflows/deny.yml@main
37+
# miri:
38+
# uses: taiki-e/github-actions/.github/workflows/miri.yml@main
39+
# msrv:
40+
# uses: taiki-e/github-actions/.github/workflows/msrv.yml@main
41+
# with:
42+
# event_name: ${{ github.event_name }}
43+
# release-dry-run:
44+
# uses: taiki-e/github-actions/.github/workflows/release-dry-run.yml@main
45+
# tidy:
46+
# uses: taiki-e/github-actions/.github/workflows/tidy.yml@main
4747

48-
test:
48+
# test:
49+
# strategy:
50+
# fail-fast: false
51+
# matrix:
52+
# include:
53+
# # TODO: nightly-2023-04-27 (https://github.com/rust-lang/rust/pull/97368)
54+
# # and nightly-2023-05-03 (https://github.com/rust-lang/rust/pull/111042)
55+
# # fixed bugs in report generation, so the latest report is not the
56+
# # same as the old report.
57+
# # - rust: '1.60'
58+
# - rust: stable
59+
# - rust: beta
60+
# - rust: nightly
61+
# - rust: nightly
62+
# os: macos-latest
63+
# - rust: nightly
64+
# os: windows-latest
65+
# runs-on: ${{ matrix.os || 'ubuntu-latest' }}
66+
# timeout-minutes: 60
67+
# steps:
68+
# - uses: taiki-e/checkout-action@v1
69+
# - name: Install Rust
70+
# run: rustup toolchain add "${{ matrix.rust }}" --no-self-update && rustup default "${{ matrix.rust }}"
71+
# - run: rustup toolchain add nightly --no-self-update
72+
# - uses: taiki-e/install-action@cargo-hack
73+
# - uses: taiki-e/install-action@cargo-minimal-versions
74+
# - uses: taiki-e/install-action@nextest
75+
# - run: cargo test --workspace --all-features
76+
# # TODO: move this test to tests/test.rs
77+
# - run: cargo install --path . --debug
78+
# - name: Test cargo llvm-cov nextest
79+
# run: |
80+
# cargo llvm-cov nextest --text --fail-under-lines 50
81+
# cargo llvm-cov nextest --text --fail-under-lines 50 --profile default --cargo-profile dev
82+
# cargo llvm-cov nextest --text --fail-under-lines 50 --profile ci
83+
# cargo llvm-cov nextest --text --fail-under-lines 50 --profile ci --cargo-profile dev
84+
# cd -- ../real1
85+
# cargo llvm-cov nextest-archive --archive-file a.tar.zst
86+
# cargo llvm-cov nextest --archive-file a.tar.zst --text --fail-under-lines 70
87+
# cargo llvm-cov report --nextest-archive-file a.tar.zst --fail-under-lines 70
88+
# rm -- a.tar.zst
89+
# cargo clean
90+
# cargo llvm-cov nextest-archive --archive-file a.tar.zst --release
91+
# cargo llvm-cov nextest --archive-file a.tar.zst --text --fail-under-lines 70
92+
# cargo llvm-cov report --nextest-archive-file a.tar.zst --fail-under-lines 70
93+
# rm -- a.tar.zst
94+
# cargo clean
95+
# cargo llvm-cov nextest-archive --archive-file a.tar.zst --cargo-profile custom
96+
# cargo llvm-cov nextest --archive-file a.tar.zst --text --fail-under-lines 70
97+
# cargo llvm-cov report --nextest-archive-file a.tar.zst --fail-under-lines 70
98+
# rm -- a.tar.zst
99+
# cargo clean
100+
# host=$(rustc -vV | grep -E '^host:' | cut -d' ' -f2)
101+
# cargo llvm-cov nextest-archive --archive-file a.tar.zst --target "${host}"
102+
# cargo llvm-cov nextest --archive-file a.tar.zst --text --fail-under-lines 70
103+
# cargo llvm-cov report --nextest-archive-file a.tar.zst --fail-under-lines 70
104+
# working-directory: tests/fixtures/crates/bin_crate
105+
# - name: Test nightly-specific options, old Cargo compatibility, trybuild compatibility
106+
# run: |
107+
# unset RUSTFLAGS
108+
109+
# # Test nightly-specific options
110+
# git clone https://github.com/taiki-e/easytime.git
111+
# pushd -- easytime >/dev/null
112+
# git checkout 7ecb6e6
113+
# cargo llvm-cov test --doctests --text --fail-under-lines 30
114+
# popd >/dev/null
115+
# pushd -- tests/fixtures/crates/cargo_config >/dev/null
116+
# # TODO: --fail-under-branches?
117+
# cargo llvm-cov test --branch --text --fail-under-lines 80
118+
# popd >/dev/null
119+
# pushd -- easytime >/dev/null
120+
# cargo llvm-cov test --branch --doctests --text --fail-under-lines 30
121+
# popd >/dev/null
122+
123+
# # Test minimum runnable Cargo version.
124+
# rustup toolchain add 1.60 --no-self-update
125+
# pushd -- easytime >/dev/null
126+
# cargo +1.60 llvm-cov test --text --fail-under-lines 30
127+
# popd >/dev/null
128+
129+
# # Test trybuild compatibility.
130+
# git clone --depth 1 https://github.com/taiki-e/easy-ext.git
131+
# pushd -- easy-ext >/dev/null
132+
# cargo llvm-cov --text --test compiletest --fail-under-lines 70
133+
# popd >/dev/null
134+
# if: startsWith(matrix.rust, 'nightly')
135+
# - run: cargo hack build --workspace --no-private --feature-powerset --no-dev-deps
136+
# - run: cargo minimal-versions build --workspace --no-private --detach-path-deps=skip-exact --all-features
137+
138+
test-ffi:
49139
strategy:
50140
fail-fast: false
51141
matrix:
52142
include:
53-
# TODO: nightly-2023-04-27 (https://github.com/rust-lang/rust/pull/97368)
54-
# and nightly-2023-05-03 (https://github.com/rust-lang/rust/pull/111042)
55-
# fixed bugs in report generation, so the latest report is not the
56-
# same as the old report.
57-
# - rust: '1.60'
58-
- rust: stable
59-
- rust: beta
60-
- rust: nightly
61-
- rust: nightly
62-
os: macos-latest
63-
- rust: nightly
64-
os: windows-latest
65-
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
143+
# https://github.com/rust-lang/rust/blob/1.60.0/src/bootstrap/native.rs#L403
144+
- llvm: '12'
145+
- llvm: '13'
146+
- llvm: '14'
147+
- llvm: '15'
148+
- llvm: '16'
149+
- llvm: '17'
150+
- llvm: '18'
151+
runs-on: ubuntu-latest
66152
timeout-minutes: 60
67153
steps:
68154
- uses: taiki-e/checkout-action@v1
69155
- name: Install Rust
70-
run: rustup toolchain add ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }}
71-
- run: rustup toolchain add nightly --no-self-update
72-
- uses: taiki-e/install-action@cargo-hack
73-
- uses: taiki-e/install-action@cargo-minimal-versions
74-
- uses: taiki-e/install-action@nextest
75-
- run: cargo test --workspace --all-features
76-
# TODO: move this test to tests/test.rs
156+
run: rustup update stable --no-self-update
157+
- name: Install LLVM
158+
run: |
159+
if type -P clang-"${{ matrix.llvm }}" &>/dev/null; then
160+
exit 0
161+
fi
162+
codename=$(grep -E '^VERSION_CODENAME=' /etc/os-release | cut -d= -f2)
163+
sudo mkdir -pm755 -- /etc/apt/keyrings
164+
curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused https://apt.llvm.org/llvm-snapshot.gpg.key \
165+
| gpg --dearmor \
166+
| sudo tee -- /etc/apt/keyrings/llvm-snapshot.gpg >/dev/null
167+
echo "deb [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] http://apt.llvm.org/${codename}/ llvm-toolchain-${codename}-${{ matrix.llvm }} main" \
168+
| sudo tee -- "/etc/apt/sources.list.d/llvm-toolchain-${codename}-${{ matrix.llvm }}.list" >/dev/null
169+
sudo apt-get -o Acquire::Retries=10 -qq update && sudo apt-get -o Acquire::Retries=10 -o Dpkg::Use-Pty=0 install -y --no-install-recommends \
170+
clang-"${{ matrix.llvm }}" \
171+
libc++-"${{ matrix.llvm }}"-dev \
172+
libc++abi-"${{ matrix.llvm }}"-dev \
173+
libclang-"${{ matrix.llvm }}"-dev \
174+
lld-"${{ matrix.llvm }}" \
175+
llvm-"${{ matrix.llvm }}" \
176+
llvm-"${{ matrix.llvm }}"-dev
77177
- run: cargo install --path . --debug
78-
- name: Test cargo llvm-cov nextest
178+
- name: Test
79179
run: |
80-
set -eEuxo pipefail
81-
cargo llvm-cov nextest --text --fail-under-lines 50
82-
cargo llvm-cov nextest --text --fail-under-lines 50 --profile default --cargo-profile dev
83-
cargo llvm-cov nextest --text --fail-under-lines 50 --profile ci
84-
cargo llvm-cov nextest --text --fail-under-lines 50 --profile ci --cargo-profile dev
85-
cd ../real1
86-
cargo llvm-cov nextest-archive --archive-file a.tar.zst
87-
cargo llvm-cov nextest --archive-file a.tar.zst --text --fail-under-lines 70
88-
cargo llvm-cov report --nextest-archive-file a.tar.zst --fail-under-lines 70
89-
rm a.tar.zst
90-
cargo clean
91-
cargo llvm-cov nextest-archive --archive-file a.tar.zst --release
92-
cargo llvm-cov nextest --archive-file a.tar.zst --text --fail-under-lines 70
93-
cargo llvm-cov report --nextest-archive-file a.tar.zst --fail-under-lines 70
94-
rm a.tar.zst
180+
export CC="clang-${{ matrix.llvm }}"
181+
export CXX="clang++-${{ matrix.llvm }}"
182+
export LLVM_COV="llvm-cov-${{ matrix.llvm }}"
183+
export LLVM_PROFDATA="llvm-profdata-${{ matrix.llvm }}"
184+
rustup toolchain add 1.60 --no-self-update
95185
cargo clean
96-
cargo llvm-cov nextest-archive --archive-file a.tar.zst --cargo-profile custom
97-
cargo llvm-cov nextest --archive-file a.tar.zst --text --fail-under-lines 70
98-
cargo llvm-cov report --nextest-archive-file a.tar.zst --fail-under-lines 70
99-
rm a.tar.zst
186+
cargo +1.60 llvm-cov test --text --include-ffi --fail-under-lines 70 -vv
100187
cargo clean
101-
host=$(rustc -vV | grep '^host:' | cut -d' ' -f2)
102-
cargo llvm-cov nextest-archive --archive-file a.tar.zst --target "${host}"
103-
cargo llvm-cov nextest --archive-file a.tar.zst --text --fail-under-lines 70
104-
cargo llvm-cov report --nextest-archive-file a.tar.zst --fail-under-lines 70
105-
working-directory: tests/fixtures/crates/bin_crate
106-
- name: Test nightly-specific options, old Cargo compatibility, trybuild compatibility
107-
run: |
108-
set -eEuxo pipefail
109-
unset RUSTFLAGS
110-
111-
# Test nightly-specific options
112-
git clone https://github.com/taiki-e/easytime.git
113-
pushd easytime >/dev/null
114-
git checkout 7ecb6e6
115-
cargo llvm-cov test --doctests --text --fail-under-lines 30
116-
popd >/dev/null
117-
pushd tests/fixtures/crates/cargo_config >/dev/null
118-
# TODO: --fail-under-branches?
119-
cargo llvm-cov test --branch --text --fail-under-lines 80
120-
popd >/dev/null
121-
pushd easytime >/dev/null
122-
cargo llvm-cov test --branch --doctests --text --fail-under-lines 30
123-
popd >/dev/null
124-
125-
# Test minimum runnable Cargo version.
126-
rustup toolchain add 1.60 --no-self-update
127-
pushd easytime >/dev/null
128-
cargo +1.60 llvm-cov test --text --fail-under-lines 30
129-
popd >/dev/null
130-
131-
# Test trybuild compatibility.
132-
git clone --depth 1 https://github.com/taiki-e/easy-ext.git
133-
pushd easy-ext >/dev/null
134-
cargo llvm-cov --text --test compiletest --fail-under-lines 70
135-
popd >/dev/null
136-
if: startsWith(matrix.rust, 'nightly')
137-
- run: cargo hack build --workspace --no-private --feature-powerset --no-dev-deps
138-
- run: cargo minimal-versions build --workspace --no-private --detach-path-deps=skip-exact --all-features
188+
cargo +stable llvm-cov test --text --include-ffi --fail-under-lines 70 -vv
189+
working-directory: tests/fixtures/crates/ffi

tests/fixtures/crates/ffi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ edition = "2021"
55
publish = false
66

77
[build-dependencies]
8-
cc = "1"
8+
cc = "=1.0.83"
99

1010
[workspace]

tests/fixtures/crates/ffi/hello_c.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include <stdio.h>
22

33
void hello_c() {
4-
printf("Hello C from Rust!\n");
4+
if (1) {
5+
printf("Hello C from Rust!\n");
6+
} else {
7+
printf("this line in C is not covered\n");
8+
}
59
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include <iostream>
22

33
extern "C" void hello_cpp() {
4-
std::cout << "Hello C++ from Rust!" << std::endl;
4+
if (1) {
5+
std::cout << "Hello C++ from Rust!" << std::endl;
6+
} else {
7+
std::cout << "this line in C++ is not covered" << std::endl;
8+
}
59
}

0 commit comments

Comments
 (0)