Skip to content
Snippets Groups Projects
Commit 955c9c8e authored by Michele Alberti's avatar Michele Alberti
Browse files

[server] Add msg-key to use relative filepath, especially in tests.

parent 61981e35
No related branches found
No related tags found
No related merge requests found
...@@ -90,10 +90,15 @@ struct ...@@ -90,10 +90,15 @@ struct
let to_json p = let to_json p =
let path = Filepath.(Normalized.to_pretty_string p.pos_path) in let path = Filepath.(Normalized.to_pretty_string p.pos_path) in
let file =
if Server_parameters.has_relative_filepath ()
then path
else (p.Filepath.pos_path :> string)
in
`Assoc [ `Assoc [
"dir" , `String (Filename.dirname path) ; "dir" , `String (Filename.dirname path) ;
"base" , `String (Filename.basename path) ; "base" , `String (Filename.basename path) ;
"file" , `String (p.Filepath.pos_path :> string) ; "file" , `String file ;
"line" , `Int p.Filepath.pos_lnum ; "line" , `Int p.Filepath.pos_lnum ;
] ]
......
...@@ -73,3 +73,10 @@ let wkind = register_warn_category "inconsistent-kind" ...@@ -73,3 +73,10 @@ let wkind = register_warn_category "inconsistent-kind"
let wname = register_warn_category "invalid-name" let wname = register_warn_category "invalid-name"
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
(* --- Filepath Normalization --- *)
(* -------------------------------------------------------------------------- *)
let use_relative_filepath = register_category "use-relative-filepath"
let has_relative_filepath () = is_debug_key_enabled use_relative_filepath
(* -------------------------------------------------------------------------- *)
...@@ -32,4 +32,6 @@ val wpage : warn_category (** Inconsistent page warning *) ...@@ -32,4 +32,6 @@ val wpage : warn_category (** Inconsistent page warning *)
val wkind : warn_category (** Inconsistent category warning *) val wkind : warn_category (** Inconsistent category warning *)
val wname : warn_category (** Invalid name warning *) val wname : warn_category (** Invalid name warning *)
val has_relative_filepath: unit -> bool
(**************************************************************************) (**************************************************************************)
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
"sloc": { "sloc": {
"dir": "tests/batch", "dir": "tests/batch",
"base": "ast_services.i", "base": "ast_services.i",
"file": "file": "tests/batch/ast_services.i",
"/home/michele/work/frama-c/src/plugins/server/tests/batch/ast_services.i",
"line": 2 "line": 2
} }
}, },
...@@ -24,8 +23,7 @@ ...@@ -24,8 +23,7 @@
"sloc": { "sloc": {
"dir": "tests/batch", "dir": "tests/batch",
"base": "ast_services.i", "base": "ast_services.i",
"file": "file": "tests/batch/ast_services.i",
"/home/michele/work/frama-c/src/plugins/server/tests/batch/ast_services.i",
"line": 1 "line": 1
} }
} }
......
LOG: @PTEST_NAME@.out.json LOG: @PTEST_NAME@.out.json
OPT: -no-autoload-plugins -load-module server -check -server-batch @PTEST_DIR@/@PTEST_NAME@.json -server-batch-output-dir @PTEST_RESULT@ OPT: -no-autoload-plugins -load-module server -check -server-batch @PTEST_DIR@/@PTEST_NAME@.json -server-batch-output-dir @PTEST_RESULT@ -server-msg-key use-relative-filepath
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment