Skip to content

Commit

Permalink
Add command line option -set-exit-code
Browse files Browse the repository at this point in the history
  • Loading branch information
cknitt authored and cristianoc committed Jun 7, 2022
1 parent 76485a8 commit 9f3c0b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ module Cli = struct

let write = ref false

let exitCode = ref false

(* names to be considered live values *)
let liveNames = ref ([] : string list)

Expand Down
5 changes: 4 additions & 1 deletion src/Reanalyze.ml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ let runAnalysis ~cmtRoot ~ppf =
let nIssues = Log_.Stats.report () in
Log_.Stats.clear ();
if !Common.Cli.json then EmitJson.finish ();
if nIssues > 0 then exit 1
if nIssues > 0 && !Common.Cli.exitCode then exit 1

let cli () =
let analysisKindSet = ref false in
Expand Down Expand Up @@ -182,6 +182,9 @@ let cli () =
"comma-separated-path-prefixes Consider all values whose path has a \
prefix in the list as live" );
("-noalloc", Unit setNoalloc, "");
( "-set-exit-code",
Set Common.Cli.exitCode,
"Exit with code 1 in case an issue is detected" );
( "-suppress",
String
(fun s ->
Expand Down

0 comments on commit 9f3c0b0

Please sign in to comment.