unityrs-testkit 1.0.0

Synthetic Unity files built in code, for unityrs's own tests and the CLI's test hooks; not a stable API. Never game data.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
// Ported from UnityPy 1.25.2 (MIT): UnityPy/environment.py, UnityPy/classes/PPtr.py, UnityPy/files/SerializedFile.py. See THIRD_PARTY_LICENSES.
//! The scenes, one function each, and [`scenes`], which lists them by
//! name for `tools/fixtures/env.py`.

mod find;
mod nested;
mod race;
mod revisit;

pub use find::{FindAsk, FindScene, find_file_kinds, find_file_listing, find_scenes, web_file};
pub use nested::{
    dependency_reads, deref_sibling_nested, nested_between_loads, nested_dropped_evicted,
    nested_duplicates, nested_evicted, nested_raw_replaced, nested_reloaded, nested_reloaded_spans,
    nested_reloaded_spans_raced, nested_replaced_unread, preload_nested_external,
    resource_in_nested_cab, resource_in_own_nested,
};
pub use race::{listings, listings_raced, race_scenes};
pub use revisit::{preload_revisits_after_load, preload_revisits_ahead};

use super::{Bundle, DepScene, Obj, Scene, bundle, bundle_spec, res_bytes, row, serialized};
use crate::bundle::{BlockOverride, TestCodec};

fn named(name: &str, data: Vec<u8>) -> (Vec<u8>, Vec<u8>) {
    (name.as_bytes().to_vec(), data)
}

/// Two bundles: an object in the first points (`m_FileID` 1) at an object in
/// the second's CAB; the first also holds a `.resS` the object reads.
#[must_use]
pub fn cross_bundle_pointer() -> Scene {
    let cab_a = serialized(
        &["archive:/CAB-B/CAB-B"],
        &[
            Obj::named(1, "a1", &[(1, 7), (0, 2)]),
            Obj::streamed(2, "tex", "archive:/CAB-A/CAB-A.resS", 4, 8),
            Obj::asset_bundle(
                3,
                Bundle {
                    preload: vec![(1, 7), (0, 2)],
                    rows: vec![row("assets/a1.prefab", (0, 2), (0, 1))],
                    ..Bundle::default()
                },
            ),
        ],
    );
    let cab_b = serialized(&[], &[Obj::named(7, "b7", &[])]);
    Scene {
        files: vec![
            named(
                "a.bundle",
                bundle(&[("CAB-A", cab_a), ("CAB-A.resS", res_bytes(32, 0))]),
            ),
            named("b.bundle", bundle(&[("CAB-B", cab_b)])),
        ],
        resolver: Vec::new(),
    }
}

/// Two loose `SerializedFile`s loaded at top level under names with
/// directories (`a/CAB-A`, `b/CAB-B`): an object in A points (`m_FileID` 1,
/// external `archive:/CAB-B/CAB-B`) at an object in B. The pointer resolves,
/// as in UnityPy, whose Environment is a top-level file's container
/// (`find_file` finds `cab-b`); without B it is `DerefError::NotFound`.
#[must_use]
pub fn loose_external_pointer() -> Scene {
    Scene {
        files: vec![
            named(
                "a/CAB-A",
                serialized(&["archive:/CAB-B/CAB-B"], &[Obj::named(1, "a1", &[(1, 5)])]),
            ),
            named("b/CAB-B", serialized(&[], &[Obj::named(5, "b5", &[])])),
        ],
        resolver: Vec::new(),
    }
}

