feat: adopt marqdo 3.0.0-rc.4 public analysis boundary
This commit is contained in:
1 parent
769550b14b
commit
fe18df6c4b
74 files changed
+7618
-5368
No files matched your search
+34
-49
@@ -1,3 +1,5 @@
|
||||
mod common;
|
||||
|
||||
use std::{fs, path::Path};
|
||||
|
||||
use marqdo_lint::{
|
||||
@@ -14,7 +16,7 @@ fn load(source: &str) -> Option<ProjectInput> {
|
||||
let path = directory.path().join("case.mq.md");
|
||||
fs::write(&path, source).unwrap();
|
||||
let runner = MarqdoRunner::discover(Some(Path::new(&binary))).unwrap();
|
||||
Some(ProjectInput::load(path, &runner).unwrap())
|
||||
Some(ProjectInput::load(path, &runner, false).unwrap())
|
||||
}
|
||||
|
||||
fn load_example(path: &str) -> Option<ProjectInput> {
|
||||
@@ -23,14 +25,21 @@ fn load_example(path: &str) -> Option<ProjectInput> {
|
||||
None
|
||||
})?;
|
||||
let runner = MarqdoRunner::discover(Some(Path::new(&binary))).unwrap();
|
||||
Some(ProjectInput::load(Path::new(env!("CARGO_MANIFEST_DIR")).join(path), &runner).unwrap())
|
||||
Some(
|
||||
ProjectInput::load(
|
||||
Path::new(env!("CARGO_MANIFEST_DIR")).join(path),
|
||||
&runner,
|
||||
false,
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
}
|
||||
|
||||
fn ids(project: &ProjectInput) -> Vec<String> {
|
||||
let mut ids: Vec<_> = project
|
||||
.documents
|
||||
.iter()
|
||||
.flat_map(|document| check_document(document))
|
||||
.flat_map(check_document)
|
||||
.map(|diagnostic| diagnostic.id)
|
||||
.collect();
|
||||
ids.sort();
|
||||
@@ -61,40 +70,23 @@ fn assert_no_control_rules(project: &ProjectInput) {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn saved_core_analysis_golden_passes_without_running_core() {
|
||||
let root = Path::new(env!("CARGO_MANIFEST_DIR"));
|
||||
let directory = root.join("tests/fixtures/golden");
|
||||
for (stem, input) in [
|
||||
("branches", directory.join("branches.mq.md")),
|
||||
("inventory", root.join("examples/nested/inventory.mq.md")),
|
||||
] {
|
||||
let source = marqdo_lint::model::SourceSnapshot::load(input).unwrap();
|
||||
let ast: serde_json::Value =
|
||||
serde_json::from_slice(&fs::read(directory.join(format!("{stem}.ast.json"))).unwrap())
|
||||
.unwrap();
|
||||
let markdown =
|
||||
marqdo_lint::model::MarkdownTree::from_json(ast["ast"].clone(), &source).unwrap();
|
||||
let raw = serde_json::from_slice(
|
||||
&fs::read(directory.join(format!("{stem}.analysis.json"))).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
let analysis = marqdo_lint::model::ExecutionProjection::from_json(raw).unwrap();
|
||||
let module = analysis
|
||||
.modules
|
||||
.into_iter()
|
||||
.find(|module| module.source_digest == source.digest_hex())
|
||||
.unwrap();
|
||||
fn saved_rc4_analysis_passes_without_running_core() {
|
||||
for stem in ["branches", "inventory", "multi-arm", "loop-jumps"] {
|
||||
let document = common::document(stem);
|
||||
let module = document.module.as_ref().unwrap();
|
||||
for function in &module.functions {
|
||||
let tree = marqdo_lint::alignment::align_function(&markdown, function);
|
||||
let tree = marqdo_lint::alignment::align_function(&document.markdown, function);
|
||||
assert!(tree.complete, "{stem}: {:?}", tree.issues);
|
||||
}
|
||||
let document = marqdo_lint::input::SourceDocument {
|
||||
source,
|
||||
markdown,
|
||||
markdown_origin: marqdo_lint::input::MarkdownOrigin::MarqdoInspect,
|
||||
module: Some(module),
|
||||
};
|
||||
assert!(check_document(&document).is_empty(), "{stem}");
|
||||
let diagnostics = check_document(&document);
|
||||
assert!(
|
||||
diagnostics
|
||||
.iter()
|
||||
.all(|diagnostic| !diagnostic.id.starts_with("MQD-BRANCH")
|
||||
&& !diagnostic.id.starts_with("MQD-LOOP")
|
||||
&& diagnostic.id != "MQD-CTRL-001"),
|
||||
"{stem}: {diagnostics:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,23 +284,16 @@ fn a_branch_body_outside_its_item_is_a_layout_mismatch() {
|
||||
assert_has(&project, "MQD-LOOP-003");
|
||||
}
|
||||
|
||||
fn rc2_available() -> bool {
|
||||
std::env::var_os("MARQDO_BIN").is_some_and(|binary| {
|
||||
std::process::Command::new(binary)
|
||||
.arg("--version")
|
||||
.output()
|
||||
.unwrap()
|
||||
.stdout
|
||||
.ends_with(b"3.0.0-rc.2\n")
|
||||
})
|
||||
fn core_available() -> bool {
|
||||
std::env::var_os("MARQDO_BIN").is_some()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rc2_branch_rules_anchor_each_affected_arm() {
|
||||
if !rc2_available() {
|
||||
fn current_branch_rules_anchor_each_affected_arm() {
|
||||
if !core_available() {
|
||||
return;
|
||||
}
|
||||
let good = include_str!("fixtures/rc2/multi-arm.mq.md");
|
||||
let good = include_str!("fixtures/control/multi-arm.mq.md");
|
||||
assert_no_control_rules(&load(good).unwrap());
|
||||
for (source, rule, anchor, related) in [
|
||||
(
|
||||
@@ -392,11 +377,11 @@ fn rc2_branch_rules_anchor_each_affected_arm() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rc2_jump_rules_check_the_arm_container_and_carrier_style() {
|
||||
if !rc2_available() {
|
||||
fn current_jump_rules_check_the_arm_container_and_carrier_style() {
|
||||
if !core_available() {
|
||||
return;
|
||||
}
|
||||
let good = include_str!("fixtures/rc2/loop-jumps.mq.md");
|
||||
let good = include_str!("fixtures/control/loop-jumps.mq.md");
|
||||
assert_no_control_rules(&load(good).unwrap());
|
||||
let styled = good
|
||||
.replace(" `continue`", " *continue*")
|
||||
|
||||
Reference in new issue
Block a user