Skip to content

Commit 1dc2438

Browse files
authored
chore: Use nextest for miri test runs (#758)
1 parent 2308261 commit 1dc2438

File tree

8 files changed

+55
-64
lines changed

8 files changed

+55
-64
lines changed

.github/workflows/test.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
with:
4242
toolchain: ${{ matrix.rust }}
4343
components: rustfmt, clippy
44+
- uses: taiki-e/install-action@nextest
4445
- uses: actions/cache@v4
4546
with:
4647
path: |
@@ -58,7 +59,7 @@ jobs:
5859
- name: Clippy
5960
run: cargo clippy --workspace --all-features --all-targets -- -D warnings
6061
- name: Test
61-
run: cargo test --workspace --all-features --all-targets
62+
run: cargo nextest run --workspace --all-features --all-targets --no-fail-fast
6263
- name: Test docs
6364
run: cargo test --workspace --all-features --doc
6465
- name: Check (without default features)
@@ -73,6 +74,7 @@ jobs:
7374
- name: Install Miri
7475
uses: dtolnay/rust-toolchain@miri
7576
id: rust-toolchain
77+
- uses: taiki-e/install-action@nextest
7678
- uses: actions/cache@v4
7779
with:
7880
path: |
@@ -89,12 +91,11 @@ jobs:
8991
- name: Setup Miri
9092
run: cargo miri setup
9193
- name: Test with Miri
92-
run: cargo miri test --no-fail-fast --all-features
94+
run: cargo miri nextest run --all-features --no-fail-fast --tests
9395
env:
9496
MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-retag-fields
9597
- name: Run examples with Miri
96-
run: |
97-
cargo miri run --example calc
98+
run: cargo miri run --example calc
9899

99100
benchmarks:
100101
# https://github.com/CodSpeedHQ/action/issues/126

benches/dataflow.rs

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use salsa::{CycleRecoveryAction, Database as Db, Setter};
77
use std::collections::BTreeSet;
88
use std::iter::IntoIterator;
99

10+
include!("shims/global_alloc_overwrite.rs");
11+
1012
/// A Use of a symbol.
1113
#[salsa::input]
1214
struct Use {

examples/calc/type_check.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<'db> CheckExpression<'_, 'db> {
108108
fn check_string(
109109
source_text: &str,
110110
expected_diagnostics: expect_test::Expect,
111-
edits: &[(&str, expect_test::Expect, expect_test::Expect)],
111+
edits: &[(&str, expect_test::Expect)],
112112
) {
113113
use salsa::{Database, Setter};
114114

@@ -135,11 +135,8 @@ fn check_string(
135135
expected_diagnostics.assert_eq(&rendered_diagnostics);
136136
});
137137

138-
// Clear logs
139-
db.take_logs();
140-
141138
// Apply edits and check diagnostics/logs after each one
142-
for (new_source_text, expected_diagnostics, expected_logs) in edits {
139+
for (new_source_text, expected_diagnostics) in edits {
143140
source_program
144141
.set_text(&mut db)
145142
.to(new_source_text.to_string());
@@ -149,8 +146,6 @@ fn check_string(
149146
expected_diagnostics
150147
.assert_debug_eq(&type_check_program::accumulated::<Diagnostic>(db, program));
151148
});
152-
153-
expected_logs.assert_debug_eq(&db.take_logs());
154149
}
155150
}
156151

@@ -267,12 +262,6 @@ fn fix_bad_variable_in_function() {
267262
expect![[r#"
268263
[]
269264
"#]],
270-
expect![[r#"
271-
[
272-
"Event: Event { thread_id: ThreadId(11), kind: WillExecute { database_key: parse_statements(Id(0)) } }",
273-
"Event: Event { thread_id: ThreadId(11), kind: WillExecute { database_key: type_check_function(Id(1800)) } }",
274-
]
275-
"#]],
276265
)],
277266
);
278267
}

src/revision.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ mod tests {
126126
use super::*;
127127

128128
#[test]
129-
fn pptional_atomic_revision() {
129+
fn optional_atomic_revision() {
130130
let val = OptionalAtomicRevision::new(Some(Revision::start()));
131131
assert_eq!(val.load(), Some(Revision::start()));
132132
assert_eq!(val.swap(None), Some(Revision::start()));

tests/cycle.rs

+26-24
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mod common;
66
use common::{ExecuteValidateLoggerDatabase, LogDatabase};
77
use expect_test::expect;
88
use salsa::{CycleRecoveryAction, Database as Db, DatabaseImpl as DbImpl, Durability, Setter};
9+
#[cfg(not(miri))]
910
use test_log::test;
1011

1112
#[derive(Clone, Copy, Debug, PartialEq, Eq, salsa::Update)]
@@ -31,12 +32,13 @@ impl Value {
3132
/// `max_iterate`, `min_panic`, `max_panic`) for testing cycle behaviors.
3233
#[salsa::input]
3334
struct Inputs {
35+
#[return_ref]
3436
inputs: Vec<Input>,
3537
}
3638

3739
impl Inputs {
3840
fn values(self, db: &dyn Db) -> impl Iterator<Item = Value> + '_ {
39-
self.inputs(db).into_iter().map(|input| input.eval(db))
41+
self.inputs(db).iter().map(|input| input.eval(db))
4042
}
4143
}
4244

@@ -69,8 +71,8 @@ enum Input {
6971
}
7072

7173
impl Input {
72-
fn eval(self, db: &dyn Db) -> Value {
73-
match self {
74+
fn eval(&self, db: &dyn Db) -> Value {
75+
match *self {
7476
Self::Value(value) => value,
7577
Self::UntrackedRead(value) => {
7678
db.report_untracked_read();
@@ -80,30 +82,30 @@ impl Input {
8082
Self::MaxIterate(inputs) => max_iterate(db, inputs),
8183
Self::MinPanic(inputs) => min_panic(db, inputs),
8284
Self::MaxPanic(inputs) => max_panic(db, inputs),
83-
Self::Successor(input) => match input.eval(db) {
85+
Self::Successor(ref input) => match input.eval(db) {
8486
Value::N(num) => Value::N(num + 1),
8587
other => other,
8688
},
87-
Self::SuccessorOrZero(input) => match input.eval(db) {
89+
Self::SuccessorOrZero(ref input) => match input.eval(db) {
8890
Value::N(num) => Value::N(num + 1),
8991
_ => Value::N(0),
9092
},
9193
}
9294
}
9395

94-
fn assert(self, db: &dyn Db, expected: Value) {
96+
fn assert(&self, db: &dyn Db, expected: Value) {
9597
assert_eq!(self.eval(db), expected)
9698
}
9799

98-
fn assert_value(self, db: &dyn Db, expected: u8) {
100+
fn assert_value(&self, db: &dyn Db, expected: u8) {
99101
self.assert(db, Value::N(expected))
100102
}
101103

102-
fn assert_bounds(self, db: &dyn Db) {
104+
fn assert_bounds(&self, db: &dyn Db) {
103105
self.assert(db, Value::OutOfBounds)
104106
}
105107

106-
fn assert_count(self, db: &dyn Db) {
108+
fn assert_count(&self, db: &dyn Db) {
107109
self.assert(db, Value::TooManyIterations)
108110
}
109111
}
@@ -734,7 +736,7 @@ fn cycle_becomes_non_cycle() {
734736
a_in.set_inputs(&mut db).to(vec![b]);
735737
b_in.set_inputs(&mut db).to(vec![a.clone()]);
736738

737-
a.clone().assert_value(&db, 255);
739+
a.assert_value(&db, 255);
738740

739741
b_in.set_inputs(&mut db).to(vec![value(30)]);
740742

@@ -758,7 +760,7 @@ fn non_cycle_becomes_cycle() {
758760
a_in.set_inputs(&mut db).to(vec![b]);
759761
b_in.set_inputs(&mut db).to(vec![value(30)]);
760762

761-
a.clone().assert_value(&db, 30);
763+
a.assert_value(&db, 30);
762764

763765
b_in.set_inputs(&mut db).to(vec![a.clone()]);
764766

@@ -790,7 +792,7 @@ fn nested_double_multiple_revisions() {
790792
Input::Successor(Box::new(b.clone())),
791793
]);
792794

793-
a.clone().assert_count(&db);
795+
a.assert_count(&db);
794796

795797
// next revision, we hit max value instead
796798
c_in.set_inputs(&mut db).to(vec![
@@ -799,13 +801,13 @@ fn nested_double_multiple_revisions() {
799801
Input::Successor(Box::new(b.clone())),
800802
]);
801803

802-
a.clone().assert_bounds(&db);
804+
a.assert_bounds(&db);
803805

804806
// and next revision, we converge
805807
c_in.set_inputs(&mut db)
806808
.to(vec![value(240), a.clone(), b.clone()]);
807809

808-
a.clone().assert_value(&db, 240);
810+
a.assert_value(&db, 240);
809811

810812
// one more revision, without relevant changes
811813
a_in.set_inputs(&mut db).to(vec![b]);
@@ -838,7 +840,7 @@ fn cycle_durability() {
838840
.with_durability(Durability::HIGH)
839841
.to(vec![a.clone()]);
840842

841-
a.clone().assert_value(&db, 255);
843+
a.assert_value(&db, 255);
842844

843845
// next revision, we converge instead
844846
a_in.set_inputs(&mut db)
@@ -866,8 +868,8 @@ fn cycle_unchanged() {
866868
b_in.set_inputs(&mut db).to(vec![value(60), c]);
867869
c_in.set_inputs(&mut db).to(vec![b.clone()]);
868870

869-
a.clone().assert_value(&db, 59);
870-
b.clone().assert_value(&db, 60);
871+
a.assert_value(&db, 59);
872+
b.assert_value(&db, 60);
871873

872874
db.assert_logs_len(4);
873875

@@ -912,8 +914,8 @@ fn cycle_unchanged_nested() {
912914
.to(vec![value(61), b.clone(), e.clone()]);
913915
e_in.set_inputs(&mut db).to(vec![d.clone()]);
914916

915-
a.clone().assert_value(&db, 59);
916-
b.clone().assert_value(&db, 60);
917+
a.assert_value(&db, 59);
918+
b.assert_value(&db, 60);
917919

918920
db.assert_logs_len(10);
919921

@@ -965,8 +967,8 @@ fn cycle_unchanged_nested_intertwined() {
965967
.to(vec![value(61), b.clone(), e.clone()]);
966968
e_in.set_inputs(&mut db).to(vec![d.clone()]);
967969

968-
a.clone().assert_value(&db, 59);
969-
b.clone().assert_value(&db, 60);
970+
a.assert_value(&db, 59);
971+
b.assert_value(&db, 60);
970972

971973
// First time we run this test, don't fetch c/d/e here; this means they won't get marked
972974
// `verified_final` in R6 (this revision), which will leave us in the next revision (R7)
@@ -977,9 +979,9 @@ fn cycle_unchanged_nested_intertwined() {
977979
// Second time we run this test, fetch everything in R6, to check the behavior of
978980
// `maybe_changed_after` with all validated-final memos.
979981
if i == 1 {
980-
c.clone().assert_value(&db, 60);
981-
d.clone().assert_value(&db, 60);
982-
e.clone().assert_value(&db, 60);
982+
c.assert_value(&db, 60);
983+
d.assert_value(&db, 60);
984+
e.assert_value(&db, 60);
983985
}
984986

985987
db.assert_logs_len(16 + i);

tests/lru.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct MyInput {
3636
field: u32,
3737
}
3838

39-
#[salsa::tracked(lru = 32)]
39+
#[salsa::tracked(lru = 8)]
4040
fn get_hot_potato(db: &dyn LogDatabase, input: MyInput) -> Arc<HotPotato> {
4141
db.push_log(format!("get_hot_potato({:?})", input.field(db)));
4242
Arc::new(HotPotato::new(input.field(db)))
@@ -57,59 +57,59 @@ fn lru_works() {
5757
let mut db = common::LoggerDatabase::default();
5858
assert_eq!(load_n_potatoes(), 0);
5959

60-
for i in 0..128u32 {
60+
for i in 0..32u32 {
6161
let input = MyInput::new(&db, i);
6262
let p = get_hot_potato(&db, input);
6363
assert_eq!(p.0, i);
6464
}
6565

66-
assert_eq!(load_n_potatoes(), 128);
66+
assert_eq!(load_n_potatoes(), 32);
6767
// trigger the GC
6868
db.synthetic_write(salsa::Durability::HIGH);
69-
assert_eq!(load_n_potatoes(), 32);
69+
assert_eq!(load_n_potatoes(), 8);
7070
}
7171

7272
#[test]
7373
fn lru_can_be_changed_at_runtime() {
7474
let mut db = common::LoggerDatabase::default();
7575
assert_eq!(load_n_potatoes(), 0);
7676

77-
let inputs: Vec<(u32, MyInput)> = (0..128).map(|i| (i, MyInput::new(&db, i))).collect();
77+
let inputs: Vec<(u32, MyInput)> = (0..32).map(|i| (i, MyInput::new(&db, i))).collect();
7878

7979
for &(i, input) in inputs.iter() {
8080
let p = get_hot_potato(&db, input);
8181
assert_eq!(p.0, i);
8282
}
8383

84-
assert_eq!(load_n_potatoes(), 128);
84+
assert_eq!(load_n_potatoes(), 32);
8585
// trigger the GC
8686
db.synthetic_write(salsa::Durability::HIGH);
87-
assert_eq!(load_n_potatoes(), 32);
87+
assert_eq!(load_n_potatoes(), 8);
8888

89-
get_hot_potato::set_lru_capacity(&mut db, 64);
90-
assert_eq!(load_n_potatoes(), 32);
89+
get_hot_potato::set_lru_capacity(&mut db, 16);
90+
assert_eq!(load_n_potatoes(), 8);
9191
for &(i, input) in inputs.iter() {
9292
let p = get_hot_potato(&db, input);
9393
assert_eq!(p.0, i);
9494
}
9595

96-
assert_eq!(load_n_potatoes(), 128);
96+
assert_eq!(load_n_potatoes(), 32);
9797
// trigger the GC
9898
db.synthetic_write(salsa::Durability::HIGH);
99-
assert_eq!(load_n_potatoes(), 64);
99+
assert_eq!(load_n_potatoes(), 16);
100100

101101
// Special case: setting capacity to zero disables LRU
102102
get_hot_potato::set_lru_capacity(&mut db, 0);
103-
assert_eq!(load_n_potatoes(), 64);
103+
assert_eq!(load_n_potatoes(), 16);
104104
for &(i, input) in inputs.iter() {
105105
let p = get_hot_potato(&db, input);
106106
assert_eq!(p.0, i);
107107
}
108108

109-
assert_eq!(load_n_potatoes(), 128);
109+
assert_eq!(load_n_potatoes(), 32);
110110
// trigger the GC
111111
db.synthetic_write(salsa::Durability::HIGH);
112-
assert_eq!(load_n_potatoes(), 128);
112+
assert_eq!(load_n_potatoes(), 32);
113113

114114
drop(db);
115115
assert_eq!(load_n_potatoes(), 0);
@@ -118,10 +118,10 @@ fn lru_can_be_changed_at_runtime() {
118118
#[test]
119119
fn lru_keeps_dependency_info() {
120120
let mut db = common::LoggerDatabase::default();
121-
let capacity = 32;
121+
let capacity = 8;
122122

123123
// Invoke `get_hot_potato2` 33 times. This will (in turn) invoke
124-
// `get_hot_potato`, which will trigger LRU after 32 executions.
124+
// `get_hot_potato`, which will trigger LRU after 8 executions.
125125
let inputs: Vec<MyInput> = (0..(capacity + 1))
126126
.map(|i| MyInput::new(&db, i as u32))
127127
.collect();

tests/parallel/cycle_ab_peeping_c.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use crate::setup::{Knobs, KnobsDatabase};
1515
struct CycleValue(u32);
1616

1717
const MIN: CycleValue = CycleValue(0);
18-
const MID: CycleValue = CycleValue(11);
19-
const MAX: CycleValue = CycleValue(22);
18+
const MID: CycleValue = CycleValue(5);
19+
const MAX: CycleValue = CycleValue(10);
2020

2121
#[salsa::tracked(cycle_fn=cycle_fn, cycle_initial=cycle_initial)]
2222
fn query_a(db: &dyn KnobsDatabase) -> CycleValue {

tests/tracked_struct_disambiguates.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,7 @@ fn execute() {
8585
let mut db = salsa::DatabaseImpl::new();
8686
let inputs = MyInputs::new(
8787
&db,
88-
(0..1024)
89-
.into_iter()
90-
.map(|i| MyInput::new(&db, i))
91-
.collect(),
88+
(0..64).into_iter().map(|i| MyInput::new(&db, i)).collect(),
9289
);
9390
let trackeds = batch(&db, inputs);
9491
for (id, tracked) in trackeds.into_iter().enumerate() {

0 commit comments

Comments
 (0)