Skip to content

Commit c428a96

Browse files
committed
Support ui_test
This also moves trybuild test to tests/test.rs.
1 parent a8e590c commit c428a96

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+674
-31
lines changed

.github/.cspell/project-dictionary.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
autocfg
22
bindeps
33
binstall
4-
compiletest
54
demangler
65
doctestbins
76
easytime
@@ -24,7 +23,6 @@ rmeta
2423
rustfilt
2524
rustix
2625
TESTNAME
27-
trybuild
2826
winapi
2927
xargo
3028
Xdemangler

.github/.cspell/rust-dependencies.txt

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/dependabot.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
version: 2
22
updates:
33
- package-ecosystem: cargo
4-
directory: /
4+
directories:
5+
- /
6+
# crates with [workspace] table are not recognized by the above 'directory: /'
7+
- /tests/fixtures/crates/trybuild
8+
- /tests/fixtures/crates/ui_test
59
schedule:
610
interval: daily
711
commit-message:

.github/workflows/ci.yml

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobs:
127127
cargo llvm-cov nextest --text --fail-under-lines 100 --profile ci --cargo-profile dev
128128
cargo clean
129129
working-directory: tests/fixtures/crates/bin_crate
130-
- name: Test nightly-specific options, old Cargo compatibility, trybuild compatibility
130+
- name: Test nightly-specific options, old Cargo compatibility
131131
run: |
132132
retry() {
133133
for i in {1..10}; do
@@ -140,11 +140,6 @@ jobs:
140140
"$@"
141141
}
142142
unset RUSTFLAGS
143-
if { sed --help 2>&1 || true; } | grep -Eq -e '-i extension'; then
144-
in_place=(-i '')
145-
else
146-
in_place=(-i)
147-
fi
148143
target="${{ matrix.target }}"
149144
if [[ -z "${target}" ]]; then
150145
target=$(rustc -vV | grep -E '^host:' | cut -d' ' -f2)
@@ -177,25 +172,6 @@ jobs:
177172
popd >/dev/null
178173
;;
179174
esac
180-
181-
# Test trybuild compatibility.
182-
case "${{ matrix.target }}" in
183-
aarch64-pc-windows-gnullvm) ;; # coverage is not supported yet on host (aarch64-pc-windows-msvc).
184-
*)
185-
retry git clone --depth 1 https://github.com/taiki-e/easy-ext.git
186-
pushd -- easy-ext >/dev/null
187-
cargo llvm-cov --test compiletest --fail-under-lines 70
188-
cargo clean
189-
cargo llvm-cov --test compiletest --fail-under-lines 70 --target "${target}"
190-
cargo clean
191-
sed -E "${in_place[@]}" 's/trybuild = .*/trybuild = "1"/g' Cargo.toml # easy-ext uses patched trybuild
192-
cargo llvm-cov --test compiletest --fail-under-lines 70
193-
cargo clean
194-
cargo llvm-cov --test compiletest --fail-under-lines 70 --target "${target}"
195-
cargo clean
196-
popd >/dev/null
197-
;;
198-
esac
199175
if: startsWith(matrix.rust, 'nightly')
200176
- name: Test --dep-coverage
201177
run: |

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
1212

1313
## [Unreleased]
1414

15+
- Support [`ui_test`](https://github.com/oli-obk/ui_test). ([#477](https://github.com/taiki-e/cargo-llvm-cov/pull/477))
16+
1517
## [0.8.1] - 2026-01-26
1618

1719
- Back "cargo-llvm-cov subcommands other than report and clean may not work correctly ..." error to warning.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ termcolor = "1"
4343
walkdir = "2.2.3"
4444

4545
[dev-dependencies]
46+
build-context = "0.1"
4647
rustversion = "1"
4748
tempfile = { version = "3", default-features = false }
4849
test-helper = { features = ["cli", "doc", "git"], git = "https://github.com/taiki-e/test-helper.git", rev = "f38a7f5" }

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This is a wrapper around rustc [`-C instrument-coverage`][instrument-coverage] a
1010

1111
- Generate very precise coverage data. (line, region, and branch coverage. branch coverage is currently optional and requires nightly, see [#8] for more)
1212
- Support `cargo test`, `cargo run`, and [`cargo nextest`][nextest] with command-line interface compatible with cargo.
13-
- Support for proc-macro, including coverage of UI tests.
13+
- Support for proc-macro, including coverage of UI tests ([trybuild](https://github.com/dtolnay/trybuild), [ui_test](https://github.com/oli-obk/ui_test)).
1414
- Support for doc tests. (this is currently optional and requires nightly, see [#2] for more)
1515
- Fast because it does not introduce extra layers between rustc, cargo, and llvm-tools.
1616

src/cargo.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ impl Workspace {
192192
}
193193
trybuild_target_dir
194194
}
195+
196+
pub(crate) fn ui_test_target_dir(&self) -> Utf8PathBuf {
197+
// https://github.com/oli-obk/ui_test/blob/0.30.4/src/config.rs#L180
198+
self.metadata.target_directory.join("ui")
199+
}
195200
}
196201

197202
// https://doc.rust-lang.org/nightly/cargo/commands/cargo-locate-project.html

src/clean.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ fn clean_ws_inner(
149149
rm_rf(&ws.profdata_file, verbose)?;
150150

151151
clean_trybuild_artifacts(ws, pkg_ids, verbose)?;
152+
clean_ui_test_artifacts(ws, verbose)?;
152153
Ok(())
153154
}
154155

@@ -186,6 +187,12 @@ fn clean_trybuild_artifacts(ws: &Workspace, pkg_ids: &[PackageId], verbose: bool
186187
Ok(())
187188
}
188189

190+
fn clean_ui_test_artifacts(ws: &Workspace, verbose: bool) -> Result<()> {
191+
let ui_test_target_dir = ws.ui_test_target_dir();
192+
rm_rf(ui_test_target_dir, verbose)?;
193+
Ok(())
194+
}
195+
189196
fn rm_rf(path: impl AsRef<Path>, verbose: bool) -> Result<()> {
190197
let path = path.as_ref();
191198
// Using std::fs instead of fs-err is okay here since we ignore error contents

src/main.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,23 @@ fn object_files(cx: &Context) -> Result<Vec<OsString>> {
10061006
}
10071007
collect_trybuild_target_dir(trybuild_target_dir)?;
10081008

1009+
// ui_test
1010+
let ui_test_target_dir = cx.ws.ui_test_target_dir();
1011+
let mut collect_ui_test_target_dir = |ui_test_target_dir: Utf8PathBuf| -> Result<()> {
1012+
if ui_test_target_dir.is_dir() {
1013+
for entry in walk_target_dir(cx, &ui_test_target_dir) {
1014+
let path = make_relative(cx, entry.path());
1015+
if is_object(cx, path) {
1016+
files.push(path.to_owned().into_os_string());
1017+
}
1018+
}
1019+
searched_dir.push(',');
1020+
searched_dir.push_str(ui_test_target_dir.as_str());
1021+
}
1022+
Ok(())
1023+
};
1024+
collect_ui_test_target_dir(ui_test_target_dir)?;
1025+
10091026
// This sort is necessary to make the result of `llvm-cov show` match between macOS and Linux.
10101027
files.sort_unstable();
10111028

0 commit comments

Comments
 (0)