Many of our tests in `tests/lean/run/` produce output from `#eval` (or `#check`) statements, that is then ignored. This PR tries to capture all the useful output using `#guard_msgs`. I've only done a cursory check that the output is still sane --- there is a chance that some "unchecked" tests have already accumulated regressions and this just cements them! In the other direction, I did identify two rotten tests: * a minor one in `setStructInstNotation.lean`, where a comment says `Set Nat`, but `#check` actually prints `?_`. Weird? * `CompilerProbe.lean` is generating empty output, apparently indicating that something is broken, but I don't know the signficance of this file. In any case, I'll ask about these elsewhere. (This started by noticing that a recent `grind` test file had an untested `trace_state`, and then got carried away.)
49 lines
1.3 KiB
Text
49 lines
1.3 KiB
Text
import Lean
|
|
import Lean.Compiler.LCNF.Probing
|
|
open Lean.Compiler.LCNF
|
|
|
|
-- Note: 2024-05-15: At the time of adding #guard_msgs here, the tests seem to all be failing.
|
|
|
|
-- Find functions that have jps which take a lambda
|
|
/-- info: #[] -/
|
|
#guard_msgs in
|
|
#eval
|
|
Probe.runGlobally (phase := .mono) <|
|
|
Probe.filterByJp (·.params.anyM (fun param => return param.type.isForall)) >=>
|
|
Probe.declNames >=>
|
|
Probe.toString
|
|
|
|
-- Count lambda lifted functions
|
|
def lambdaCounter : Probe Decl Nat :=
|
|
Probe.filter (fun decl =>
|
|
if let .str _ val := decl.name then
|
|
return val.startsWith "_lam"
|
|
else
|
|
return false) >=>
|
|
Probe.declNames >=>
|
|
Probe.count
|
|
|
|
-- Run everywhere
|
|
/-- info: #[0] -/
|
|
#guard_msgs in
|
|
#eval
|
|
Probe.runGlobally (phase := .mono) <|
|
|
lambdaCounter
|
|
|
|
-- Run limited
|
|
/-- info: #[0] -/
|
|
#guard_msgs in
|
|
#eval
|
|
Probe.runOnModule `Lean.Compiler.LCNF.JoinPoints (phase := .mono) <|
|
|
lambdaCounter
|
|
|
|
-- Find most commonly used function with threshold
|
|
/-- info: #[] -/
|
|
#guard_msgs in
|
|
#eval
|
|
Probe.runOnModule `Lean.Compiler.LCNF.JoinPoints (phase := .mono) <|
|
|
Probe.getLetValues >=>
|
|
Probe.filter (fun e => return e matches .const ..) >=>
|
|
Probe.map (fun | .const declName .. => return s!"{declName}" | _ => unreachable!) >=>
|
|
Probe.countUniqueSorted >=>
|
|
Probe.filter (fun (_, count) => return count > 100)
|