Skip to content

Commit 3e40fa5

Browse files
committed
Simplify version handling of UI tests.
Due to checking in error outputs these tests only work reliably on stable and not on intermediate version between our MSRV (currently 1.48) and the current stable version. Hence this simplifies things to run only MSRV-compatible tests for the MSRV builds, anything else for stable builds except for those tests which require the nightly feature, i.e. the `Ungil` being distinct from the `Send` trait. Finally, `not_send3` is disabled when using the nightly feature since while `Rc` is not send, it also not GIL-bound and hence can be passed into `allow_threads` as it does not actually spawn a new thread.
1 parent 3ec966d commit 3e40fa5

File tree

2 files changed

+18
-86
lines changed

2 files changed

+18
-86
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ jobs:
5959
name: Prepare minimal package versions (MSRV only)
6060
run: nox -s set-minimal-package-versions
6161

62+
- if: inputs.rust == 'nightly'
63+
name: Ignore changed error messages when using trybuild
64+
run: echo "TRYBUILD=overwrite" >> "$GITHUB_ENV"
65+
6266
- name: Build docs
6367
run: cargo doc --no-deps --no-default-features --features "full ${{ inputs.extra-features }}"
6468

tests/test_compile_error.rs

Lines changed: 14 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,8 @@
11
#![cfg(feature = "macros")]
22