/// One bundle whose first CAB holds a pointer for every dereference rule:
/// null, a missing path id, `m_FileID` past the end, a negative id in range
/// and one below it, `i32::MIN`, an external nobody has, a raw sibling, a
/// sibling matched by its lower-cased name, and one found by `find_file`
/// under a key with a directory.
#[must_use]
pub fn deref_rules() -> Scene {
    let externals = [
        "archive:/CAB-RAW/CAB-RAW.resS",
        "archive:/CAB-MISSING/CAB-MISSING",
        "archive:/CAB-E2/Cab-E2",
        "archive:/elsewhere/CAB-D",
    ];
    let cab_e = serialized(
        &externals,
        &[Obj::named(
            1,
            "e1",
            &[
                (0, 0),
                (0, 99),
                (5, 1),
                (-1, 11),
                (-5, 1),
                (i32::MIN, 1),
                (2, 1),
                (1, 1),
                (3, 9),
                (3, 10),
                (4, 11),
                (0, 1),
            ],
        )],
    );
    Scene {
        files: vec![named(
            "e.bundle",
            bundle(&[
                ("CAB-E", cab_e),
                ("CAB-RAW.resS", res_bytes(16, 3)),
                ("CAB-E2", serialized(&[], &[Obj::named(9, "e9", &[])])),
                ("dir/CAB-D", serialized(&[], &[Obj::named(11, "d11", &[])])),
            ]),
        )],
        resolver: Vec::new(),
    }
}

/// A bundle of a good CAB, its `.resS` and a CAB that fails to parse: the
/// load fails, `files` stays empty, and the first two are registered.
#[must_use]
pub fn bad_cab() -> Scene {
    let good = serialized(
        &[],
        &[
            Obj::named(1, "g1", &[]),
            Obj::streamed(2, "tex", "archive:/CAB-G/CAB-G.resS", 0, 4),
        ],
    );
    // An AssetBundle without `m_Container`: UnityPy's object-mode read at
    // parse (`files/SerializedFile.py:316-321`) fails the file.
    let bad = serialized(
        &[],
        &[Obj::asset_bundle(
            1,
            Bundle {
                no_container: true,
                ..Bundle::default()
            },
        )],
    );
    Scene {
        files: vec![named(
            "g.bundle",
            bundle(&[
                ("CAB-G", good),
                ("CAB-G.resS", res_bytes(16, 7)),
                ("CAB-BAD", bad),
            ]),
        )],
        resolver: Vec::new(),
    }
}

/// A bundle whose second entry is a bundle under the path of the first,
/// a CAB (plan 3.13 (b)).
#[must_use]
pub fn nested_after_cab() -> Scene {
    let inner = bundle(&[("CAB-INNER", serialized(&[], &[Obj::named(2, "inner", &[])]))]);
    Scene {
        files: vec![named(
            "n.bundle",
            bundle(&[
                ("CAB-N", serialized(&[], &[Obj::named(1, "n1", &[])])),
                ("CAB-N", inner),
            ]),
        )],
        resolver: Vec::new(),
    }
}

/// A bundle with a block after its last entry's bytes that fails to decode
/// (plan 3.13 (c)).
#[must_use]
pub fn last_block_fails() -> Scene {
    let mut spec = bundle_spec(&[("CAB-L", serialized(&[], &[Obj::named(1, "l1", &[(0, 1)])]))]);
    let blocks = spec
        .entries
        .iter()
        .map(|e| e.data.len())
        .sum::<usize>()
        .div_ceil(spec.block_size);
    spec.block_overrides.push(BlockOverride {
        block: blocks,
        // An id no codec has: UnityPy's `CompressionFlags(9)` raises.
        codec: Some(TestCodec::Raw(9)),
        uncompressed: Some(16),
        compressed: None,
    });
    Scene {
        files: vec![named("l.bundle", crate::bundle::build(&spec))],
        resolver: Vec::new(),
    }
}

/// A container whose preload table points every way the preload skips:
/// past the externals, at a file nobody has, at a missing object, null,
/// and rows whose spans fall outside the table.
#[must_use]
pub fn preload_skips() -> Scene {
    let skipped = serialized(
        &["archive:/CAB-NONE/CAB-NONE"],
        &[
            Obj::named(1, "p1", &[]),
            Obj::asset_bundle(
                2,
                Bundle {
                    preload: vec![(0, 1), (9, 1), (1, 1), (0, 77), (0, 0)],
                    rows: vec![
                        row("assets/p1.prefab", (0, 5), (0, 1)),
                        row("assets/out.prefab", (3, 9), (0, 1)),
                        row("assets/neg.prefab", (-1, 2), (0, 1)),
                    ],
                    ..Bundle::default()
                },
            ),
        ],
    );
    Scene {
        files: vec![named("p.bundle", bundle(&[("CAB-P", skipped)]))],
        resolver: Vec::new(),
    }
}

