Skip to content

Commit f53b63b

Browse files
Create djls-testing crate (#670)
1 parent 3876398 commit f53b63b

173 files changed

Lines changed: 6496 additions & 5508 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/bench.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ jobs:
3333
- name: Cache corpus
3434
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
3535
with:
36-
path: crates/djls-corpus/.corpus
37-
key: ${{ runner.os }}-corpus-${{ hashFiles('crates/djls-corpus/manifest.lock') }}
36+
path: crates/djls-testing/.corpus
37+
key: ${{ runner.os }}-corpus-${{ hashFiles('crates/djls-testing/manifest.lock') }}
3838
restore-keys: |
3939
${{ runner.os }}-corpus-
4040
4141
- name: Sync corpus
42-
run: cargo run -q -p djls-corpus -- sync
42+
run: cargo run -q -p djls-testing --bin corpus -- sync
4343

4444
- run: cargo install cargo-codspeed --locked
4545

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ jobs:
107107
- name: Cache corpus
108108
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
109109
with:
110-
path: crates/djls-corpus/.corpus
111-
key: ${{ runner.os }}-corpus-${{ hashFiles('crates/djls-corpus/manifest.lock') }}
110+
path: crates/djls-testing/.corpus
111+
key: ${{ runner.os }}-corpus-${{ hashFiles('crates/djls-testing/manifest.lock') }}
112112
restore-keys: |
113113
${{ runner.os }}-corpus-
114114

ARCHITECTURE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ Settings and diagnostics configuration. Merges configuration from multiple sourc
120120

121121
Benchmarks using [divan](https://github.com/nvzqz/divan). Owns a `BenchDatabase` that implements `SemanticDb` with realistic tag specs, plus benchmarks for parsing, validation, extraction, and full-pipeline `djls check` runs. `just dev profile <bench> [filter]` generates flamegraphs.
122122

123-
### `crates/djls-corpus`
123+
### `crates/djls-testing`
124124

125-
Corpus management for integration tests. Syncs real-world Django project source — templates and templatetag modules from 40+ packages and 17 real projects — for testing extraction and validation against code that actually exists in the wild. See the [Testing](#testing) section for how corpus tests work.
125+
Shared test infrastructure. Owns the corpus sync tool, shared Salsa test database, fixture builders, and markdown test runner. The corpus syncs real-world Django project source — templates and templatetag modules from 40+ packages and 17 real projects — for testing extraction and validation against code that actually exists in the wild. See the [Testing](#testing) section for how corpus tests work.
126126

127127
## The Database Trait Stack
128128

@@ -279,7 +279,7 @@ Corpus tests serve two purposes:
279279
1. **Extraction snapshot tests** — parse every `templatetags/*.py` file with the Ruff parser and snapshot the extracted rules. This catches regressions in Python AST analysis and documents what we can extract from real-world code.
280280
2. **Validation integration tests** — validate real templates against extracted rules. This is our "zero false positives" check: if we report a diagnostic on a template from a real project, it's probably a bug in our analysis, not in the project.
281281

282-
The corpus is deliberately not checked into the repository (it's ~hundreds of MB of third-party source). `just corpus sync` downloads it from the lockfile (`crates/djls-corpus/manifest.lock`), which pins exact versions and SHA-256 checksums.
282+
The corpus is deliberately not checked into the repository (it's ~hundreds of MB of third-party source). `just corpus sync` downloads it from the lockfile (`crates/djls-testing/manifest.lock`), which pins exact versions and SHA-256 checksums.
283283

284284
### Incremental Computation Tests
285285

Cargo.lock

Lines changed: 30 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ edition = "2024"
99
djls = { path = "crates/djls" }
1010
djls-bench = { path = "crates/djls-bench" }
1111
djls-conf = { path = "crates/djls-conf" }
12-
djls-corpus = { path = "crates/djls-corpus" }
1312
djls-db = { path = "crates/djls-db" }
1413
djls-format = { path = "crates/djls-format" }
1514
djls-ide = { path = "crates/djls-ide" }
@@ -18,6 +17,7 @@ djls-semantic = { path = "crates/djls-semantic" }
1817
djls-server = { path = "crates/djls-server" }
1918
djls-source = { path = "crates/djls-source" }
2019
djls-templates = { path = "crates/djls-templates" }
20+
djls-testing = { path = "crates/djls-testing" }
2121

2222
# core deps, pin exact versions
2323
salsa = "0.26.1"

Justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ clean:
2727
cargo clean
2828

2929
corpus *ARGS:
30-
cargo run -q -p djls-corpus -- {{ ARGS }}
30+
cargo run -q -p djls-testing --bin corpus -- {{ ARGS }}
3131

3232
clippy *ARGS:
3333
cargo clippy --all-targets --all-features --benches --fix {{ ARGS }} -- -D warnings

crates/djls-bench/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ edition.workspace = true
55

66
[dependencies]
77
djls-conf = { workspace = true }
8-
djls-corpus = { workspace = true }
98
djls-db = { workspace = true }
109
djls-ide = { workspace = true }
1110
djls-project = { workspace = true }
1211
djls-semantic = { workspace = true }
1312
djls-source = { workspace = true }
1413
djls-templates = { workspace = true }
14+
djls-testing = { workspace = true }
1515

1616
camino = { workspace = true }
1717
divan = { workspace = true }

crates/djls-bench/benches/check.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ struct CorpusTemplates {
7171
}
7272

7373
fn load_corpus_inner(
74-
get_paths: impl FnOnce(&djls_corpus::Corpus) -> Option<Vec<Utf8PathBuf>>,
74+
get_paths: impl FnOnce(&djls_testing::Corpus) -> Option<Vec<Utf8PathBuf>>,
7575
) -> Option<CorpusTemplates> {
76-
if !djls_corpus::Corpus::is_available() {
76+
if !djls_testing::Corpus::is_available() {
7777
return None;
7878
}
7979

80-
let corpus = djls_corpus::Corpus::require();
80+
let corpus = djls_testing::Corpus::require();
8181
let mut template_paths = get_paths(&corpus)?;
8282
template_paths.sort();
8383

crates/djls-bench/benches/models.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,21 @@ struct CorpusModels {
101101
}
102102

103103
fn load_corpus_models_inner(
104-
get_paths: impl FnOnce(&djls_corpus::Corpus) -> Option<Vec<Utf8PathBuf>>,
104+
get_paths: impl FnOnce(&djls_testing::Corpus) -> Option<Vec<Utf8PathBuf>>,
105105
) -> Option<CorpusModels> {
106-
if !djls_corpus::Corpus::is_available() {
106+
if !djls_testing::Corpus::is_available() {
107107
return None;
108108
}
109109

110-
let corpus = djls_corpus::Corpus::require();
110+
let corpus = djls_testing::Corpus::require();
111111
let mut paths = get_paths(&corpus)?;
112112
paths.sort();
113113

114114
let files: Vec<(String, String)> = paths
115115
.into_iter()
116116
.filter_map(|path| {
117117
let source = std::fs::read_to_string(path.as_std_path()).ok()?;
118-
let module_path = djls_corpus::module_path_from_file(&path);
118+
let module_path = djls_testing::module_path_from_file(&path);
119119
Some((source, module_path))
120120
})
121121
.collect();

crates/djls-ide/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ tower-lsp-server = { workspace = true }
1616
tracing = { workspace = true }
1717

1818
[dev-dependencies]
19-
salsa = { workspace = true }
19+
djls-testing = { workspace = true }
2020

2121
[lints]
2222
workspace = true

0 commit comments

Comments
 (0)