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
mod default;

pub use self::default::DefaultTestSuiteRegistry;

use std::{path::Path, sync::Arc};

use litcheck::diagnostics::DiagResult;

use crate::{
    suite::{TestSuite, TestSuiteKey},
    test::Test,
    Config,
};

pub trait TestSuiteRegistry: IntoIterator<Item = Arc<Test>> {
    /// Load all available test suites
    fn load(&mut self, config: &Config) -> DiagResult<()>;

    /// Returns true if there are no suites/tests in the registry
    fn is_empty(&self) -> bool;

    /// Returns the number of test suites in the registry
    fn num_suites(&self) -> usize;

    /// Returns the number of tests in the registry
    fn num_tests(&self) -> usize;

    /// Returns the number of tests in the registry belonging to a specific suite
    fn size_of_suite(&self, id: &TestSuiteKey) -> usize;

    /// Get a [TestSuite] using its [TestSuiteKey]
    fn get(&self, id: &TestSuiteKey) -> Arc<TestSuite>;

    /// Get a [TestSuite] given the path at which it's configuration resides
    fn get_by_path(&self, path: &Path) -> Option<Arc<TestSuite>>;

    /// Get an iterator over the tests in the registry
    fn tests(&self) -> impl Iterator<Item = Arc<Test>> + '_;

    /// Get an iterator over the tests in the registry
    fn suites(&self) -> impl Iterator<Item = Arc<TestSuite>> + '_;
}