Mutation testing toolkit for MoonBit projects
Dependencies
moon add Magic486/moon_mutest@0.1.7moon run --target js cmd/main -- scan "a == b && true"moon -C examples/consumer_workspace testmoon run --target js cmd/main -- run path/to/workspace --max-mutants 10 --first 10moon run --target js cmd/main -- run . \
--changed-since origin/master \
--max-mutants 30 \
--first 10moon run --target js cmd/main -- run . --changed-since HEAD~1 --max-mutants 20{
"changed_since": "origin/master",
"max_mutants": 30,
"first": 10,
"fail_under": 80,
"max_survived": 0
}{
"equivalent": [
{ "id": 12, "reason": "该分支在当前域模型中与原逻辑等价" }
]
}moon run --target js cmd/main -- run . \
--changed-since origin/master \
--fail-under 80 \
--max-survived 0 \
--max-compile-error 0 \
--max-timeout 0 \
--max-skipped 0# 强断言:预期 killed=1、score=100%、质量门禁通过
moon run --target js cmd/main -- run examples/quality_gate_workspace \
--max-mutants 1 --first 1 --fail-under 100 --max-survived 0 --max-skipped 0
# 弱断言:预期 survived=1、risk=high,并给出补测建议
moon run --target js cmd/main -- run examples/weak_test_workspace \
--max-mutants 1 --first 1# 供 CI 机器消费
moon run --target js cmd/main -- run . --format json --max-mutants 20
# 供代码评审或归档阅读
moon run --target js cmd/main -- run . --format markdown --max-mutants 20 > mutest-report.md
# 可离线打开的总览、文件风险排序与 survived 诊断
moon run --target js cmd/main -- run . --format html --max-mutants 20 > mutest-report.html| 参数 | 用途 |
|---|---|
| --profile basic\|boundary\|experimental | 选择变异规则集。 |
| --changed-since REF | 只测相对 Git 参考点发生变化的生产文件。 |
| --max-mutants N / --first N | 限制规划或实际执行数量。 |
| --id-start A --id-end B | 执行半开区间 [A, B) 的 mutant id。 |
| --include-tests | 也把测试文件作为 mutation 目标。 |
| --include-generated | 包含生成的 MoonBit 文件。 |
| --keep-temp / --temp-dir PATH | 保留或指定临时 workspace,便于排障。 |
| --no-fail-fast | 一个 mutant 执行全部命令,而不是在首次有效信号后停止。 |
| --format text\|markdown\|json\|html | 选择报告格式。 |
| --fail-under 与 --max-* | 启用质量门禁。 |
///|
test {
let manifest = @moon_mutest.manifest("a == b && true", file="demo.mbt")
inspect(manifest.summary.candidate_count, content="3")
}moon fmt
moon info
moon check --target all
moon test --target all
git diff --exit-codefn build_execution_plan_with_profile(files : ArrayView[SourceFile], config : MutestConfig, profile : RuleProfile) -> ExecutionPlanfn build_selected_batch_plan(plan : ExecutionPlan, selection : SelectionMode, strategy : BatchStrategy) -> BatchPlanfn classify_baseline(expected : ArrayView[RunnerCommand], results : ArrayView[CommandResult]) -> BaselineReportfn classify_project_sequence(mutation : ProjectMutation, commands : ArrayView[CommandResult]) -> ProjectMutantResultfn classify_sequence(candidate : MutationCandidate, commands : ArrayView[CommandResult]) -> MutantResultfn command_failure(phase : CommandPhase, code : Int, stdout? : String, stderr? : String) -> CommandResultfn discover_filtered(source : String, filter : MutationFilter, file? : String) -> Array[MutationCandidate]fn discover_with_profile(source : String, profile : RuleProfile, file? : String) -> Array[MutationCandidate]fn discover_with_rules(source : String, rules : ArrayView[MutationRule], file? : String) -> Array[MutationCandidate]fn evaluate_quality_gate_after_baseline(report : ProjectRunReport, gate : QualityGate, baseline : BaselineReport) -> QualityGateReportfn filter_candidates(candidates : ArrayView[MutationCandidate], filter : MutationFilter) -> Array[MutationCandidate]fn format_manifest_json_with_profile(source : String, profile : RuleProfile, file? : String) -> Stringfn format_unified_diff(file : String, line : Int, before : String, after : String) -> Stringfn generate_selected_runner_script(plan : ExecutionPlan, mode : SelectionMode, dialect : ShellDialect) -> RunnerScriptfn manifest_with_profile(source : String, profile : RuleProfile, file? : String) -> MutationManifestfn plan_project_filtered(files : ArrayView[SourceFile], filter : MutationFilter) -> ProjectMutationPlanfn plan_project_with_rules(files : ArrayView[SourceFile], filter : MutationFilter, rules : ArrayView[MutationRule]) -> ProjectMutationPlanfn project_result(mutation : ProjectMutation, outcome : MutantOutcome, detail? : String) -> ProjectMutantResultfn select_changed_workspace_files(files : ArrayView[SourceFile], changed_paths : ArrayView[String]) -> Array[SourceFile]fn select_project_mutations(plan : ProjectMutationPlan, mode : SelectionMode) -> Array[ProjectMutation]fn select_workspace_files(files : ArrayView[SourceFile], spec : WorkspaceFileSpec) -> Array[SourceFile]fn skip_execution_results_for_baseline(plan : ExecutionPlan, report : BaselineReport) -> Array[ProjectMutantResult]fn summarize_candidates(file : String, candidates : ArrayView[MutationCandidate]) -> MutationSummaryfn summarize_project_run(plan : ProjectMutationPlan, results : ArrayView[ProjectMutantResult]) -> ProjectRunReportfn summarize_workspace_selection(files : ArrayView[SourceFile], spec : WorkspaceFileSpec) -> WorkspaceSelectionReportMutation testing toolkit for MoonBit projects
Dependencies