@@ -302,13 +302,15 @@ let enforce (((sexps_rewriter, _), _) as input) conditions =
302302let enforce_diff (((sexps_rewriter , _ ), _ ) as input ) conditions =
303303 Sexps_rewriter. reset sexps_rewriter;
304304 let original =
305- Sexps_rewriter. contents sexps_rewriter |> Parsexp.Single. parse_string_exn
305+ Dunolint_engine. format_dune_file
306+ ~new_contents: (Sexps_rewriter. contents sexps_rewriter)
306307 in
307308 enforce_internal input conditions;
308309 let changed =
309- Sexps_rewriter. contents sexps_rewriter |> Parsexp.Single. parse_string_exn
310+ Dunolint_engine. format_dune_file
311+ ~new_contents: (Sexps_rewriter. contents sexps_rewriter)
310312 in
311- Expect_test_patdiff. print_patdiff_s original changed
313+ Expect_test_patdiff. print_patdiff original changed ~context: 3
312314;;
313315
314316let % expect_test " enforce" =
@@ -425,11 +427,11 @@ let%expect_test "add_name_via_enforce" =
425427 test [ name (equals main) ];
426428 [% expect
427429 {|
428- - 1 ,1 + 1 ,3
429- -| (executable (public_name my - cli))
430- +| (executable
431- +| (public_name my- cli)
432- +| (name main))
430+ - 1 ,2 + 1 ,3
431+ (executable
432+ -| (public_name my - cli))
433+ +| (public_name my- cli)
434+ +| (name main))
433435 | }];
434436 (* The invariant will be undefined if the field isn't there. *)
435437 test [ name (is_prefix " hey" ) ];
@@ -440,11 +442,11 @@ let%expect_test "add_name_via_enforce" =
440442 test [ name (and_ [ equals main; is_prefix " ma" ]) ];
441443 [% expect
442444 {|
443- - 1 ,1 + 1 ,3
444- -| (executable (public_name my - cli))
445- +| (executable
446- +| (public_name my- cli)
447- +| (name main))
445+ - 1 ,2 + 1 ,3
446+ (executable
447+ -| (public_name my - cli))
448+ +| (public_name my- cli)
449+ +| (name main))
448450 | }];
449451 (* Currently the application of invariant is not idempotent. See how, at the
450452 end of the application of this chain of [and_] the invariant no longer
@@ -453,11 +455,11 @@ let%expect_test "add_name_via_enforce" =
453455 test [ name (and_ [ equals main; is_prefix " hey_" ]) ];
454456 [% expect
455457 {|
456- - 1 ,1 + 1 ,3
457- -| (executable (public_name my - cli))
458- +| (executable
459- +| (public_name my- cli)
460- +| (name hey_main))
458+ - 1 ,2 + 1 ,3
459+ (executable
460+ -| (public_name my - cli))
461+ +| (public_name my- cli)
462+ +| (name hey_main))
461463 | }];
462464 (* When going through other blang constructs, currently we do not pick initial
463465 values. *)
@@ -499,11 +501,11 @@ let%expect_test "enforce_failures" =
499501 test [ public_name (equals (Dune.Executable.Public_name. v " public-main" )) ];
500502 [% expect
501503 {|
502- - 1 ,1 + 1 ,3
503- -| (executable (name my_exe))
504- +| (executable
505- +| (name my_exe)
506- +| (public_name public- main))
504+ - 1 ,2 + 1 ,3
505+ (executable
506+ -| (name my_exe))
507+ +| (name my_exe)
508+ +| (public_name public- main))
507509 | }];
508510 test [ public_name (is_prefix " prefix_" ) ];
509511 [% expect {|| }];
@@ -621,58 +623,58 @@ let%expect_test "remove_fields" =
621623 test [ not_ (has_field `instrumentation ) ];
622624 [% expect
623625 {|
624- - 1 ,6 + 1 ,5
626+ - 1 ,8 + 1 ,6
625627 (executable
626- (name my- exe)
627- (public_name my- cli)
628- -| (instrumentation (backend bisect_ppx))
629- (lint (pps ppx_linter))
630- (preprocess no_preprocessing))
628+ (name my- exe)
629+ (public_name my- cli)
630+ -| (instrumentation
631+ -| (backend bisect_ppx))
632+ (lint
633+ (pps ppx_linter))
634+ (preprocess no_preprocessing))
631635 | }];
632636 test [ not_ (has_field `lint ) ];
633637 [% expect
634638 {|
635- - 1 ,6 + 1 , 5
636- (executable
637- (name my - exe)
638- (public_name my - cli )
639- (instrumentation (backend bisect_ppx))
640- -| (lint ( pps ppx_linter))
641- (preprocess no_preprocessing))
639+ - 3 ,6 + 3 , 4
640+ (public_name my - cli)
641+ (instrumentation
642+ (backend bisect_ppx) )
643+ -| (lint
644+ -| (pps ppx_linter))
645+ (preprocess no_preprocessing))
642646 | }];
643647 test [ not_ (has_field `preprocess ) ];
644648 [% expect
645649 {|
646- - 1 ,6 + 1 ,5
647- (executable
648- (name my- exe)
649- (public_name my- cli)
650- (instrumentation (backend bisect_ppx))
651- -| (lint (pps ppx_linter))
652- -| (preprocess no_preprocessing))
653- +| (lint (pps ppx_linter)))
650+ - 4 ,5 + 4 ,4
651+ (instrumentation
652+ (backend bisect_ppx))
653+ (lint
654+ -| (pps ppx_linter))
655+ -| (preprocess no_preprocessing))
656+ +| (pps ppx_linter)))
654657 | }];
655658 test [ not_ (has_field `name ) ];
656659 [% expect
657660 {|
658- - 1 ,6 + 1 ,5
661+ - 1 ,5 + 1 ,4
659662 (executable
660- -| (name my- exe)
661- (public_name my- cli)
662- (instrumentation (backend bisect_ppx))
663- (lint (pps ppx_linter))
664- (preprocess no_preprocessing))
663+ -| (name my- exe)
664+ (public_name my- cli)
665+ (instrumentation
666+ (backend bisect_ppx))
665667 | }];
666668 test [ not_ (has_field `public_name ) ];
667669 [% expect
668670 {|
669671 - 1 ,6 + 1 ,5
670672 (executable
671- (name my- exe)
672- -| (public_name my- cli)
673- (instrumentation (backend bisect_ppx))
674- (lint (pps ppx_linter ))
675- (preprocess no_preprocessing))
673+ (name my- exe)
674+ -| (public_name my- cli)
675+ (instrumentation
676+ (backend bisect_ppx ))
677+ (lint
676678 | }];
677679 ()
678680;;
@@ -727,60 +729,59 @@ let%expect_test "field_condition_enforcement_with_existing_fields" =
727729 {|
728730 - 1 ,6 + 1 ,6
729731 (executable
730- (name my- exe)
731- -| (public_name my- cli)
732- +| (public_name new - name)
733- (instrumentation (backend bisect_ppx))
734- (lint (pps ppx_linter ))
735- (preprocess no_preprocessing))
732+ (name my- exe)
733+ -| (public_name my- cli)
734+ +| (public_name new - name)
735+ (instrumentation
736+ (backend bisect_ppx ))
737+ (lint
736738 | }];
737739 test [ public_name (is_prefix " cli-" ); public_name (is_suffix " -pub" ) ];
738740 [% expect
739741 {|
740742 - 1 ,6 + 1 ,6
741743 (executable
742- (name my- exe)
743- -| (public_name my- cli)
744- +| (public_name cli- my- cli- pub)
745- (instrumentation (backend bisect_ppx))
746- (lint (pps ppx_linter ))
747- (preprocess no_preprocessing))
744+ (name my- exe)
745+ -| (public_name my- cli)
746+ +| (public_name cli- my- cli- pub)
747+ (instrumentation
748+ (backend bisect_ppx ))
749+ (lint
748750 | }];
749751 test [ instrumentation (backend (Dune.Instrumentation.Backend.Name. v " coverage" )) ];
750752 [% expect
751753 {|
752- - 1 ,6 + 1 ,6
753- (executable
754- (name my- exe)
755- (public_name my- cli)
756- -| (instrumentation (backend bisect_ppx))
757- +| (instrumentation (backend coverage))
758- (lint (pps ppx_linter))
759- (preprocess no_preprocessing))
754+ - 2 ,7 + 2 ,7
755+ (name my- exe)
756+ (public_name my- cli)
757+ (instrumentation
758+ -| (backend bisect_ppx))
759+ +| (backend coverage))
760+ (lint
761+ (pps ppx_linter))
762+ (preprocess no_preprocessing))
760763 | }];
761764 test [ lint (pps (pp (Dune.Pp.Name. v " ppx_deriving" ))) ];
762765 [% expect
763766 {|
764- - 1 ,6 + 1 ,6
765- (executable
766- (name my- exe)
767- (public_name my- cli)
768- (instrumentation (backend bisect_ppx))
769- -| (lint (pps ppx_linter))
770- +| (lint (pps ppx_deriving ppx_linter))
771- (preprocess no_preprocessing))
767+ - 4 ,5 + 4 ,5
768+ (instrumentation
769+ (backend bisect_ppx))
770+ (lint
771+ -| (pps ppx_linter))
772+ +| (pps ppx_deriving ppx_linter))
773+ (preprocess no_preprocessing))
772774 | }];
773775 test [ preprocess (pps (pp (Dune.Pp.Name. v " ppx_compare" ))) ];
774776 [% expect
775777 {|
776- - 1 ,6 + 1 ,6
777- (executable
778- (name my- exe)
779- (public_name my- cli)
780- (instrumentation (backend bisect_ppx))
781- (lint (pps ppx_linter))
782- -| (preprocess no_preprocessing))
783- +| (preprocess (pps ppx_compare)))
778+ - 5 ,4 + 5 ,5
779+ (backend bisect_ppx))
780+ (lint
781+ (pps ppx_linter))
782+ -| (preprocess no_preprocessing))
783+ +| (preprocess
784+ +| (pps ppx_compare)))
784785 | }];
785786 ()
786787;;
0 commit comments