Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### unreleased

### Changed

- Paths are normalized to drop the directory prefix ("./" on MacOs and Linux)
before pretty printing them (#482, @shonfeder).

### 2.6.0

#### Added
Expand Down
11 changes: 11 additions & 0 deletions bin/cli.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ open Cmdliner

let named wrapper = Term.(app (const wrapper))

let normalize_file_path filename =
let local_prefix = Filename.current_dir_name ^ Filename.dir_sep in
let len_prefix = String.length local_prefix in
if
String.length filename >= len_prefix
&& String.equal (String.sub filename 0 len_prefix) local_prefix
then
(* Strip current directory prefix *)
String.sub filename len_prefix (String.length filename - len_prefix)
else filename

let non_deterministic =
let doc = "Run non-deterministic tests." in
let env = Cmd.Env.info ~doc "MDX_RUN_NON_DETERMINISTIC" in
Expand Down
1 change: 1 addition & 0 deletions bin/cli.mli
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
open Cmdliner.Term

val named : ('a -> 'b) -> 'a t -> 'b t
val normalize_file_path : string -> string
val non_deterministic : [> `Non_deterministic of bool ] t
val syntax : [> `Syntax of Mdx.Syntax.t option ] t
val file : [> `File of string ] t
Expand Down
2 changes: 1 addition & 1 deletion bin/dune_gen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let run (`Setup ()) (`Prelude prelude) (`Directories dirs) =
in

let pp_prelude ppf (env, filename) =
Fmt.pf ppf "(%a, %S)" pp_env env filename
Fmt.pf ppf "(%a, %S)" pp_env env (Cli.normalize_file_path filename)
in

let pp_preludes ppf preludes =
Expand Down
3 changes: 2 additions & 1 deletion bin/pp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ let vpad_of_lines t =
in
aux 0 t

let pp_line_directive ppf (file, line) = Fmt.pf ppf "#%d %S" line file
let pp_line_directive ppf (file, line) =
Fmt.pf ppf "#%d %S" line (Cli.normalize_file_path file)

let rec add_semi_semi = function
| [] -> []
Expand Down
3 changes: 1 addition & 2 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,4 @@
result
(alcotest :with-test))
(conflicts
(result (< 1.5))
(dune (and :with-test (= 3.24.0)))))
(result (< 1.5))))
1 change: 0 additions & 1 deletion mdx.opam
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ depends: [
]
conflicts: [
"result" {< "1.5"}
"dune" {with-test & = "3.24.0"}
]
build: [
["dune" "subst"] {dev}
Expand Down
Loading