@@ -14,6 +14,8 @@ main = do
1414 } $ do
1515 StdoutTrim stackLocalInstallRoot <- liftIO $ cmd " stack path --local-install-root"
1616 StdoutTrim stackLocalBin <- liftIO $ cmd " stack path --local-bin"
17+ StdoutTrim gitDescribe <- liftIO $ cmd " git" [ " describe" , " --abbrev=8" , " --always" ]
18+ StdoutTrim gitSha <- liftIO $ cmd " git" [ " describe" , " --always" , " --match" , " NOT A TAG" , " --dirty" ]
1719
1820 let elmFormat = stackLocalInstallRoot </> " bin/elm-format" <.> exe
1921 let shellcheck = stackLocalBin </> " shellcheck" <.> exe
@@ -29,6 +31,7 @@ main = do
2931
3032 phony " build" $ need [ elmFormat ]
3133 phony " stack-test" $ need [ " _build/stack-test.ok" ]
34+ phony " profile" $ need [ " _build/tests/test-files/prof.ok" ]
3235
3336 phony " clean" $ do
3437 cmd_ " stack clean"
@@ -56,7 +59,6 @@ main = do
5659
5760 " generated/Build_elm_format.hs" %> \ out -> do
5861 alwaysRerun
59- (StdoutTrim gitDescribe) <- cmd " git" [ " describe" , " --abbrev=8" , " --always" ]
6062 writeFileChanged out $ unlines
6163 [ " module Build_elm_format where"
6264 , " "
@@ -70,6 +72,15 @@ main = do
7072 need generatedSourceFiles
7173 cmd_ " stack build --test --no-run-tests"
7274
75+ " _build/bin/elm-format-prof" %> \ out -> do
76+ StdoutTrim profileInstallRoot <- liftIO $ cmd " stack path --profile --local-install-root"
77+ sourceFiles <- getDirectoryFiles " " sourceFilesPattern
78+ need sourceFiles
79+ need generatedSourceFiles
80+ cmd_ " stack build --profile --executable-profiling --library-profiling"
81+ copyFileChanged (profileInstallRoot </> " bin/elm-format" <.> exe) out
82+
83+
7384 --
7485 -- Haskell tests
7586 --
@@ -124,6 +135,15 @@ main = do
124135 cmd_ (" bash" <.> exe) script elmFormat
125136 writeFile' out " "
126137
138+ " _build/tests/test-files/prof.ok" %> \ out -> do
139+ let oks =
140+ [ " _build/tests/test-files/good/Elm-0.17/prof.ok"
141+ , " _build/tests/test-files/good/Elm-0.18/prof.ok"
142+ , " _build/tests/test-files/good/Elm-0.19/prof.ok"
143+ ]
144+ need oks
145+ writeFile' out (unlines oks)
146+
127147
128148 -- Elm files
129149
@@ -138,6 +158,20 @@ main = do
138158 need oks
139159 writeFile' out (unlines elmFiles)
140160
161+ (" _build/tests/test-files/good/Elm-" ++ elmVersion ++ " /prof.ok" ) %> \ out -> do
162+ alwaysRerun
163+ elmFiles <- getDirectoryFiles " "
164+ [ " tests/test-files/good/Elm-" ++ elmVersion ++ " //*.elm"
165+ ]
166+ let oks = [" _profile" </> f -<.> (gitSha ++ " .prof" ) | f <- elmFiles]
167+ need oks
168+ writeFile' out (unlines oks)
169+
170+ (" _profile/tests/test-files/good/Elm-" ++ elmVersion ++ " //*." ++ gitSha ++ " .prof" ) %> \ out -> do
171+ let source = dropDirectory1 $ dropExtensions out <.> " elm"
172+ need [ " _build/bin/elm-format-prof" , source ]
173+ cmd_ " _build/bin/elm-format-prof" source " --output" " /dev/null" (" --elm-version=" ++ elmVersion) " +RTS" " -p" (" -po" ++ (out -<.> " " ))
174+
141175 (" _build/tests/test-files/*/Elm-" ++ elmVersion ++ " //*.elm_formatted" ) %> \ out -> do
142176 let source = dropDirectory1 $ out -<.> " elm"
143177 need [ elmFormat, source ]
0 commit comments