From 7a0c775ef33b7238228cd6583c18a447cddfe186 Mon Sep 17 00:00:00 2001 From: Jaro Date: Wed, 19 Apr 2023 16:34:56 +0200 Subject: [PATCH] Rename golden files for easier tracking. --- .gitignore | 1 + .../loremIpsum20em.golden} | 0 .../spannedArabicFiller20em.golden} | 0 .../arabicFiller20em.golden} | 0 .../czechHello.golden} | 0 .../czechHelloParagraphNarrow.golden} | 0 .../czechHelloParagraphUltraNarrow.golden} | 0 .../devanagari.golden} | 0 .../devanagariAccent.golden} | 0 .../devanagariPrefixedAccent.golden} | 0 .../hardBreaksLTR.golden} | 0 .../hardBreaksRTL.golden} | 0 .../ligature.golden} | 0 .../ligatureParagraphBreak1.golden} | 0 .../ligatureParagraphBreak2.golden} | 0 .../lineHeightLarger.golden} | 0 .../lineHeightNormal.golden} | 0 .../lineHeightSmaller.golden} | 0 .../loremIpsum100em.golden} | 0 .../loremIpsum20em.golden} | 0 .../manySpaces.golden} | 0 .../mixedLanguageLTR.golden} | 0 .../mixedScriptWords.golden} | 0 .../spannedArabicFiller20em.golden} | 0 .../spannedLoremIpsum20em.golden} | 0 ...ontInfo => spannedLoremIpsum20em.fontInfo} | 0 .../golden => spannedLoremIpsum20em.golden} | 0 TESTING.md | 10 ++-- balkon.cabal | 28 +---------- test/Data/Text/ParagraphLayoutSpec.hs | 49 +++++++++++-------- 30 files changed, 37 insertions(+), 51 deletions(-) rename .golden/{loremIpsum20emPaginated/golden => paginatedParagraphLayout/loremIpsum20em.golden} (100%) rename .golden/{spannedArabicFiller20emPaginated/golden => paginatedParagraphLayout/spannedArabicFiller20em.golden} (100%) rename .golden/{arabicFiller20em/golden => paragraphLayout/arabicFiller20em.golden} (100%) rename .golden/{czechHelloParagraph/golden => paragraphLayout/czechHello.golden} (100%) rename .golden/{czechHelloParagraphNarrow/golden => paragraphLayout/czechHelloParagraphNarrow.golden} (100%) rename .golden/{czechHelloParagraphUltraNarrow/golden => paragraphLayout/czechHelloParagraphUltraNarrow.golden} (100%) rename .golden/{devanagariParagraph/golden => paragraphLayout/devanagari.golden} (100%) rename .golden/{devanagariAccentParagraph/golden => paragraphLayout/devanagariAccent.golden} (100%) rename .golden/{devanagariPrefixedAccentParagraph/golden => paragraphLayout/devanagariPrefixedAccent.golden} (100%) rename .golden/{hardBreaksLTRParagraph/golden => paragraphLayout/hardBreaksLTR.golden} (100%) rename .golden/{hardBreaksRTLParagraph/golden => paragraphLayout/hardBreaksRTL.golden} (100%) rename .golden/{ligatureParagraph/golden => paragraphLayout/ligature.golden} (100%) rename .golden/{ligatureParagraphBreak1/golden => paragraphLayout/ligatureParagraphBreak1.golden} (100%) rename .golden/{ligatureParagraphBreak2/golden => paragraphLayout/ligatureParagraphBreak2.golden} (100%) rename .golden/{lineHeightLarger/golden => paragraphLayout/lineHeightLarger.golden} (100%) rename .golden/{lineHeightNormal/golden => paragraphLayout/lineHeightNormal.golden} (100%) rename .golden/{lineHeightSmaller/golden => paragraphLayout/lineHeightSmaller.golden} (100%) rename .golden/{loremIpsum100em/golden => paragraphLayout/loremIpsum100em.golden} (100%) rename .golden/{loremIpsum20em/golden => paragraphLayout/loremIpsum20em.golden} (100%) rename .golden/{manySpacesParagraph/golden => paragraphLayout/manySpaces.golden} (100%) rename .golden/{mixedLanguageLTRParagraph/golden => paragraphLayout/mixedLanguageLTR.golden} (100%) rename .golden/{mixedScriptWordsParagraph/golden => paragraphLayout/mixedScriptWords.golden} (100%) rename .golden/{spannedArabicFiller20em/golden => paragraphLayout/spannedArabicFiller20em.golden} (100%) rename .golden/{spannedLoremIpsum20em/golden => paragraphLayout/spannedLoremIpsum20em.golden} (100%) rename .golden/shapedRuns/{spannedLoremIpsum20em/fontInfo => spannedLoremIpsum20em.fontInfo} (100%) rename .golden/shapedRuns/{spannedLoremIpsum20em/golden => spannedLoremIpsum20em.golden} (100%) diff --git a/.gitignore b/.gitignore index 74adca3..d8cd482 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /dist/ /dist-newstyle/ /.golden/**/actual +/.golden/**/*.actual diff --git a/.golden/loremIpsum20emPaginated/golden b/.golden/paginatedParagraphLayout/loremIpsum20em.golden similarity index 100% rename from .golden/loremIpsum20emPaginated/golden rename to .golden/paginatedParagraphLayout/loremIpsum20em.golden diff --git a/.golden/spannedArabicFiller20emPaginated/golden b/.golden/paginatedParagraphLayout/spannedArabicFiller20em.golden similarity index 100% rename from .golden/spannedArabicFiller20emPaginated/golden rename to .golden/paginatedParagraphLayout/spannedArabicFiller20em.golden diff --git a/.golden/arabicFiller20em/golden b/.golden/paragraphLayout/arabicFiller20em.golden similarity index 100% rename from .golden/arabicFiller20em/golden rename to .golden/paragraphLayout/arabicFiller20em.golden diff --git a/.golden/czechHelloParagraph/golden b/.golden/paragraphLayout/czechHello.golden similarity index 100% rename from .golden/czechHelloParagraph/golden rename to .golden/paragraphLayout/czechHello.golden diff --git a/.golden/czechHelloParagraphNarrow/golden b/.golden/paragraphLayout/czechHelloParagraphNarrow.golden similarity index 100% rename from .golden/czechHelloParagraphNarrow/golden rename to .golden/paragraphLayout/czechHelloParagraphNarrow.golden diff --git a/.golden/czechHelloParagraphUltraNarrow/golden b/.golden/paragraphLayout/czechHelloParagraphUltraNarrow.golden similarity index 100% rename from .golden/czechHelloParagraphUltraNarrow/golden rename to .golden/paragraphLayout/czechHelloParagraphUltraNarrow.golden diff --git a/.golden/devanagariParagraph/golden b/.golden/paragraphLayout/devanagari.golden similarity index 100% rename from .golden/devanagariParagraph/golden rename to .golden/paragraphLayout/devanagari.golden diff --git a/.golden/devanagariAccentParagraph/golden b/.golden/paragraphLayout/devanagariAccent.golden similarity index 100% rename from .golden/devanagariAccentParagraph/golden rename to .golden/paragraphLayout/devanagariAccent.golden diff --git a/.golden/devanagariPrefixedAccentParagraph/golden b/.golden/paragraphLayout/devanagariPrefixedAccent.golden similarity index 100% rename from .golden/devanagariPrefixedAccentParagraph/golden rename to .golden/paragraphLayout/devanagariPrefixedAccent.golden diff --git a/.golden/hardBreaksLTRParagraph/golden b/.golden/paragraphLayout/hardBreaksLTR.golden similarity index 100% rename from .golden/hardBreaksLTRParagraph/golden rename to .golden/paragraphLayout/hardBreaksLTR.golden diff --git a/.golden/hardBreaksRTLParagraph/golden b/.golden/paragraphLayout/hardBreaksRTL.golden similarity index 100% rename from .golden/hardBreaksRTLParagraph/golden rename to .golden/paragraphLayout/hardBreaksRTL.golden diff --git a/.golden/ligatureParagraph/golden b/.golden/paragraphLayout/ligature.golden similarity index 100% rename from .golden/ligatureParagraph/golden rename to .golden/paragraphLayout/ligature.golden diff --git a/.golden/ligatureParagraphBreak1/golden b/.golden/paragraphLayout/ligatureParagraphBreak1.golden similarity index 100% rename from .golden/ligatureParagraphBreak1/golden rename to .golden/paragraphLayout/ligatureParagraphBreak1.golden diff --git a/.golden/ligatureParagraphBreak2/golden b/.golden/paragraphLayout/ligatureParagraphBreak2.golden similarity index 100% rename from .golden/ligatureParagraphBreak2/golden rename to .golden/paragraphLayout/ligatureParagraphBreak2.golden diff --git a/.golden/lineHeightLarger/golden b/.golden/paragraphLayout/lineHeightLarger.golden similarity index 100% rename from .golden/lineHeightLarger/golden rename to .golden/paragraphLayout/lineHeightLarger.golden diff --git a/.golden/lineHeightNormal/golden b/.golden/paragraphLayout/lineHeightNormal.golden similarity index 100% rename from .golden/lineHeightNormal/golden rename to .golden/paragraphLayout/lineHeightNormal.golden diff --git a/.golden/lineHeightSmaller/golden b/.golden/paragraphLayout/lineHeightSmaller.golden similarity index 100% rename from .golden/lineHeightSmaller/golden rename to .golden/paragraphLayout/lineHeightSmaller.golden diff --git a/.golden/loremIpsum100em/golden b/.golden/paragraphLayout/loremIpsum100em.golden similarity index 100% rename from .golden/loremIpsum100em/golden rename to .golden/paragraphLayout/loremIpsum100em.golden diff --git a/.golden/loremIpsum20em/golden b/.golden/paragraphLayout/loremIpsum20em.golden similarity index 100% rename from .golden/loremIpsum20em/golden rename to .golden/paragraphLayout/loremIpsum20em.golden diff --git a/.golden/manySpacesParagraph/golden b/.golden/paragraphLayout/manySpaces.golden similarity index 100% rename from .golden/manySpacesParagraph/golden rename to .golden/paragraphLayout/manySpaces.golden diff --git a/.golden/mixedLanguageLTRParagraph/golden b/.golden/paragraphLayout/mixedLanguageLTR.golden similarity index 100% rename from .golden/mixedLanguageLTRParagraph/golden rename to .golden/paragraphLayout/mixedLanguageLTR.golden diff --git a/.golden/mixedScriptWordsParagraph/golden b/.golden/paragraphLayout/mixedScriptWords.golden similarity index 100% rename from .golden/mixedScriptWordsParagraph/golden rename to .golden/paragraphLayout/mixedScriptWords.golden diff --git a/.golden/spannedArabicFiller20em/golden b/.golden/paragraphLayout/spannedArabicFiller20em.golden similarity index 100% rename from .golden/spannedArabicFiller20em/golden rename to .golden/paragraphLayout/spannedArabicFiller20em.golden diff --git a/.golden/spannedLoremIpsum20em/golden b/.golden/paragraphLayout/spannedLoremIpsum20em.golden similarity index 100% rename from .golden/spannedLoremIpsum20em/golden rename to .golden/paragraphLayout/spannedLoremIpsum20em.golden diff --git a/.golden/shapedRuns/spannedLoremIpsum20em/fontInfo b/.golden/shapedRuns/spannedLoremIpsum20em.fontInfo similarity index 100% rename from .golden/shapedRuns/spannedLoremIpsum20em/fontInfo rename to .golden/shapedRuns/spannedLoremIpsum20em.fontInfo diff --git a/.golden/shapedRuns/spannedLoremIpsum20em/golden b/.golden/shapedRuns/spannedLoremIpsum20em.golden similarity index 100% rename from .golden/shapedRuns/spannedLoremIpsum20em/golden rename to .golden/shapedRuns/spannedLoremIpsum20em.golden diff --git a/TESTING.md b/TESTING.md index b1b9f70..dc9a39d 100644 --- a/TESTING.md +++ b/TESTING.md @@ -28,11 +28,11 @@ Steps: 4. Verify that `git status` reports no differences. - 5. Verify that a file named `actual` was generated by automated tests in - the directory `.golden/shapedRuns/spannedLoremIpsum20em/`. + 5. Verify that a file named `spannedLoremIpsum20em.actual` was generated by + automated tests in the directory `.golden/shapedRuns/`. - For example by running the command - `ls -l .golden/shapedRuns/spannedLoremIpsum20em/actual` + `ls -l .golden/shapedRuns/spannedLoremIpsum20em.actual` and checking the file's modification time. @@ -54,9 +54,9 @@ Steps: 1. Run Typograffiti with the font path, face index, pixel size, and scale set according to the contents of the file - `.golden/shapedRuns/spannedLoremIpsum20em/fontInfo` from Balkón, + `.golden/shapedRuns/spannedLoremIpsum20em.fontInfo` from Balkón, and with input set to be read from the file - `.golden/shapedRuns/spannedLoremIpsum20em/golden` from Balkón. + `.golden/shapedRuns/spannedLoremIpsum20em.golden` from Balkón. 2. Verify that text is displayed in the output window. diff --git a/balkon.cabal b/balkon.cabal index 1d2815b..3c432f1 100644 --- a/balkon.cabal +++ b/balkon.cabal @@ -68,32 +68,8 @@ extra-doc-files: -- or a tutorial module. extra-source-files: cabal.project, - .golden/arabicFiller20em/golden, - .golden/czechHelloParagraph/golden, - .golden/czechHelloParagraphNarrow/golden, - .golden/czechHelloParagraphUltraNarrow/golden, - .golden/devanagariAccentParagraph/golden, - .golden/devanagariParagraph/golden, - .golden/devanagariPrefixedAccentParagraph/golden, - .golden/hardBreaksLTRParagraph/golden, - .golden/hardBreaksRTLParagraph/golden, - .golden/ligatureParagraph/golden, - .golden/ligatureParagraphBreak1/golden, - .golden/ligatureParagraphBreak2/golden, - .golden/lineHeightLarger/golden, - .golden/lineHeightNormal/golden, - .golden/lineHeightSmaller/golden, - .golden/loremIpsum100em/golden, - .golden/loremIpsum20em/golden, - .golden/loremIpsum20emPaginated/golden, - .golden/manySpacesParagraph/golden, - .golden/mixedLanguageLTRParagraph/golden, - .golden/mixedScriptWordsParagraph/golden, - .golden/shapedRuns/spannedLoremIpsum20em/fontInfo, - .golden/shapedRuns/spannedLoremIpsum20em/golden, - .golden/spannedArabicFiller20em/golden, - .golden/spannedArabicFiller20emPaginated/golden, - .golden/spannedLoremIpsum20em/golden, + .golden/**/*.fontInfo, + .golden/**/*.golden, assets/fonts/plex/IBMPlexSansArabic-Regular.ttf, assets/fonts/plex/OFL.txt, assets/fonts/sarala/OFL.txt, diff --git a/test/Data/Text/ParagraphLayoutSpec.hs b/test/Data/Text/ParagraphLayoutSpec.hs index 5024305..6eb27d6 100644 --- a/test/Data/Text/ParagraphLayoutSpec.hs +++ b/test/Data/Text/ParagraphLayoutSpec.hs @@ -4,7 +4,7 @@ import Data.Text.Glyphize (Font) import Test.Hspec import Test.Hspec.Golden -import System.FilePath (()) +import System.FilePath ((<.>), ()) import Data.Text.ParagraphLayout import Data.Text.ParagraphLayout.FontLoader import Data.Text.ParagraphLayout.Internal.Plain.ParagraphLayout @@ -14,6 +14,15 @@ import Data.Text.ParagraphLayout.Rect type Page = (PageContinuity, ParagraphLayout) +goldenLayoutDir :: FilePath +goldenLayoutDir = ".golden" "paragraphLayout" + +goldenPagesDir :: FilePath +goldenPagesDir = ".golden" "paginatedParagraphLayout" + +goldenShapedRunsDir :: FilePath +goldenShapedRunsDir = ".golden" "shapedRuns" + class ShouldBeGolden a where shouldBeGolden :: a -> FilePath -> Golden a @@ -23,8 +32,8 @@ instance ShouldBeGolden ParagraphLayout where , encodePretty = show , writeToFile = \ path -> writeFile path . prettyShow , readFromFile = \ path -> readFile path >>= return . read - , goldenFile = ".golden" name "golden" - , actualFile = Just (".golden" name "actual") + , goldenFile = goldenLayoutDir name <.> "golden" + , actualFile = Just (goldenLayoutDir name <.> "actual") , failFirstTime = True } @@ -34,8 +43,8 @@ instance ShouldBeGolden Pages where , encodePretty = show . getPages , writeToFile = \ path -> writeFile path . prettyShow , readFromFile = \ path -> readFile path >>= return . Pages . read - , goldenFile = ".golden" name "golden" - , actualFile = Just (".golden" name "actual") + , goldenFile = goldenPagesDir name <.> "golden" + , actualFile = Just (goldenPagesDir name <.> "actual") , failFirstTime = True } @@ -45,13 +54,13 @@ instance ShouldBeGolden ShapedRuns where , encodePretty = show . getShapedRuns , writeToFile = \ path -> writeFile path . prettyShow , readFromFile = \ path -> readFile path >>= return . ShapedRuns . read - , goldenFile = ".golden" "shapedRuns" name "golden" - , actualFile = Just (".golden" "shapedRuns" name "actual") + , goldenFile = goldenShapedRunsDir name <.> "golden" + , actualFile = Just (goldenShapedRunsDir name <.> "actual") , failFirstTime = True } fontInfoPath :: String -> FilePath -fontInfoPath name = ".golden" "shapedRuns" name "fontInfo" +fontInfoPath name = goldenShapedRunsDir name <.> "fontInfo" shapedRuns' :: ParagraphLayout -> ShapedRuns shapedRuns' = ShapedRuns . shapedRuns @@ -112,7 +121,7 @@ spec = do it "applies hard breaks correctly" $ do let opts = ParagraphOptions font Normal 6000 let result = layoutPlain $ hardBreaksRTLParagraph opts - result `shouldBeGolden` "hardBreaksRTLParagraph" + result `shouldBeGolden` "hardBreaksRTL" describe "with Devanagari font" $ do font <- runIO $ loadFont devanagariFont 0 testingOptions @@ -127,7 +136,7 @@ spec = do x_size (paragraphRect result) `shouldBe` 645 it "is golden" $ do - result `shouldBeGolden` "devanagariAccentParagraph" + result `shouldBeGolden` "devanagariAccent" describe "lone accent character after prefix" $ do let @@ -139,12 +148,12 @@ spec = do x_size (paragraphRect result) `shouldBe` 0 it "is golden" $ do - result `shouldBeGolden` "devanagariPrefixedAccentParagraph" + result `shouldBeGolden` "devanagariPrefixedAccent" it "handles input without wrapping" $ do let opts = ParagraphOptions font Normal 9000 let result = layoutPlain $ devanagariParagraph opts - result `shouldBeGolden` "devanagariParagraph" + result `shouldBeGolden` "devanagari" describe "with Latin font" $ do -- Note: This font does not contain Japanese glyphs. @@ -163,12 +172,12 @@ spec = do it "handles Czech hello" $ do let opts = ParagraphOptions font Normal 8000 let result = layoutPlain $ czechHelloParagraph opts - result `shouldBeGolden` "czechHelloParagraph" + result `shouldBeGolden` "czechHello" it "renders an \"ffi\" ligature" $ do let opts = ParagraphOptions font Normal 8000 let result = layoutPlain $ ligatureParagraph opts - result `shouldBeGolden` "ligatureParagraph" + result `shouldBeGolden` "ligature" it "breaks an \"ffi\" ligature into \"ff\" + \"i\"" $ do let opts = ParagraphOptions font Normal 2418 @@ -183,7 +192,7 @@ spec = do it "handles mixed languages in LTR layout" $ do let opts = ParagraphOptions font Normal 8000 let result = layoutPlain $ mixedLanguageLTRParagraph opts - result `shouldBeGolden` "mixedLanguageLTRParagraph" + result `shouldBeGolden` "mixedLanguageLTR" it "handles normal line height" $ do let opts = ParagraphOptions font Normal 8000 @@ -234,17 +243,17 @@ spec = do it "wraps mixed-script words correctly" $ do let opts = ParagraphOptions font Normal 6000 let result = layoutPlain $ mixedScriptWordsParagraph opts - result `shouldBeGolden` "mixedScriptWordsParagraph" + result `shouldBeGolden` "mixedScriptWords" it "trims spaces around lines" $ do let opts = ParagraphOptions font Normal 6000 let result = layoutPlain $ manySpacesParagraph opts - result `shouldBeGolden` "manySpacesParagraph" + result `shouldBeGolden` "manySpaces" it "applies hard breaks correctly" $ do let opts = ParagraphOptions font Normal 5000 let result = layoutPlain $ hardBreaksLTRParagraph opts - result `shouldBeGolden` "hardBreaksLTRParagraph" + result `shouldBeGolden` "hardBreaksLTR" describe "paginate" $ do @@ -262,7 +271,7 @@ spec = do , pageWidows = 2 } pages = paginateAll popts pl - Pages pages `shouldBeGolden` "spannedArabicFiller20emPaginated" + Pages pages `shouldBeGolden` "spannedArabicFiller20em" describe "with Latin font" $ do font <- runIO $ loadFont latinFont 0 testingOptions @@ -278,7 +287,7 @@ spec = do , pageWidows = 3 } pages = paginateAll popts pl - Pages pages `shouldBeGolden` "loremIpsum20emPaginated" + Pages pages `shouldBeGolden` "loremIpsum20em" describe "shaped runs for demo" $ do -- 2.30.2