/// A preload pointer below the externals: `IndexError`, raised.
#[must_use]
pub fn preload_below_start() -> Scene {
    let file = serialized(
        &["archive:/CAB-NONE/CAB-NONE"],
        &[
            Obj::named(1, "q1", &[]),
            Obj::asset_bundle(
                2,
                Bundle {
                    preload: vec![(-3, 1)],
                    rows: vec![row("assets/q1.prefab", (0, 1), (0, 1))],
                    ..Bundle::default()
                },
            ),
        ],
    );
    Scene {
        files: vec![named("q.bundle", bundle(&[("CAB-Q", file)]))],
        resolver: Vec::new(),
    }
}

/// A preload pointer at a raw sibling: `AttributeError`, raised.
#[must_use]
pub fn preload_raw_target() -> Scene {
    let file = serialized(
        &["archive:/CAB-R/CAB-R.resS"],
        &[
            Obj::named(1, "r1", &[]),
            Obj::asset_bundle(
                2,
                Bundle {
                    preload: vec![(1, 1)],
                    rows: vec![row("assets/r1.prefab", (0, 1), (0, 1))],
                    ..Bundle::default()
                },
            ),
        ],
    );
    Scene {
        files: vec![named(
            "r.bundle",
            bundle(&[("CAB-R", file), ("CAB-R.resS", res_bytes(8, 1))]),
        )],
        resolver: Vec::new(),
    }
}

/// `AssetBundle`s read in object mode: two fields whose names clean to one
/// key (the last wins), one without `m_MainAsset` (`UnknownObject`), and
/// one without `m_Container` (the file fails).
#[must_use]
pub fn asset_bundle_modes() -> Scene {
    let shadow = serialized(
        &[],
        &[
            Obj::named(1, "s1", &[]),
            Obj::asset_bundle(
                2,
                Bundle {
                    rows: vec![row("assets/first.prefab", (0, 0), (0, 1))],
                    shadow_container: Some(vec![
                        row("assets/second.prefab", (0, 0), (0, 1)),
                        row("assets/third.prefab", (0, 0), (0, 2)),
                    ]),
                    ..Bundle::default()
                },
            ),
        ],
    );
    let unknown = serialized(
        &[],
        &[
            Obj::named(1, "u1", &[]),
            Obj::asset_bundle(
                2,
                Bundle {
                    rows: vec![row("assets/u1.prefab", (0, 0), (0, 1))],
                    no_main_asset: true,
                    ..Bundle::default()
                },
            ),
        ],
    );
    let missing = serialized(
        &[],
        &[
            Obj::named(1, "m1", &[]),
            Obj::asset_bundle(
                2,
                Bundle {
                    no_container: true,
                    ..Bundle::default()
                },
            ),
        ],
    );
    Scene {
        files: vec![
            named("shadow.bundle", bundle(&[("CAB-S", shadow)])),
            named("unknown.bundle", bundle(&[("CAB-U", unknown)])),
            named("missing.bundle", bundle(&[("CAB-M", missing)])),
        ],
        resolver: Vec::new(),
    }
}

