Skip to content

Commit

Permalink
Merge pull request #261 from CraigFe/quote-trailing-whitespace
Browse files Browse the repository at this point in the history
Quote pretty-printed diffs to indicate trailing whitespace
  • Loading branch information
craigfe authored Jul 15, 2020
2 parents 7455a14 + bb99639 commit baf5563
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 107 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### Unreleased

- Surround pretty-printed diffs with quotes to make trailing whitespace more
obvious. (#261, @CraigFe)

### 1.2.0 (2020-07-13)

- Add an `alcotest-mirage` package, allowing the construction of MirageOS
Expand Down
7 changes: 4 additions & 3 deletions src/alcotest-engine/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,13 @@ let check (type a) (t : a testable) msg (expected : a) (actual : a) =
let s = const string in
let pp_error = const Pp.tag `Fail ++ s (" " ^ msg)
and pp_expected ppf () =
Fmt.string ppf " Expected: ";
(styled `Green (pp t)) ppf expected;
Fmt.pf ppf " Expected: `%a'" (styled `Green (pp t)) expected;
Format.pp_print_if_newline ppf ();
Fmt.cut ppf ();
()
and pp_actual = s " Received: " ++ const (styled `Red (pp t)) actual in
and pp_actual ppf () =
Fmt.pf ppf " Received: `%a'" (styled `Red (pp t)) actual
in
raise
(Core.Check_error
Fmt.(vbox (pp_error ++ cut ++ cut ++ pp_expected ++ cut ++ pp_actual)))
Expand Down
52 changes: 26 additions & 26 deletions test/e2e/alcotest/failing/check_basic.expected
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ This run has ID `<uuid>'.
└──────────────────────────────────────────────────────────────────────────────┘
FAIL bool

Expected: true
Received: false
Expected: `true'
Received: `false'
──────────────────────────────────────────────────────────────────────────────


Expand All @@ -43,8 +43,8 @@ FAIL bool
└──────────────────────────────────────────────────────────────────────────────┘
FAIL int

Expected: 1
Received: 2
Expected: `1'
Received: `2'
──────────────────────────────────────────────────────────────────────────────


Expand All @@ -53,8 +53,8 @@ FAIL int
└──────────────────────────────────────────────────────────────────────────────┘
FAIL int32

Expected: 2147483647
Received: -2147483648
Expected: `2147483647'
Received: `-2147483648'
──────────────────────────────────────────────────────────────────────────────


Expand All @@ -63,8 +63,8 @@ FAIL int32
└──────────────────────────────────────────────────────────────────────────────┘
FAIL int64

Expected: 9223372036854775807
Received: -9223372036854775808
Expected: `9223372036854775807'
Received: `-9223372036854775808'
──────────────────────────────────────────────────────────────────────────────


Expand All @@ -73,8 +73,8 @@ FAIL int64
└──────────────────────────────────────────────────────────────────────────────┘
FAIL float

Expected: 1
Received: 2
Expected: `1'
Received: `2'
──────────────────────────────────────────────────────────────────────────────


Expand All @@ -83,8 +83,8 @@ FAIL float
└──────────────────────────────────────────────────────────────────────────────┘
FAIL char

Expected: a
Received: b
Expected: `a'
Received: `b'
──────────────────────────────────────────────────────────────────────────────


Expand All @@ -93,8 +93,8 @@ FAIL char
└──────────────────────────────────────────────────────────────────────────────┘
FAIL string

Expected: Lorem ipsum
Received: dolor sit amet.
Expected: `Lorem ipsum'
Received: `dolor sit amet.'
──────────────────────────────────────────────────────────────────────────────


Expand All @@ -103,8 +103,8 @@ FAIL string
└──────────────────────────────────────────────────────────────────────────────┘
FAIL bytes

Expected: "\001\002\003"
Received: "\001\000\003"
Expected: `"\001\002\003"'
Received: `"\001\000\003"'
──────────────────────────────────────────────────────────────────────────────


Expand All @@ -113,8 +113,8 @@ FAIL bytes
└──────────────────────────────────────────────────────────────────────────────┘
FAIL list

Expected: [a; b]
Received: [a; c]
Expected: `[a; b]'
Received: `[a; c]'
──────────────────────────────────────────────────────────────────────────────


Expand All @@ -123,8 +123,8 @@ FAIL list
└──────────────────────────────────────────────────────────────────────────────┘
FAIL array

Expected: [|0; 9223372036854775807|]
Received: [|0; 1; 9223372036854775807|]
Expected: `[|0; 9223372036854775807|]'
Received: `[|0; 1; 9223372036854775807|]'
──────────────────────────────────────────────────────────────────────────────


Expand All @@ -133,8 +133,8 @@ FAIL array
└──────────────────────────────────────────────────────────────────────────────┘
FAIL option some

Expected: Some 1
Received: Some 2
Expected: `Some 1'
Received: `Some 2'
──────────────────────────────────────────────────────────────────────────────


Expand All @@ -143,8 +143,8 @@ FAIL option some
└──────────────────────────────────────────────────────────────────────────────┘
FAIL result

Expected: Ok 1
Received: Error ()
Expected: `Ok 1'
Received: `Error ()'
──────────────────────────────────────────────────────────────────────────────


Expand All @@ -153,8 +153,8 @@ FAIL result
└──────────────────────────────────────────────────────────────────────────────┘
FAIL pair

Expected: (1, a)
Received: (1, b)
Expected: `(1, a)'
Received: `(1, b)'
──────────────────────────────────────────────────────────────────────────────

13 failures! in <test-duration>s. 13 tests run.
Expand Down
156 changes: 78 additions & 78 deletions test/e2e/alcotest/failing/check_long.expected
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ This run has ID `<uuid>'.
└──────────────────────────────────────────────────────────────────────────────┘
FAIL list

Expected: [a; b; c; d; e; f; g; h; i; j; k; l; m; n; o; p; q; r; s;
t; u; v; w; x; y; z; A]
Expected: `[a; b; c; d; e; f; g; h; i; j; k; l; m; n; o; p; q; r;
s; t; u; v; w; x; y; z; A]'

Received: [a; b; c; d; e; f; g; h; i; j; k; l; m; n; o; p; q; r; s;
t; u; v; w; x; y; z; B]
Received: `[a; b; c; d; e; f; g; h; i; j; k; l; m; n; o; p; q; r;
s; t; u; v; w; x; y; z; B]'
──────────────────────────────────────────────────────────────────────────────


Expand All @@ -26,23 +26,23 @@ FAIL list
└──────────────────────────────────────────────────────────────────────────────┘
FAIL array

Expected: [|0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15;
16; 17; 18; 19; 20; 21; 22; 23; 24; 25; 26; 27; 28; 29;
30; 31; 32; 33; 34; 35; 36; 37; 38; 39; 40; 41; 42; 43;
44; 45; 46; 47; 48; 49; 50; 51; 52; 53; 54; 55; 56; 57;
58; 59; 60; 61; 62; 63; 64; 65; 66; 67; 68; 69; 70; 71;
72; 73; 74; 75; 76; 77; 78; 79; 80; 81; 82; 83; 84; 85;
86; 87; 88; 89; 90; 91; 92; 93; 94; 95; 96; 97; 98; 99;
9223372036854775807|]
Expected: `[|0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15;
16; 17; 18; 19; 20; 21; 22; 23; 24; 25; 26; 27; 28; 29;
30; 31; 32; 33; 34; 35; 36; 37; 38; 39; 40; 41; 42; 43;
44; 45; 46; 47; 48; 49; 50; 51; 52; 53; 54; 55; 56; 57;
58; 59; 60; 61; 62; 63; 64; 65; 66; 67; 68; 69; 70; 71;
72; 73; 74; 75; 76; 77; 78; 79; 80; 81; 82; 83; 84; 85;
86; 87; 88; 89; 90; 91; 92; 93; 94; 95; 96; 97; 98; 99;
9223372036854775807|]'

Received: [|0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15;
16; 17; 18; 19; 20; 21; 22; 23; 24; 25; 26; 27; 28; 29;
30; 31; 32; 33; 34; 35; 36; 37; 38; 39; 40; 41; 42; 43;
44; 45; 46; 47; 48; 49; 50; 51; 52; 53; 54; 55; 56; 57;
58; 59; 60; 61; 62; 63; 64; 65; 66; 67; 68; 69; 70; 71;
72; 73; 74; 75; 76; 77; 78; 79; 80; 81; 82; 83; 84; 85;
86; 87; 88; 89; 90; 91; 92; 93; 94; 95; 96; 97; 98; 99;
-9223372036854775808|]
Received: `[|0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15;
16; 17; 18; 19; 20; 21; 22; 23; 24; 25; 26; 27; 28; 29;
30; 31; 32; 33; 34; 35; 36; 37; 38; 39; 40; 41; 42; 43;
44; 45; 46; 47; 48; 49; 50; 51; 52; 53; 54; 55; 56; 57;
58; 59; 60; 61; 62; 63; 64; 65; 66; 67; 68; 69; 70; 71;
72; 73; 74; 75; 76; 77; 78; 79; 80; 81; 82; 83; 84; 85;
86; 87; 88; 89; 90; 91; 92; 93; 94; 95; 96; 97; 98; 99;
-9223372036854775808|]'
──────────────────────────────────────────────────────────────────────────────


Expand All @@ -51,77 +51,77 @@ FAIL array
└──────────────────────────────────────────────────────────────────────────────┘
FAIL nested options

Expected: Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Expected: `Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some 1
Some
Some 1'

Received: Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Received: `Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some
Some 2
Some 2'
──────────────────────────────────────────────────────────────────────────────

3 failures! in <test-duration>s. 3 tests run.
Expand Down

0 comments on commit baf5563

Please # to comment.