|
1 |
| -(* open Odiff.Diff *) |
| 1 | +open Odiff.Diff |
2 | 2 |
|
3 | 3 | let printDiffResult makeParsableOutput result =
|
4 |
| - (* (match (result, makeParsableOutput) with *) |
5 |
| - (* | Layout, true -> "" *) |
6 |
| - (* | Layout, false -> *) |
7 |
| - (* Pastel.createElement *) |
8 |
| - (* ~children: *) |
9 |
| - (* [ *) |
10 |
| - (* (Pastel.createElement ~color:Red ~bold:true ~children:[ "Failure!" ] *) |
11 |
| - (* () [@JSX]); *) |
12 |
| - (* " Images have different layout.\n"; *) |
13 |
| - (* ] *) |
14 |
| - (* () [@JSX] *) |
15 |
| - (* | Pixel (_output, diffCount, _percentage, _lines), true when diffCount == 0 -> *) |
16 |
| - (* "" *) |
17 |
| - (* | Pixel (_output, diffCount, _percentage, _lines), false when diffCount == 0 *) |
18 |
| - (* -> *) |
19 |
| - (* Pastel.createElement *) |
20 |
| - (* ~children: *) |
21 |
| - (* [ *) |
22 |
| - (* (Pastel.createElement ~color:Green ~bold:true *) |
23 |
| - (* ~children:[ "Success!" ] () [@JSX]); *) |
24 |
| - (* " Images are equal.\n"; *) |
25 |
| - (* (Pastel.createElement ~dim:true *) |
26 |
| - (* ~children:[ "No diff output created." ] *) |
27 |
| - (* () [@JSX]); *) |
28 |
| - (* ] *) |
29 |
| - (* () [@JSX] *) |
30 |
| - (* | Pixel (_output, diffCount, diffPercentage, stack), true *) |
31 |
| - (* when not (Stack.is_empty stack) -> *) |
32 |
| - (* Int.to_string diffCount ^ ";" *) |
33 |
| - (* ^ Float.to_string diffPercentage *) |
34 |
| - (* ^ ";" *) |
35 |
| - (* ^ (stack *) |
36 |
| - (* |> Stack.fold (fun acc line -> (line |> Int.to_string) ^ "," ^ acc) "") *) |
37 |
| - (* | Pixel (_output, diffCount, diffPercentage, _), true -> *) |
38 |
| - (* Int.to_string diffCount ^ ";" ^ Float.to_string diffPercentage *) |
39 |
| - (* | Pixel (_output, diffCount, diffPercentage, _lines), false -> *) |
40 |
| - (* Pastel.createElement *) |
41 |
| - (* ~children: *) |
42 |
| - (* [ *) |
43 |
| - (* (Pastel.createElement ~color:Red ~bold:true ~children:[ "Failure!" ] *) |
44 |
| - (* () [@JSX]); *) |
45 |
| - (* " Images are different.\n"; *) |
46 |
| - (* "Different pixels: "; *) |
47 |
| - (* (Pastel.createElement ~color:Red ~bold:true *) |
48 |
| - (* ~children:[ Printf.sprintf "%i (%f%%)" diffCount diffPercentage ] *) |
49 |
| - (* () [@JSX]); *) |
50 |
| - (* ] *) |
51 |
| - (* () [@JSX]) *) |
52 |
| - (* |> Console.log; *) |
| 4 | + let reset_ppf = Spectrum.prepare_ppf Format.str_formatter in |
| 5 | + (match (result, makeParsableOutput) with |
| 6 | + | Layout, true -> () |
| 7 | + | Layout, false -> |
| 8 | + Spectrum.Simple.printf "@{<red>%s!@} Images have different layout.\n" |
| 9 | + "Failure!" |
| 10 | + | Pixel (_output, diffCount, diffPercentage, stack), true |
| 11 | + when not (Stack.is_empty stack) -> |
| 12 | + Int.to_string diffCount ^ ";" |
| 13 | + ^ Float.to_string diffPercentage |
| 14 | + ^ ";" |
| 15 | + ^ (stack |
| 16 | + |> Stack.fold (fun acc line -> (line |> Int.to_string) ^ "," ^ acc) "") |
| 17 | + |> print_endline |
| 18 | + | Pixel (_output, diffCount, diffPercentage, _), true -> |
| 19 | + Int.to_string diffCount ^ ";" ^ Float.to_string diffPercentage |
| 20 | + |> print_endline |
| 21 | + | Pixel (_output, diffCount, _percentage, _lines), false when diffCount == 0 |
| 22 | + -> |
| 23 | + Spectrum.Simple.printf |
| 24 | + "@{<green><bold>Success!@} Images are equal.\n\ |
| 25 | + @{<dim>No diff output created.@}" |
| 26 | + | Pixel (_output, diffCount, diffPercentage, _lines), false -> |
| 27 | + Spectrum.Simple.printf |
| 28 | + "@{<red,bold>Failure!@} Images are different.\n\ |
| 29 | + Different pixels: @{<red,bold>%i (%f%%)@}" diffCount diffPercentage); |
| 30 | + |
| 31 | + reset_ppf (); |
53 | 32 | result
|
0 commit comments