/// A loaded bundle whose CAB points at, and reads a resource from, files
/// only the resolver has: `find_file` loads `cab-dep`'s bundle as a
/// dependency (a container, so the pointer has no target), whose own copy of
/// `CAB-H` then replaces the loaded one's key, and `cab-loose`, a
/// `SerializedFile` it resolves into; the resource fallback loads
/// `CAB-H2.resS` under the name it asked for, twice (the first and last
/// candidates are one name).
#[must_use]
pub fn resolver_loads() -> Scene {
    let cab_h = |name: &str| {
        serialized(
            &["archive:/CAB-DEP/CAB-DEP", "archive:/CAB-LOOSE/CAB-LOOSE"],
            &[
                Obj::named(1, name, &[(1, 3), (2, 5)]),
                Obj::streamed(2, "tex", "archive:/CAB-H2/CAB-H2.resS", 2, 6),
                Obj::asset_bundle(
                    4,
                    Bundle {
                        rows: vec![row(&format!("assets/{name}.prefab"), (0, 0), (0, 1))],
                        ..Bundle::default()
                    },
                ),
            ],
        )
    };
    let dep = bundle(&[
        ("CAB-DEP", serialized(&[], &[Obj::named(3, "dep3", &[])])),
        ("CAB-H", cab_h("h-copy")),
    ]);
    Scene {
        files: vec![named("h.bundle", bundle(&[("CAB-H", cab_h("h1"))]))],
        resolver: vec![
            // Lower-case: `find_file` asks for the cleaned (lower-cased)
            // external name, and UnityPy finds only an exact file name
            // (its walk keys a lower-cased path its open then misses).
            named("cab-dep", dep),
            named(
                "cab-loose",
                serialized(&[], &[Obj::named(5, "loose5", &[])]),
            ),
            named("CAB-H2.resS", res_bytes(24, 9)),
        ],
    }
}

/// A loose file whose preload pointer names a CAB only the resolver has:
/// the container pass's `find_file` registers it, and UnityPy's loop over
/// `env.cabs` raises `RuntimeError` (the dict changed size); the next pass
/// ends.
#[must_use]
pub fn preload_loads_new_cab() -> Scene {
    let file = serialized(
        &["archive:/CAB-NEW/CAB-NEW"],
        &[
            Obj::named(1, "x1", &[]),
            Obj::asset_bundle(
                2,
                Bundle {
                    preload: vec![(1, 3)],
                    rows: vec![row("assets/x1.prefab", (0, 1), (0, 1))],
                    ..Bundle::default()
                },
            ),
        ],
    );
    Scene {
        files: vec![named("x/CAB-X", file)],
        resolver: vec![named(
            "cab-new",
            serialized(&[], &[Obj::named(3, "new3", &[])]),
        )],
    }
}

/// Container paths (`obj.container`): rows whose spans overlap (the first
/// row to reach an object gives its path), a row's own asset (which beats
/// any span), two rows of one asset (the last wins), and a span reaching an
/// object in a sibling CAB.
#[must_use]
pub fn preload_paths() -> Scene {
    let pp = serialized(
        &["archive:/CAB-PQ/CAB-PQ"],
        &[
            Obj::named(1, "p1", &[]),
            Obj::named(2, "p2", &[]),
            Obj::named(3, "p3", &[]),
            Obj::named(4, "p4", &[]),
            Obj::named(5, "p5", &[]),
            Obj::asset_bundle(
                9,
                Bundle {
                    preload: vec![(0, 1), (0, 2), (0, 3), (1, 7), (0, 4)],
                    rows: vec![
                        row("assets/a.prefab", (0, 3), (0, 1)),
                        row("assets/b.prefab", (1, 4), (0, 2)),
                        row("assets/c.prefab", (0, 0), (0, 5)),
                        row("assets/d.prefab", (0, 0), (0, 5)),
                    ],
                    ..Bundle::default()
                },
            ),
        ],
    );
    let pq = serialized(&[], &[Obj::named(7, "q7", &[])]);
    Scene {
        files: vec![named(
            "pp.bundle",
            bundle(&[("CAB-PP", pp), ("CAB-PQ", pq)]),
        )],
        resolver: Vec::new(),
    }
}

/// A container row whose asset is in another file (`m_FileID` 1): UnityPy
/// keys its path by path id alone, so the object of that path id in the
/// container's own file gets it; the core keys only a row whose asset is in
/// the container's own file (`PARITY.md` section 19.2), so neither file's
/// object does.
#[must_use]
pub fn container_other_file() -> Scene {
    let of = serialized(
        &["archive:/CAB-OG/CAB-OG"],
        &[
            Obj::named(1, "of1", &[]),
            Obj::asset_bundle(
                9,
                Bundle {
                    rows: vec![row("assets/other.prefab", (0, 0), (1, 1))],
                    ..Bundle::default()
                },
            ),
        ],
    );
    let og = serialized(&[], &[Obj::named(1, "og1", &[])]);
    Scene {
        files: vec![named(
            "of.bundle",
            bundle(&[("CAB-OF", of), ("CAB-OG", og)]),
        )],
        resolver: Vec::new(),
    }
}

