-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c27ea05
commit 1a8ca30
Showing
5 changed files
with
38 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,32 @@ | ||
(* open Odiff.Diff *) | ||
open Odiff.Diff | ||
|
||
let printDiffResult makeParsableOutput result = | ||
(* (match (result, makeParsableOutput) with *) | ||
(* | Layout, true -> "" *) | ||
(* | Layout, false -> *) | ||
(* Pastel.createElement *) | ||
(* ~children: *) | ||
(* [ *) | ||
(* (Pastel.createElement ~color:Red ~bold:true ~children:[ "Failure!" ] *) | ||
(* () [@JSX]); *) | ||
(* " Images have different layout.\n"; *) | ||
(* ] *) | ||
(* () [@JSX] *) | ||
(* | Pixel (_output, diffCount, _percentage, _lines), true when diffCount == 0 -> *) | ||
(* "" *) | ||
(* | Pixel (_output, diffCount, _percentage, _lines), false when diffCount == 0 *) | ||
(* -> *) | ||
(* Pastel.createElement *) | ||
(* ~children: *) | ||
(* [ *) | ||
(* (Pastel.createElement ~color:Green ~bold:true *) | ||
(* ~children:[ "Success!" ] () [@JSX]); *) | ||
(* " Images are equal.\n"; *) | ||
(* (Pastel.createElement ~dim:true *) | ||
(* ~children:[ "No diff output created." ] *) | ||
(* () [@JSX]); *) | ||
(* ] *) | ||
(* () [@JSX] *) | ||
(* | Pixel (_output, diffCount, diffPercentage, stack), true *) | ||
(* when not (Stack.is_empty stack) -> *) | ||
(* Int.to_string diffCount ^ ";" *) | ||
(* ^ Float.to_string diffPercentage *) | ||
(* ^ ";" *) | ||
(* ^ (stack *) | ||
(* |> Stack.fold (fun acc line -> (line |> Int.to_string) ^ "," ^ acc) "") *) | ||
(* | Pixel (_output, diffCount, diffPercentage, _), true -> *) | ||
(* Int.to_string diffCount ^ ";" ^ Float.to_string diffPercentage *) | ||
(* | Pixel (_output, diffCount, diffPercentage, _lines), false -> *) | ||
(* Pastel.createElement *) | ||
(* ~children: *) | ||
(* [ *) | ||
(* (Pastel.createElement ~color:Red ~bold:true ~children:[ "Failure!" ] *) | ||
(* () [@JSX]); *) | ||
(* " Images are different.\n"; *) | ||
(* "Different pixels: "; *) | ||
(* (Pastel.createElement ~color:Red ~bold:true *) | ||
(* ~children:[ Printf.sprintf "%i (%f%%)" diffCount diffPercentage ] *) | ||
(* () [@JSX]); *) | ||
(* ] *) | ||
(* () [@JSX]) *) | ||
(* |> Console.log; *) | ||
let reset_ppf = Spectrum.prepare_ppf Format.str_formatter in | ||
(match (result, makeParsableOutput) with | ||
| Layout, true -> () | ||
| Layout, false -> | ||
Spectrum.Simple.printf "@{<red>%s!@} Images have different layout.\n" | ||
"Failure!" | ||
| Pixel (_output, diffCount, diffPercentage, stack), true | ||
when not (Stack.is_empty stack) -> | ||
Int.to_string diffCount ^ ";" | ||
^ Float.to_string diffPercentage | ||
^ ";" | ||
^ (stack | ||
|> Stack.fold (fun acc line -> (line |> Int.to_string) ^ "," ^ acc) "") | ||
|> print_endline | ||
| Pixel (_output, diffCount, diffPercentage, _), true -> | ||
Int.to_string diffCount ^ ";" ^ Float.to_string diffPercentage | ||
|> print_endline | ||
| Pixel (_output, diffCount, _percentage, _lines), false when diffCount == 0 | ||
-> | ||
Spectrum.Simple.printf | ||
"@{<green><bold>Success!@} Images are equal.\n\ | ||
@{<dim>No diff output created.@}" | ||
| Pixel (_output, diffCount, diffPercentage, _lines), false -> | ||
Spectrum.Simple.printf | ||
"@{<red,bold>Failure!@} Images are different.\n\ | ||
Different pixels: @{<red,bold>%i (%f%%)@}" diffCount diffPercentage); | ||
|
||
reset_ppf (); | ||
result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
odiff-core | ||
odiff-io | ||
(cmdliner (= 1.3.0)) | ||
(spectrum (= 0.6.0)) | ||
) | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters