foch_test/source.rs
1//! Source text handed to the library by its caller.
2
3pub use foch_annotation::source::{RelPath, SourcePosition, SourceSpan};
4use serde::{Deserialize, Serialize};
5
6/// Whether EU4 itself loads the file.
7#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
8#[serde(rename_all = "snake_case")]
9pub enum SourceKind {
10 /// A file the game loads. Tests may only appear in `#` comments.
11 Inline,
12 /// A file below the mod's `tests/` directory, which the game does not load.
13 /// It may contain plain `test = { ... }` and `fixture = { ... }` blocks;
14 /// files below `tests/events/` are helper events for the test layer only.
15 TestsDir,
16}
17
18/// The caller reads files; the library only receives their text.
19#[derive(Clone, Debug)]
20pub struct SourceFile {
21 pub mod_name: String,
22 pub path: RelPath,
23 pub kind: SourceKind,
24 pub text: String,
25}