/// A resource read's fallback loads, through the resolver, a file whose
/// object points (`m_FileID` 1) at a CAB of the loaded bundle. UnityPy's
/// `load_file` parses the fallback's file with the Environment as its
/// container (`environment.py:107-108`, `:154`), so the pointer resolves as
/// a top-level file's does.
#[must_use]
pub fn fallback_file_pointer() -> Scene {
    let f = serialized(
        &["LOOSE-T"],
        &[Obj::streamed(1, "tex", "archive:/CAB-R/CAB-R.resS", 0, 4)],
    );
    let t = serialized(&[], &[Obj::named(5, "t5", &[])]);
    Scene {
        files: vec![named("f.bundle", bundle(&[("CAB-F", f), ("CAB-T", t)]))],
        resolver: vec![named(
            "LOOSE-T",
            serialized(&["archive:/CAB-T/CAB-T"], &[Obj::named(4, "l4", &[(1, 5)])]),
        )],
    }
}

/// A preload whose externals UnityPy's `find_file` reaches two ways: `H`
/// (`xab.assets`) by the registry, where a caller's copy holds the key, and
/// `A` (`ab.assets`) by its walk's suffix match (`environment.py:345-354`),
/// which loads the resolver's `xab.assets` under that name, so the name
/// asked misses again: every dereference of `A` loads a new copy, which
/// takes the key, and the next dereference of `H` finds that copy. One row
/// spans `H`, `A`, `H`, `A` (path ids 5, 5, 6, 7): the caller's copy gets 5
/// alone, the last copy 7 alone (review round 2: the walk kept its first
/// answer for each external).
#[must_use]
pub fn preload_suffix_external() -> Scene {
    let x = |prefix: &str| {
        serialized(
            &[],
            &[
                Obj::named(5, &format!("{prefix}5"), &[]),
                Obj::named(6, &format!("{prefix}6"), &[]),
                Obj::named(7, &format!("{prefix}7"), &[]),
            ],
        )
    };
    let r = serialized(
        &["archive:/CAB-B/xab.assets", "archive:/CAB-B/ab.assets"],
        &[
            Obj::named(1, "r1", &[]),
            Obj::asset_bundle(
                2,
                Bundle {
                    preload: vec![(1, 5), (2, 5), (1, 6), (2, 7)],
                    rows: vec![row("assets/r.prefab", (0, 4), (0, 1))],
                    ..Bundle::default()
                },
            ),
        ],
    );
    Scene {
        files: vec![
            // Under the key `xab.assets`, as the resolver's file.
            named("caller/xab.assets", x("caller")),
            named("r.bundle", bundle(&[("CAB-R", r)])),
        ],
        // Only `xab.assets`: the walk's `ab.assets` matches it by suffix.
        resolver: vec![named("xab.assets", x("found"))],
    }
}

/// Two bundles that each hold a CAB of one name, `CAB-S`, with its own
/// `.resS`, container row and object 7; the first also holds `CAB-X`, which
/// points at `CAB-S`'s object 7. UnityPy's one registry keeps the later
/// copy under each key, so a resource read from either copy's texture
/// reads the later `.resS`, and the container lists only the later row;
/// a pointer matches the asking file's own bundle first
/// (`classes/PPtr.py:75-78`), so `CAB-X` reads its own bundle's object 7
/// (`PARITY.md` section 19.2, same-named CABs).
#[must_use]
pub fn same_named_cabs() -> Scene {
    let cab_s = |name: &str| {
        serialized(
            &[],
            &[
                Obj::named(7, &format!("{name}7"), &[]),
                Obj::streamed(2, &format!("tex-{name}"), "archive:/CAB-S/CAB-S.resS", 0, 4),
                Obj::asset_bundle(
                    3,
                    Bundle {
                        rows: vec![row(&format!("assets/{name}.prefab"), (0, 0), (0, 7))],
                        ..Bundle::default()
                    },
                ),
            ],
        )
    };
    let x = serialized(&["archive:/CAB-S/CAB-S"], &[Obj::named(1, "x1", &[(1, 7)])]);
    let a = bundle(&[
        ("CAB-X", x),
        ("CAB-S", cab_s("a")),
        ("CAB-S.resS", res_bytes(8, 10)),
    ]);
    let b = bundle(&[("CAB-S", cab_s("b")), ("CAB-S.resS", res_bytes(8, 200))]);
    Scene {
        files: vec![named("a.bundle", a), named("b.bundle", b)],
        resolver: Vec::new(),
    }
}

