2022-08-07 23:20:39 +00:00
|
|
|
#![allow(warnings)]
|
|
|
|
|
2022-08-08 23:54:15 +00:00
|
|
|
use std::panic::{RefUnwindSafe, UnwindSafe};
|
|
|
|
|
|
|
|
use expect_test::expect;
|
2024-07-27 12:29:41 +00:00
|
|
|
use salsa::DatabaseImpl;
|
2022-08-22 13:48:14 +00:00
|
|
|
use salsa::Durability;
|
2022-08-08 23:54:15 +00:00
|
|
|
|
|
|
|
// Axes:
|
|
|
|
//
|
|
|
|
// Threading
|
|
|
|
// * Intra-thread
|
|
|
|
// * Cross-thread -- part of cycle is on one thread, part on another
|
|
|
|
//
|
|
|
|
// Recovery strategies:
|
|
|
|
// * Panic
|
|
|
|
// * Fallback
|
|
|
|
// * Mixed -- multiple strategies within cycle participants
|
|
|
|
//
|
|
|
|
// Across revisions:
|
|
|
|
// * N/A -- only one revision
|
|
|
|
// * Present in new revision, not old
|
|
|
|
// * Present in old revision, not new
|
|
|
|
// * Present in both revisions
|
|
|
|
//
|
|
|
|
// Dependencies
|
|
|
|
// * Tracked
|
|
|
|
// * Untracked -- cycle participant(s) contain untracked reads
|
|
|
|
//
|
|
|
|
// Layers
|
|
|
|
// * Direct -- cycle participant is directly invoked from test
|
|
|
|
// * Indirect -- invoked a query that invokes the cycle
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// | Thread | Recovery | Old, New | Dep style | Layers | Test Name |
|
|
|
|
// | ------ | -------- | -------- | --------- | ------ | --------- |
|
|
|
|
// | Intra | Panic | N/A | Tracked | direct | cycle_memoized |
|
|
|
|
// | Intra | Panic | N/A | Untracked | direct | cycle_volatile |
|
|
|
|
// | Intra | Fallback | N/A | Tracked | direct | cycle_cycle |
|
|
|
|
// | Intra | Fallback | N/A | Tracked | indirect | inner_cycle |
|
|
|
|
// | Intra | Fallback | Both | Tracked | direct | cycle_revalidate |
|
|
|
|
// | Intra | Fallback | New | Tracked | direct | cycle_appears |
|
|
|
|
// | Intra | Fallback | Old | Tracked | direct | cycle_disappears |
|
2022-08-22 13:48:14 +00:00
|
|
|
// | Intra | Fallback | Old | Tracked | direct | cycle_disappears_durability |
|
2022-08-08 23:54:15 +00:00
|
|
|
// | Intra | Mixed | N/A | Tracked | direct | cycle_mixed_1 |
|
|
|
|
// | Intra | Mixed | N/A | Tracked | direct | cycle_mixed_2 |
|
2022-08-09 10:33:46 +00:00
|
|
|
// | Cross | Panic | N/A | Tracked | both | parallel/parallel_cycle_none_recover.rs |
|
|
|
|
// | Cross | Fallback | N/A | Tracked | both | parallel/parallel_cycle_one_recover.rs |
|
|
|
|
// | Cross | Fallback | N/A | Tracked | both | parallel/parallel_cycle_mid_recover.rs |
|
|
|
|
// | Cross | Fallback | N/A | Tracked | both | parallel/parallel_cycle_all_recover.rs |
|
2022-08-09 00:13:21 +00:00
|
|
|
|
2022-08-08 23:54:15 +00:00
|
|
|
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
|
|
|
|
struct Error {
|
|
|
|
cycle: Vec<String>,
|
|
|
|
}
|
|
|
|
|
2024-07-16 10:04:01 +00:00
|
|
|
use salsa::Database as Db;
|
|
|
|
use salsa::Setter;
|
|
|
|
|
|
|
|
#[salsa::input]
|
2022-08-08 23:54:15 +00:00
|
|
|
struct MyInput {}
|
2022-08-07 23:20:39 +00:00
|
|
|
|
2024-07-16 10:04:01 +00:00
|
|
|
#[salsa::tracked]
|
2022-08-08 23:54:15 +00:00
|
|
|
fn memoized_a(db: &dyn Db, input: MyInput) {
|
|
|
|
memoized_b(db, input)
|
2022-08-07 23:20:39 +00:00
|
|
|
}
|
|
|
|
|
2024-07-16 10:04:01 +00:00
|
|
|
#[salsa::tracked]
|
2022-08-08 23:54:15 +00:00
|
|
|
fn memoized_b(db: &dyn Db, input: MyInput) {
|
|
|
|
memoized_a(db, input)
|
2022-08-07 23:20:39 +00:00
|
|
|
}
|
|
|
|
|
2024-07-16 10:04:01 +00:00
|
|
|
#[salsa::tracked]
|
2022-08-08 23:54:15 +00:00
|
|
|
fn volatile_a(db: &dyn Db, input: MyInput) {
|
2022-08-24 22:30:27 +00:00
|
|
|
db.report_untracked_read();
|
2022-08-08 23:54:15 +00:00
|
|
|
volatile_b(db, input)
|
2022-08-08 00:57:29 +00:00
|
|
|
}
|
2022-08-07 23:32:39 +00:00
|
|
|
|
2024-07-16 10:04:01 +00:00
|
|
|
#[salsa::tracked]
|
2022-08-08 23:54:15 +00:00
|
|
|
fn volatile_b(db: &dyn Db, input: MyInput) {
|
2022-08-24 22:30:27 +00:00
|
|
|
db.report_untracked_read();
|
2022-08-08 23:54:15 +00:00
|
|
|
volatile_a(db, input)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// The queries A, B, and C in `Database` can be configured
|
|
|
|
/// to invoke one another in arbitrary ways using this
|
|
|
|
/// enum.
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
|
|
|
enum CycleQuery {
|
|
|
|
None,
|
|
|
|
A,
|
|
|
|
B,
|
|
|
|
C,
|
|
|
|
AthenC,
|
|
|
|
}
|
|
|
|
|
2024-07-16 10:04:01 +00:00
|
|
|
#[salsa::input]
|
2022-08-08 23:54:15 +00:00
|
|
|
struct ABC {
|
|
|
|
a: CycleQuery,
|
|
|
|
b: CycleQuery,
|
|
|
|
c: CycleQuery,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl CycleQuery {
|
|
|
|
fn invoke(self, db: &dyn Db, abc: ABC) -> Result<(), Error> {
|
|
|
|
match self {
|
|
|
|
CycleQuery::A => cycle_a(db, abc),
|
|
|
|
CycleQuery::B => cycle_b(db, abc),
|
|
|
|
CycleQuery::C => cycle_c(db, abc),
|
|
|
|
CycleQuery::AthenC => {
|
|
|
|
let _ = cycle_a(db, abc);
|
|
|
|
cycle_c(db, abc)
|
|
|
|
}
|
|
|
|
CycleQuery::None => Ok(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-16 10:04:01 +00:00
|
|
|
#[salsa::tracked(recovery_fn=recover_a)]
|
2022-08-08 23:54:15 +00:00
|
|
|
fn cycle_a(db: &dyn Db, abc: ABC) -> Result<(), Error> {
|
|
|
|
abc.a(db).invoke(db, abc)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn recover_a(db: &dyn Db, cycle: &salsa::Cycle, abc: ABC) -> Result<(), Error> {
|
|
|
|
Err(Error {
|
2024-07-16 10:04:01 +00:00
|
|
|
cycle: cycle.participant_keys().map(|k| format!("{k:?}")).collect(),
|
2022-08-08 23:54:15 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-07-16 10:04:01 +00:00
|
|
|
#[salsa::tracked(recovery_fn=recover_b)]
|
2022-08-08 23:54:15 +00:00
|
|
|
fn cycle_b(db: &dyn Db, abc: ABC) -> Result<(), Error> {
|
|
|
|
abc.b(db).invoke(db, abc)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn recover_b(db: &dyn Db, cycle: &salsa::Cycle, abc: ABC) -> Result<(), Error> {
|
|
|
|
Err(Error {
|
2024-07-16 10:04:01 +00:00
|
|
|
cycle: cycle.participant_keys().map(|k| format!("{k:?}")).collect(),
|
2022-08-08 23:54:15 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-07-16 10:04:01 +00:00
|
|
|
#[salsa::tracked]
|
2022-08-08 23:54:15 +00:00
|
|
|
fn cycle_c(db: &dyn Db, abc: ABC) -> Result<(), Error> {
|
|
|
|
abc.c(db).invoke(db, abc)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[track_caller]
|
|
|
|
fn extract_cycle(f: impl FnOnce() + UnwindSafe) -> salsa::Cycle {
|
|
|
|
let v = std::panic::catch_unwind(f);
|
|
|
|
if let Err(d) = &v {
|
|
|
|
if let Some(cycle) = d.downcast_ref::<salsa::Cycle>() {
|
|
|
|
return cycle.clone();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
panic!("unexpected value: {:?}", v)
|
2022-08-07 23:20:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2022-08-08 23:54:15 +00:00
|
|
|
fn cycle_memoized() {
|
2024-07-27 12:29:41 +00:00
|
|
|
salsa::DatabaseImpl::new().attach(|db| {
|
2024-07-16 10:04:01 +00:00
|
|
|
let input = MyInput::new(db);
|
|
|
|
let cycle = extract_cycle(|| memoized_a(db, input));
|
|
|
|
let expected = expect![[r#"
|
|
|
|
[
|
2024-08-11 05:08:31 +00:00
|
|
|
memoized_a(Id(0)),
|
|
|
|
memoized_b(Id(0)),
|
2024-07-16 10:04:01 +00:00
|
|
|
]
|
|
|
|
"#]];
|
|
|
|
expected.assert_debug_eq(&cycle.all_participants(db));
|
|
|
|
})
|
2022-08-08 23:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn cycle_volatile() {
|
2024-07-27 12:29:41 +00:00
|
|
|
salsa::DatabaseImpl::new().attach(|db| {
|
2024-07-16 10:04:01 +00:00
|
|
|
let input = MyInput::new(db);
|
|
|
|
let cycle = extract_cycle(|| volatile_a(db, input));
|
|
|
|
let expected = expect![[r#"
|
|
|
|
[
|
2024-08-11 05:08:31 +00:00
|
|
|
volatile_a(Id(0)),
|
|
|
|
volatile_b(Id(0)),
|
2024-07-16 10:04:01 +00:00
|
|
|
]
|
|
|
|
"#]];
|
|
|
|
expected.assert_debug_eq(&cycle.all_participants(db));
|
|
|
|
});
|
2022-08-08 23:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn expect_cycle() {
|
|
|
|
// A --> B
|
|
|
|
// ^ |
|
|
|
|
// +-----+
|
|
|
|
|
2024-07-27 12:29:41 +00:00
|
|
|
salsa::DatabaseImpl::new().attach(|db| {
|
2024-07-16 10:04:01 +00:00
|
|
|
let abc = ABC::new(db, CycleQuery::B, CycleQuery::A, CycleQuery::None);
|
|
|
|
assert!(cycle_a(db, abc).is_err());
|
|
|
|
})
|
2022-08-08 23:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn inner_cycle() {
|
|
|
|
// A --> B <-- C
|
|
|
|
// ^ |
|
|
|
|
// +-----+
|
2024-07-27 12:29:41 +00:00
|
|
|
salsa::DatabaseImpl::new().attach(|db| {
|
2024-07-16 10:04:01 +00:00
|
|
|
let abc = ABC::new(db, CycleQuery::B, CycleQuery::A, CycleQuery::B);
|
|
|
|
let err = cycle_c(db, abc);
|
|
|
|
assert!(err.is_err());
|
|
|
|
let expected = expect![[r#"
|
|
|
|
[
|
2024-08-11 05:08:31 +00:00
|
|
|
"cycle_a(Id(0))",
|
|
|
|
"cycle_b(Id(0))",
|
2024-07-16 10:04:01 +00:00
|
|
|
]
|
|
|
|
"#]];
|
|
|
|
expected.assert_debug_eq(&err.unwrap_err().cycle);
|
|
|
|
})
|
2022-08-08 23:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn cycle_revalidate() {
|
|
|
|
// A --> B
|
|
|
|
// ^ |
|
|
|
|
// +-----+
|
2024-07-27 12:29:41 +00:00
|
|
|
let mut db = salsa::DatabaseImpl::new();
|
2022-09-03 21:48:24 +00:00
|
|
|
let abc = ABC::new(&db, CycleQuery::B, CycleQuery::A, CycleQuery::None);
|
2022-08-08 23:54:15 +00:00
|
|
|
assert!(cycle_a(&db, abc).is_err());
|
2022-08-22 10:32:04 +00:00
|
|
|
abc.set_b(&mut db).to(CycleQuery::A); // same value as default
|
2022-08-08 23:54:15 +00:00
|
|
|
assert!(cycle_a(&db, abc).is_err());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn cycle_recovery_unchanged_twice() {
|
|
|
|
// A --> B
|
|
|
|
// ^ |
|
|
|
|
// +-----+
|
2024-07-27 12:29:41 +00:00
|
|
|
let mut db = salsa::DatabaseImpl::new();
|
2022-09-03 21:48:24 +00:00
|
|
|
let abc = ABC::new(&db, CycleQuery::B, CycleQuery::A, CycleQuery::None);
|
2022-08-08 23:54:15 +00:00
|
|
|
assert!(cycle_a(&db, abc).is_err());
|
|
|
|
|
2022-08-22 10:32:04 +00:00
|
|
|
abc.set_c(&mut db).to(CycleQuery::A); // force new revision
|
2022-08-08 23:54:15 +00:00
|
|
|
assert!(cycle_a(&db, abc).is_err());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn cycle_appears() {
|
2024-07-27 12:29:41 +00:00
|
|
|
let mut db = salsa::DatabaseImpl::new();
|
2022-08-08 23:54:15 +00:00
|
|
|
// A --> B
|
2022-09-03 21:48:24 +00:00
|
|
|
let abc = ABC::new(&db, CycleQuery::B, CycleQuery::None, CycleQuery::None);
|
2022-08-08 23:54:15 +00:00
|
|
|
assert!(cycle_a(&db, abc).is_ok());
|
|
|
|
|
|
|
|
// A --> B
|
|
|
|
// ^ |
|
|
|
|
// +-----+
|
2022-08-22 10:32:04 +00:00
|
|
|
abc.set_b(&mut db).to(CycleQuery::A);
|
2022-08-08 23:54:15 +00:00
|
|
|
assert!(cycle_a(&db, abc).is_err());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn cycle_disappears() {
|
2024-07-27 12:29:41 +00:00
|
|
|
let mut db = salsa::DatabaseImpl::new();
|
2022-08-08 23:54:15 +00:00
|
|
|
|
|
|
|
// A --> B
|
|
|
|
// ^ |
|
|
|
|
// +-----+
|
2022-09-03 21:48:24 +00:00
|
|
|
let abc = ABC::new(&db, CycleQuery::B, CycleQuery::A, CycleQuery::None);
|
2022-08-08 23:54:15 +00:00
|
|
|
assert!(cycle_a(&db, abc).is_err());
|
|
|
|
|
|
|
|
// A --> B
|
2022-08-22 10:32:04 +00:00
|
|
|
abc.set_b(&mut db).to(CycleQuery::None);
|
2022-08-08 23:54:15 +00:00
|
|
|
assert!(cycle_a(&db, abc).is_ok());
|
|
|
|
}
|
|
|
|
|
2022-08-22 13:48:14 +00:00
|
|
|
/// A variant on `cycle_disappears` in which the values of
|
|
|
|
/// `a` and `b` are set with durability values.
|
|
|
|
/// If we are not careful, this could cause us to overlook
|
|
|
|
/// the fact that the cycle will no longer occur.
|
|
|
|
#[test]
|
|
|
|
fn cycle_disappears_durability() {
|
2024-07-27 12:29:41 +00:00
|
|
|
let mut db = salsa::DatabaseImpl::new();
|
2022-08-22 13:48:14 +00:00
|
|
|
let abc = ABC::new(
|
|
|
|
&mut db,
|
|
|
|
CycleQuery::None,
|
|
|
|
CycleQuery::None,
|
|
|
|
CycleQuery::None,
|
|
|
|
);
|
|
|
|
abc.set_a(&mut db)
|
|
|
|
.with_durability(Durability::LOW)
|
|
|
|
.to(CycleQuery::B);
|
|
|
|
abc.set_b(&mut db)
|
|
|
|
.with_durability(Durability::HIGH)
|
|
|
|
.to(CycleQuery::A);
|
|
|
|
|
|
|
|
assert!(cycle_a(&db, abc).is_err());
|
|
|
|
|
|
|
|
// At this point, `a` read `LOW` input, and `b` read `HIGH` input. However,
|
|
|
|
// because `b` participates in the same cycle as `a`, its final durability
|
|
|
|
// should be `LOW`.
|
|
|
|
//
|
|
|
|
// Check that setting a `LOW` input causes us to re-execute `b` query, and
|
|
|
|
// observe that the cycle goes away.
|
|
|
|
abc.set_a(&mut db)
|
|
|
|
.with_durability(Durability::LOW)
|
|
|
|
.to(CycleQuery::None);
|
|
|
|
|
|
|
|
assert!(cycle_b(&mut db, abc).is_ok());
|
|
|
|
}
|
|
|
|
|
2022-08-08 23:54:15 +00:00
|
|
|
#[test]
|
|
|
|
fn cycle_mixed_1() {
|
2024-07-27 12:29:41 +00:00
|
|
|
salsa::DatabaseImpl::new().attach(|db| {
|
2024-07-16 10:04:01 +00:00
|
|
|
// A --> B <-- C
|
|
|
|
// | ^
|
|
|
|
// +-----+
|
|
|
|
let abc = ABC::new(db, CycleQuery::B, CycleQuery::C, CycleQuery::B);
|
2022-08-08 23:54:15 +00:00
|
|
|
|
2024-07-16 10:04:01 +00:00
|
|
|
let expected = expect![[r#"
|
|
|
|
[
|
2024-08-11 05:08:31 +00:00
|
|
|
"cycle_b(Id(0))",
|
|
|
|
"cycle_c(Id(0))",
|
2024-07-16 10:04:01 +00:00
|
|
|
]
|
|
|
|
"#]];
|
|
|
|
expected.assert_debug_eq(&cycle_c(db, abc).unwrap_err().cycle);
|
|
|
|
})
|
2022-08-08 23:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn cycle_mixed_2() {
|
2024-07-27 12:29:41 +00:00
|
|
|
salsa::DatabaseImpl::new().attach(|db| {
|
2024-07-16 10:04:01 +00:00
|
|
|
// Configuration:
|
|
|
|
//
|
|
|
|
// A --> B --> C
|
|
|
|
// ^ |
|
|
|
|
// +-----------+
|
|
|
|
let abc = ABC::new(db, CycleQuery::B, CycleQuery::C, CycleQuery::A);
|
|
|
|
let expected = expect![[r#"
|
2024-08-11 05:08:31 +00:00
|
|
|
[
|
|
|
|
"cycle_a(Id(0))",
|
|
|
|
"cycle_b(Id(0))",
|
|
|
|
"cycle_c(Id(0))",
|
|
|
|
]
|
|
|
|
"#]];
|
2024-07-16 10:04:01 +00:00
|
|
|
expected.assert_debug_eq(&cycle_a(db, abc).unwrap_err().cycle);
|
|
|
|
})
|
2022-08-08 23:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn cycle_deterministic_order() {
|
|
|
|
// No matter whether we start from A or B, we get the same set of participants:
|
|
|
|
let f = || {
|
2024-07-27 12:29:41 +00:00
|
|
|
let mut db = salsa::DatabaseImpl::new();
|
2022-08-08 23:54:15 +00:00
|
|
|
|
|
|
|
// A --> B
|
|
|
|
// ^ |
|
|
|
|
// +-----+
|
2022-09-03 21:48:24 +00:00
|
|
|
let abc = ABC::new(&db, CycleQuery::B, CycleQuery::A, CycleQuery::None);
|
2022-08-08 23:54:15 +00:00
|
|
|
(db, abc)
|
|
|
|
};
|
|
|
|
let (db, abc) = f();
|
|
|
|
let a = cycle_a(&db, abc);
|
|
|
|
let (db, abc) = f();
|
|
|
|
let b = cycle_b(&db, abc);
|
|
|
|
let expected = expect![[r#"
|
|
|
|
(
|
|
|
|
[
|
2024-08-11 05:08:31 +00:00
|
|
|
"cycle_a(Id(0))",
|
|
|
|
"cycle_b(Id(0))",
|
2022-08-08 23:54:15 +00:00
|
|
|
],
|
|
|
|
[
|
2024-08-11 05:08:31 +00:00
|
|
|
"cycle_a(Id(0))",
|
|
|
|
"cycle_b(Id(0))",
|
2022-08-08 23:54:15 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
"#]];
|
|
|
|
expected.assert_debug_eq(&(a.unwrap_err().cycle, b.unwrap_err().cycle));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn cycle_multiple() {
|
|
|
|
// No matter whether we start from A or B, we get the same set of participants:
|
2024-07-27 12:29:41 +00:00
|
|
|
let mut db = salsa::DatabaseImpl::new();
|
2022-08-08 23:54:15 +00:00
|
|
|
|
|
|
|
// Configuration:
|
|
|
|
//
|
|
|
|
// A --> B <-- C
|
|
|
|
// ^ | ^
|
|
|
|
// +-----+ |
|
|
|
|
// | |
|
|
|
|
// +-----+
|
|
|
|
//
|
|
|
|
// Here, conceptually, B encounters a cycle with A and then
|
|
|
|
// recovers.
|
2022-09-03 21:48:24 +00:00
|
|
|
let abc = ABC::new(&db, CycleQuery::B, CycleQuery::AthenC, CycleQuery::A);
|
2022-08-08 23:54:15 +00:00
|
|
|
|
|
|
|
let c = cycle_c(&db, abc);
|
|
|
|
let b = cycle_b(&db, abc);
|
|
|
|
let a = cycle_a(&db, abc);
|
|
|
|
let expected = expect![[r#"
|
|
|
|
(
|
|
|
|
[
|
2024-08-11 05:08:31 +00:00
|
|
|
"cycle_a(Id(0))",
|
|
|
|
"cycle_b(Id(0))",
|
2022-08-08 23:54:15 +00:00
|
|
|
],
|
|
|
|
[
|
2024-08-11 05:08:31 +00:00
|
|
|
"cycle_a(Id(0))",
|
|
|
|
"cycle_b(Id(0))",
|
2022-08-08 23:54:15 +00:00
|
|
|
],
|
|
|
|
[
|
2024-08-11 05:08:31 +00:00
|
|
|
"cycle_a(Id(0))",
|
|
|
|
"cycle_b(Id(0))",
|
2022-08-08 23:54:15 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
"#]];
|
|
|
|
expected.assert_debug_eq(&(
|
|
|
|
c.unwrap_err().cycle,
|
|
|
|
b.unwrap_err().cycle,
|
|
|
|
a.unwrap_err().cycle,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn cycle_recovery_set_but_not_participating() {
|
2024-07-27 12:29:41 +00:00
|
|
|
salsa::DatabaseImpl::new().attach(|db| {
|
2024-07-16 10:04:01 +00:00
|
|
|
// A --> C -+
|
|
|
|
// ^ |
|
|
|
|
// +--+
|
|
|
|
let abc = ABC::new(db, CycleQuery::C, CycleQuery::None, CycleQuery::C);
|
|
|
|
|
|
|
|
// Here we expect C to panic and A not to recover:
|
|
|
|
let r = extract_cycle(|| drop(cycle_a(db, abc)));
|
|
|
|
let expected = expect![[r#"
|
|
|
|
[
|
2024-08-11 05:08:31 +00:00
|
|
|
cycle_c(Id(0)),
|
2024-07-16 10:04:01 +00:00
|
|
|
]
|
|
|
|
"#]];
|
|
|
|
expected.assert_debug_eq(&r.all_participants(db));
|
|
|
|
})
|
2022-08-08 23:54:15 +00:00
|
|
|
}
|