From a3753885bb513c8927056d8daf5a651d0191092b Mon Sep 17 00:00:00 2001 From: Julian Sutherland Date: Fri, 7 Sep 2018 10:04:05 -0700 Subject: [PATCH] Reordered elements of severity array to make compare more meaningful. This will be helpful in merging inferBO and Quandary commits in QuandaryBO Reviewed By: ezgicicek Differential Revision: D9700516 fbshipit-source-id: c96a8240d --- infer/src/IR/Exceptions.ml | 2 +- infer/src/IR/Exceptions.mli | 2 +- infer/src/unit/SeverityTests.ml | 18 ++++++++++++++++++ infer/src/unit/inferunit.ml | 3 ++- 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 infer/src/unit/SeverityTests.ml diff --git a/infer/src/IR/Exceptions.ml b/infer/src/IR/Exceptions.ml index e846db96d..b25801cd0 100644 --- a/infer/src/IR/Exceptions.ml +++ b/infer/src/IR/Exceptions.ml @@ -29,7 +29,7 @@ type err_class = Checker | Prover | Nocat | Linters [@@deriving compare] let equal_err_class = [%compare.equal: err_class] (** severity of the report *) -type severity = Advice | Error | Info | Like | Warning [@@deriving compare] +type severity = Like | Info | Advice | Warning | Error [@@deriving compare] let equal_severity = [%compare.equal: severity] diff --git a/infer/src/IR/Exceptions.mli b/infer/src/IR/Exceptions.mli index 06a6b80ee..ec9b9311c 100644 --- a/infer/src/IR/Exceptions.mli +++ b/infer/src/IR/Exceptions.mli @@ -22,7 +22,7 @@ val equal_visibility : visibility -> visibility -> bool val string_of_visibility : visibility -> string (** severity of the report *) -type severity = Advice | Error | Info | Like | Warning [@@deriving compare] +type severity = Like | Info | Advice | Warning | Error [@@deriving compare] val equal_severity : severity -> severity -> bool diff --git a/infer/src/unit/SeverityTests.ml b/infer/src/unit/SeverityTests.ml new file mode 100644 index 000000000..1b8c1f8d3 --- /dev/null +++ b/infer/src/unit/SeverityTests.ml @@ -0,0 +1,18 @@ +(* + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +open! IStd +open OUnit2 + +let order_tests _ = + assert_equal (-1) ([%compare: Exceptions.severity] Exceptions.Like Exceptions.Info) ; + assert_equal (-1) ([%compare: Exceptions.severity] Exceptions.Info Exceptions.Advice) ; + assert_equal (-1) ([%compare: Exceptions.severity] Exceptions.Advice Exceptions.Warning) ; + assert_equal (-1) ([%compare: Exceptions.severity] Exceptions.Warning Exceptions.Error) + + +let tests = "severity_test_suite" >::: ["severity_order_tests" >:: order_tests] diff --git a/infer/src/unit/inferunit.ml b/infer/src/unit/inferunit.ml index 96e3521f9..a2f55528b 100644 --- a/infer/src/unit/inferunit.ml +++ b/infer/src/unit/inferunit.ml @@ -41,7 +41,8 @@ let () = ; SchedulerTests.tests ; StacktraceTests.tests ; TaintTests.tests - ; TraceTests.tests ] + ; TraceTests.tests + ; SeverityTests.tests ] @ ClangTests.tests ) in let test_suite = "all" >::: tests in