diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2023-08-30 16:31:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-30 16:31:31 +0100 |
commit | d28384c3deec1497d28f0f6bd16cf51de832e572 (patch) | |
tree | b65eb37b3c066f95d69c5ae36798426d617a9119 /cli/tools/test/mod.rs | |
parent | 329698cf73e98bd3347f5b03f5ecb562a6ce9925 (diff) |
refactor(lsp): store test definitions in adjacency list (#20330)
Previously:
```rust
pub struct TestDefinition {
pub id: String,
pub name: String,
pub range: SourceRange,
pub steps: Vec<TestDefinition>,
}
pub struct TestDefinitions {
pub discovered: Vec<TestDefinition>,
pub injected: Vec<lsp_custom::TestData>,
pub script_version: String,
}
```
Now:
```rust
pub struct TestDefinition {
pub id: String,
pub name: String,
pub range: Option<Range>,
pub is_dynamic: bool, // True for 'injected' module, not statically detected but added at runtime.
pub parent_id: Option<String>,
pub step_ids: HashSet<String>,
}
pub struct TestModule {
pub specifier: ModuleSpecifier,
pub script_version: String,
pub defs: HashMap<String, TestDefinition>,
}
```
Storing the test tree as a literal tree diminishes the value of IDs,
even though vscode stores them that way. This makes all data easily
accessible from `TestModule`. It unifies the interface between
'discovered' and 'injected' tests. This unblocks some enhancements wrt
syncing tests between the LSP and extension, such as this TODO:
https://github.com/denoland/vscode_deno/blob/61f08d5a71536a0a5f7dce965955b09e6bd957e1/client/src/testing.ts#L251-L259
and https://github.com/denoland/vscode_deno/issues/900. We should also
get more flexibility overall.
`TestCollector` is cleaned up, now stores a `&mut TestModule` directly
and registers tests as it comes across them with
`TestModule::register()`. This method ensures sanity in the redundant
data from having both of `TestDefinition::{parent_id,step_ids}`.
All of the messy conversions between `TestDescription`,
`LspTestDescription`, `TestDefinition`, `TestData` and `TestIdentifier`
are cleaned up. They shouldn't have been using `impl From` and now the
full list of tests is available to their implementations.
Diffstat (limited to 'cli/tools/test/mod.rs')
-rw-r--r-- | cli/tools/test/mod.rs | 7 |
1 files changed, 0 insertions, 7 deletions
diff --git a/cli/tools/test/mod.rs b/cli/tools/test/mod.rs index 2a0938e96..296d306e2 100644 --- a/cli/tools/test/mod.rs +++ b/cli/tools/test/mod.rs @@ -15,7 +15,6 @@ use crate::graph_util::graph_valid_with_cli_options; use crate::graph_util::has_graph_root_local_dependent_changed; use crate::module_loader::ModuleLoadPreparer; use crate::ops; -use crate::util::checksum; use crate::util::file_watcher; use crate::util::fs::collect_specifiers; use crate::util::path::get_extension; @@ -174,12 +173,6 @@ pub struct TestDescription { pub location: TestLocation, } -impl TestDescription { - pub fn static_id(&self) -> String { - checksum::gen(&[self.location.file_name.as_bytes(), self.name.as_bytes()]) - } -} - #[derive(Debug, Clone, Eq, PartialEq, Deserialize)] #[serde(rename_all = "camelCase")] pub enum TestOutput { |