litcheck_lit/suite/registry/
mod.rs

1mod default;
2
3pub use self::default::DefaultTestSuiteRegistry;
4
5use std::{path::Path, sync::Arc};
6
7use litcheck::diagnostics::DiagResult;
8
9use crate::{
10    suite::{TestSuite, TestSuiteKey},
11    test::Test,
12    Config,
13};
14
15pub trait TestSuiteRegistry: IntoIterator<Item = Arc<Test>> {
16    /// Load all available test suites
17    fn load(&mut self, config: &Config) -> DiagResult<()>;
18
19    /// Returns true if there are no suites/tests in the registry
20    fn is_empty(&self) -> bool;
21
22    /// Returns the number of test suites in the registry
23    fn num_suites(&self) -> usize;
24
25    /// Returns the number of tests in the registry
26    fn num_tests(&self) -> usize;
27
28    /// Returns the number of tests in the registry belonging to a specific suite
29    fn size_of_suite(&self, id: &TestSuiteKey) -> usize;
30
31    /// Get a [TestSuite] using its [TestSuiteKey]
32    fn get(&self, id: &TestSuiteKey) -> Arc<TestSuite>;
33
34    /// Get a [TestSuite] given the path at which it's configuration resides
35    fn get_by_path(&self, path: &Path) -> Option<Arc<TestSuite>>;
36
37    /// Get an iterator over the tests in the registry
38    fn tests(&self) -> impl Iterator<Item = Arc<Test>> + '_;
39
40    /// Get an iterator over the tests in the registry
41    fn suites(&self) -> impl Iterator<Item = Arc<TestSuite>> + '_;
42}