3-
#[rustversion::not(nightly)]
43
#[cfg(not(target_arch = "wasm32"))] // Not possible to invoke compiler from wasm
54
#[test]
65
fn test_compile_errors() {
7-
// stable - require all tests to pass
8-
_test_compile_errors()
9-
}
10-
11-
#[cfg(not(feature = "nightly"))]
12-
#[cfg(not(target_arch = "wasm32"))] // We are building wasm Python with pthreads disabled
13-
#[rustversion::nightly]
14-
#[test]
15-
fn test_compile_errors() {
16-
// nightly - don't care if test output is potentially wrong, to avoid churn in PyO3's CI thanks
17-
// to diagnostics changing on nightly.
18-
let _ = std::panic::catch_unwind(_test_compile_errors);
19-
}
20-
21-
#[cfg(feature = "nightly")]
22-
#[cfg(not(target_arch = "wasm32"))] // Not possible to invoke compiler from wasm
23-
#[rustversion::nightly]
24-
#[test]
25-
fn test_compile_errors() {
26-
// nightly - don't care if test output is potentially wrong, to avoid churn in PyO3's CI thanks
27-
// to diagnostics changing on nightly.
28-
_test_compile_errors()
29-
}
30-
31-
#[cfg(not(feature = "nightly"))]
32-
fn _test_compile_errors() {
336
let t = trybuild::TestCases::new();
347

358
t.compile_fail("tests/ui/invalid_macro_args.rs");
@@ -46,89 +19,44 @@ fn _test_compile_errors() {
4619
t.compile_fail("tests/ui/invalid_pymodule_args.rs");
4720
t.compile_fail("tests/ui/reject_generics.rs");
4821

49-
tests_rust_1_49(&t);
50-
tests_rust_1_56(&t);
51-
tests_rust_1_57(&t);
52-
tests_rust_1_58(&t);
53-
tests_rust_1_60(&t);
54-
tests_rust_1_62(&t);
55-
tests_rust_1_63(&t);
22+
tests_not_msrv(&t);
23+
tests_nightly(&t);
5624

5725
#[rustversion::since(1.49)]
58-
fn tests_rust_1_49(t: &trybuild::TestCases) {
26+
fn tests_not_msrv(t: &trybuild::TestCases) {
5927
t.compile_fail("tests/ui/deprecations.rs");
60-
}
61-
#[rustversion::before(1.49)]
62-
fn tests_rust_1_49(_t: &trybuild::TestCases) {}
63-
64-
#[rustversion::since(1.56)]
65-
fn tests_rust_1_56(t: &trybuild::TestCases) {
6628
t.compile_fail("tests/ui/invalid_closure.rs");
67-
6829
t.compile_fail("tests/ui/pyclass_send.rs");
69-
}
70-
71-
#[rustversion::before(1.56)]
72-
fn tests_rust_1_56(_t: &trybuild::TestCases) {}
73-
74-
#[rustversion::since(1.57)]
75-
fn tests_rust_1_57(t: &trybuild::TestCases) {
7630
t.compile_fail("tests/ui/invalid_argument_attributes.rs");
7731
t.compile_fail("tests/ui/invalid_frompy_derive.rs");
7832
t.compile_fail("tests/ui/static_ref.rs");
7933
t.compile_fail("tests/ui/wrong_aspyref_lifetimes.rs");
80-
}
81-
82-
#[rustversion::before(1.57)]
83-
fn tests_rust_1_57(_t: &trybuild::TestCases) {}
84-
85-
#[rustversion::since(1.58)]
86-
fn tests_rust_1_58(t: &trybuild::TestCases) {
8734
t.compile_fail("tests/ui/invalid_pyfunctions.rs");
8835
t.compile_fail("tests/ui/invalid_pymethods.rs");
8936
#[cfg(Py_LIMITED_API)]
9037
t.compile_fail("tests/ui/abi3_nativetype_inheritance.rs");
91-
}
92-
93-
#[rustversion::before(1.58)]
94-
fn tests_rust_1_58(_t: &trybuild::TestCases) {}
95-
96-
#[rustversion::since(1.60)]
97-
fn tests_rust_1_60(t: &trybuild::TestCases) {
9838
t.compile_fail("tests/ui/invalid_intern_arg.rs");
9939
t.compile_fail("tests/ui/invalid_frozen_pyclass_borrow.rs");
100-
}
101-
102-
#[rustversion::before(1.60)]
103-
fn tests_rust_1_60(_t: &trybuild::TestCases) {}
104-
105-
#[rustversion::since(1.62)]
106-
fn tests_rust_1_62(t: &trybuild::TestCases) {
10740
t.compile_fail("tests/ui/invalid_pymethod_receiver.rs");
10841
t.compile_fail("tests/ui/missing_intopy.rs");
109-
}
110-
111-
#[rustversion::before(1.62)]
112-
fn tests_rust_1_62(_t: &trybuild::TestCases) {}
113-
114-
#[rustversion::since(1.63)]
115-
fn tests_rust_1_63(t: &trybuild::TestCases) {
11642
t.compile_fail("tests/ui/invalid_result_conversion.rs");
11743
t.compile_fail("tests/ui/not_send.rs");
11844
t.compile_fail("tests/ui/not_send2.rs");
45+
#[cfg(not(feature = "nightly"))]
11946
t.compile_fail("tests/ui/not_send3.rs");
12047
t.compile_fail("tests/ui/get_set_all.rs");
12148
}
12249

123-
#[rustversion::before(1.63)]
124-
fn tests_rust_1_63(_t: &trybuild::TestCases) {}
125-
}
50+
#[rustversion::before(1.49)]
51+
fn tests_not_msrv(_t: &trybuild::TestCases) {}
12652

127-
#[cfg(feature = "nightly")]
128-
fn _test_compile_errors() {
129-
let t = trybuild::TestCases::new();
53+
#[cfg(feature = "nightly")]
54+
fn tests_nightly(t: &trybuild::TestCases) {
55+
t.compile_fail("tests/ui/not_send_auto_trait.rs");
56+
t.compile_fail("tests/ui/not_send_auto_trait2.rs");
57+
t.compile_fail("tests/ui/send_wrapper.rs");
58+
}
13059

131-
t.compile_fail("tests/ui/not_send_auto_trait.rs");
132-
t.compile_fail("tests/ui/not_send_auto_trait2.rs");
133-
t.compile_fail("tests/ui/send_wrapper.rs");
60+
#[cfg(not(feature = "nightly"))]
61+
fn tests_nightly(_t: &trybuild::TestCases) {}
13462
}

0 commit comments

Comments
 (0)