1mod config;
2mod list;
3mod registry;
4mod result;
5mod status;
6
7pub use self::config::{TestConfig, TestConfigError};
8pub use self::list::TestList;
9pub use self::registry::{DefaultTestRegistry, TestRegistry};
10pub use self::result::TestResult;
11pub use self::status::TestStatus;
12
13use std::{
14 path::{Path, PathBuf},
15 sync::Arc,
16 time::Duration,
17};
18
19use crate::suite::TestSuite;
20
21pub struct Test {
23 link: intrusive_collections::LinkedListAtomicLink,
24 pub suite: Arc<TestSuite>,
26 pub config: Arc<TestConfig>,
28 pub name: Arc<str>,
30 pub path: PathBuf,
32 pub absolute_path: PathBuf,
34 pub xfail_not: bool,
36 pub previous_failure: Option<TestResult>,
38 pub previous_elapsed: Option<Duration>,
40}
41impl Test {
42 pub fn new(path_in_suite: PathBuf, suite: Arc<TestSuite>, config: Arc<TestConfig>) -> Self {
43 let absolute_path = suite.source_dir.get_ref().join(&path_in_suite);
44 let name =
45 Arc::from(format!("{}::{}", suite.name(), path_in_suite.display()).into_boxed_str());
46 Self {
47 link: Default::default(),
48 suite,
49 config,
50 name,
51 path: path_in_suite,
52 absolute_path,
53 xfail_not: false,
54 previous_failure: None,
55 previous_elapsed: None,
56 }
57 }
58
59 pub fn name(&self) -> &str {
60 self.name.as_ref()
61 }
62
63 pub fn source_path(&self) -> &Path {
64 self.absolute_path.as_path()
65 }
66}