/// Every scene, by name: what `tools/fixtures/env.py` records.
#[must_use]
pub fn scenes() -> Vec<(&'static str, Scene)> {
    vec![
        ("cross_bundle_pointer", cross_bundle_pointer()),
        ("loose_external_pointer", loose_external_pointer()),
        ("deref_rules", deref_rules()),
        ("bad_cab", bad_cab()),
        ("nested_after_cab", nested_after_cab()),
        ("last_block_fails", last_block_fails()),
        ("preload_skips", preload_skips()),
        ("preload_below_start", preload_below_start()),
        ("preload_raw_target", preload_raw_target()),
        ("asset_bundle_modes", asset_bundle_modes()),
        ("resolver_loads", resolver_loads()),
        ("preload_loads_new_cab", preload_loads_new_cab()),
        ("preload_paths", preload_paths()),
        ("container_other_file", container_other_file()),
        ("fallback_file_pointer", fallback_file_pointer()),
        ("nested_duplicates", nested_duplicates()),
        ("preload_suffix_external", preload_suffix_external()),
        ("preload_revisits_after_load", preload_revisits_after_load()),
        ("preload_revisits_ahead", preload_revisits_ahead()),
        ("same_named_cabs", same_named_cabs()),
        ("preload_nested_external", preload_nested_external()),
        ("resource_in_own_nested", resource_in_own_nested()),
        ("deref_sibling_nested", deref_sibling_nested()),
        ("resource_in_nested_cab", resource_in_nested_cab()),
        ("nested_replaced_unread", nested_replaced_unread()),
        ("nested_reloaded", nested_reloaded()),
        ("nested_raw_replaced", nested_raw_replaced()),
        ("nested_reloaded_spans", nested_reloaded_spans()),
        ("nested_reloaded_spans_raced", nested_reloaded_spans_raced()),
        ("nested_between_loads", nested_between_loads()),
        ("listings_raced", listings_raced()),
    ]
}

/// Every scene some of whose loads are dependencies, by name: what
/// `tools/fixtures/env.py` records with those loads made as UnityPy's
/// `load_file(..., is_dependency=True)`.
#[must_use]
pub fn dependency_scenes() -> Vec<(&'static str, DepScene)> {
    vec![
        ("nested_dropped_evicted", nested_dropped_evicted()),
        ("nested_evicted", nested_evicted()),
        ("dependency_reads", dependency_reads()),
    ]
}

#[cfg(test)]
mod tests {
    use super::{dependency_scenes, find_scenes, race_scenes, scenes};

    /// Every scene of every list (fix pass 15: the `find_file` and race
    /// lists were left out), a race scene's other file among its files.
    #[test]
    fn every_scene_has_files_with_distinct_names() {
        let deps = dependency_scenes().into_iter().map(|(n, d)| (n, d.scene));
        let finds = find_scenes().into_iter().map(|(n, f)| (n, f.scene));
        let races = race_scenes().into_iter().map(|(n, r)| {
            let mut scene = r.scene;
            scene.files.push(r.other);
            (n, scene)
        });
        for (name, scene) in scenes().into_iter().chain(deps).chain(finds).chain(races) {
            assert!(!scene.files.is_empty(), "{name}");
            let mut names: Vec<_> = scene.files.iter().map(|f| &f.0).collect();
            names.sort();
            names.dedup();
            assert_eq!(names.len(), scene.files.len(), "{name}");
        }
    }
}