From 6ad8655117d3752828802bf3f1918ee963441063 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Wed, 27 Jul 2022 00:44:24 +0200 Subject: [PATCH 1/2] Make dce command less noisy w.r.t. unrelated test changes. Fixes https://github.com/rescript-lang/rescript-vscode/issues/515 --- analysis/src/Commands.ml | 12 +++++++++--- analysis/tests/src/Dce.res | 1 + analysis/tests/src/dce/DceTest.res | 1 + analysis/tests/src/expected/Dce.res.txt | 2 +- analysis/tests/src/expected/Debug.res.txt | 5 +++-- 5 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 analysis/tests/src/dce/DceTest.res diff --git a/analysis/src/Commands.ml b/analysis/src/Commands.ml index ad9ad4a89..5fcbca9ac 100644 --- a/analysis/src/Commands.ml +++ b/analysis/src/Commands.ml @@ -324,6 +324,9 @@ let test ~path = Sys.remove currentFile | "dce" -> print_endline ("DCE " ^ path); + Reanalyze.RunConfig.runConfig.suppress <- ["src"]; + Reanalyze.RunConfig.runConfig.unsuppress <- + [Filename.concat "src" "dce"]; DceCommand.command () | "doc" -> print_endline ("DocumentSymbol " ^ path); @@ -390,11 +393,14 @@ let test ~path = (Protocol.stringifyRange range) indent indent newText))) | "dia" -> diagnosticSyntax ~path - | "hin" -> ( + | "hin" -> let line_start = 0 in let line_end = 6 in - print_endline ("Inlay Hint " ^ path ^ " " ^ string_of_int line_start ^ ":" ^ string_of_int line_end); - inlayhint ~path ~pos:(line_start, line_end) ~maxLength:"25" ~debug:false) + print_endline + ("Inlay Hint " ^ path ^ " " ^ string_of_int line_start ^ ":" + ^ string_of_int line_end); + inlayhint ~path ~pos:(line_start, line_end) ~maxLength:"25" + ~debug:false | "cle" -> print_endline ("Code Lens " ^ path); codeLens ~path ~debug:false diff --git a/analysis/tests/src/Dce.res b/analysis/tests/src/Dce.res index 3de79ed60..bbf1b6e67 100644 --- a/analysis/tests/src/Dce.res +++ b/analysis/tests/src/Dce.res @@ -1,2 +1,3 @@ // ^dce +let x = 10 diff --git a/analysis/tests/src/dce/DceTest.res b/analysis/tests/src/dce/DceTest.res new file mode 100644 index 000000000..df5e54207 --- /dev/null +++ b/analysis/tests/src/dce/DceTest.res @@ -0,0 +1 @@ +let x = 12 diff --git a/analysis/tests/src/expected/Dce.res.txt b/analysis/tests/src/expected/Dce.res.txt index 9e47ef48c..f50cced86 100644 --- a/analysis/tests/src/expected/Dce.res.txt +++ b/analysis/tests/src/expected/Dce.res.txt @@ -1,3 +1,3 @@ DCE src/Dce.res -issues:249 +issues:2 diff --git a/analysis/tests/src/expected/Debug.res.txt b/analysis/tests/src/expected/Debug.res.txt index a95597eae..d854f6c44 100644 --- a/analysis/tests/src/expected/Debug.res.txt +++ b/analysis/tests/src/expected/Debug.res.txt @@ -3,8 +3,8 @@ Definition src/Debug.res 1:20 Dependencies: @rescript/react Source directories: ./node_modules/@rescript/react/src ./node_modules/@rescript/react/src/legacy Source files: ./node_modules/@rescript/react/src/React.res ./node_modules/@rescript/react/src/ReactDOM.res ./node_modules/@rescript/react/src/ReactDOMServer.res ./node_modules/@rescript/react/src/ReactDOMStyle.res ./node_modules/@rescript/react/src/ReactEvent.res ./node_modules/@rescript/react/src/ReactEvent.resi ./node_modules/@rescript/react/src/ReactTestUtils.res ./node_modules/@rescript/react/src/ReactTestUtils.resi ./node_modules/@rescript/react/src/RescriptReactErrorBoundary.res ./node_modules/@rescript/react/src/RescriptReactErrorBoundary.resi ./node_modules/@rescript/react/src/RescriptReactRouter.res ./node_modules/@rescript/react/src/RescriptReactRouter.resi ./node_modules/@rescript/react/src/legacy/ReactDOMRe.res ./node_modules/@rescript/react/src/legacy/ReasonReact.res -Source directories: ./src ./src/expected -Source files: ./src/Auto.res ./src/CodeLens.res ./src/CompletePrioritize1.res ./src/CompletePrioritize2.res ./src/Completion.res ./src/Component.res ./src/Component.resi ./src/CreateInterface.res ./src/Cross.res ./src/Dce.res ./src/Debug.res ./src/Definition.res ./src/DefinitionWithInterface.res ./src/DefinitionWithInterface.resi ./src/Div.res ./src/DocumentSymbol.res ./src/Fragment.res ./src/Highlight.res ./src/Hover.res ./src/InlayHint.res ./src/Jsx.res ./src/Jsx.resi ./src/LongIdentTest.res ./src/Object.res ./src/Patterns.res ./src/RecModules.res ./src/RecordCompletion.res ./src/RecoveryOnProp.res ./src/References.res ./src/ReferencesWithInterface.res ./src/ReferencesWithInterface.resi ./src/Rename.res ./src/RenameWithInterface.res ./src/RenameWithInterface.resi ./src/TableclothMap.ml ./src/TableclothMap.mli ./src/TypeDefinition.res ./src/Xform.res +Source directories: ./src ./src/dce ./src/expected +Source files: ./src/Auto.res ./src/CodeLens.res ./src/CompletePrioritize1.res ./src/CompletePrioritize2.res ./src/Completion.res ./src/Component.res ./src/Component.resi ./src/CreateInterface.res ./src/Cross.res ./src/Dce.res ./src/Debug.res ./src/Definition.res ./src/DefinitionWithInterface.res ./src/DefinitionWithInterface.resi ./src/Div.res ./src/DocumentSymbol.res ./src/Fragment.res ./src/Highlight.res ./src/Hover.res ./src/InlayHint.res ./src/Jsx.res ./src/Jsx.resi ./src/LongIdentTest.res ./src/Object.res ./src/Patterns.res ./src/RecModules.res ./src/RecordCompletion.res ./src/RecoveryOnProp.res ./src/References.res ./src/ReferencesWithInterface.res ./src/ReferencesWithInterface.resi ./src/Rename.res ./src/RenameWithInterface.res ./src/RenameWithInterface.resi ./src/TableclothMap.ml ./src/TableclothMap.mli ./src/TypeDefinition.res ./src/Xform.res ./src/dce/DceTest.res Impl cmt:./lib/bs/src/Auto.cmt res:./src/Auto.res Impl cmt:./lib/bs/src/CodeLens.cmt res:./src/CodeLens.res Impl cmt:./lib/bs/src/CompletePrioritize1.cmt res:./src/CompletePrioritize1.res @@ -37,6 +37,7 @@ IntfAndImpl cmti:./lib/bs/src/RenameWithInterface.cmti resi:./src/RenameWithInte IntfAndImpl cmti:./lib/bs/src/TableclothMap.cmti resi:./src/TableclothMap.mli cmt:./lib/bs/src/TableclothMap.cmt res:./src/TableclothMap.ml Impl cmt:./lib/bs/src/TypeDefinition.cmt res:./src/TypeDefinition.res Impl cmt:./lib/bs/src/Xform.cmt res:./src/Xform.res +Impl cmt:./lib/bs/src/dce/DceTest.cmt res:./src/dce/DceTest.res Dependency dirs: ./node_modules/@rescript/react/lib/bs/src ./node_modules/@rescript/react/lib/bs/src/legacy Opens from bsconfig: locItems: From ca2ff476a8b1d5ca01616007708732407f6a3a37 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Wed, 27 Jul 2022 00:48:32 +0200 Subject: [PATCH 2/2] tweak test --- analysis/tests/src/Dce.res | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/analysis/tests/src/Dce.res b/analysis/tests/src/Dce.res index bbf1b6e67..de0b8b498 100644 --- a/analysis/tests/src/Dce.res +++ b/analysis/tests/src/Dce.res @@ -1,3 +1,4 @@ +// Note: in test mode this only reports on src/dce + // ^dce -let x = 10