git @ Cat's Eye Technologies Falderal / e665256
Implement -k flag to skip named functionalities. catseye 10 years ago
4 changed file(s) with 53 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
8989 to the Functionality-definition pragmas given in the Falderal file;
9090 to replace them, you must first clear the ones with that name from
9191 the file by supplying `-c foo` on the command line.
92 * `falderal` also allows tests for named functionalities to be skipped
93 completely, by passing the name of the functionality to be skipped
94 after a `-k` flag on the command line.
9295 * The Markdown formatter now formats Bird-style embedded code with
9396 HTML embedded in the Markdown document. This is so that it can
9497 be styled independently from, and thus distinguished from, any plain
118121 first file would be in effect at the start of the second file.
119122 Files are now loaded and processed seperately.
120123
121 TODO:
122
123 * Command-line option to skip tests for given functionalities.
124
125124 Version 0.5 "The Loop" (current released version):
126125
127126 * The command-line format of `falderal` has changed, for the better.
22 loadText,
33 parseFunctionality,
44 collectFunctionalityDefinitions,
5 stripFunctionalities,
56 assignFunctionalities
67 ) where
78
133134 convertLinesToBlocks [] = []
134135
135136 --
137 -- Remove all tests for the given functionality from a list of blocks.
138 -- The functionality to be removed is typically a NamedFunctionality.
139 -- Third argument should initially be False, and indicates whether we are
140 -- stripping.
141 --
142
143 stripFunctionalities :: [Block] -> [Functionality] -> Bool -> [Block]
144
145 stripFunctionalities [] _ _ = []
146 stripFunctionalities (d@(Directive (TestsFor fn)):rest) fns _
147 | fn `elem` fns = stripFunctionalities rest fns True
148 | otherwise = d:stripFunctionalities rest fns False
149 stripFunctionalities (other:rest) names False =
150 other:stripFunctionalities rest names False
151 stripFunctionalities (other:rest) names True =
152 stripFunctionalities rest names True
153
154 --
136155 -- Give each test block a functionality, expanding named functionalities to
137156 -- concrete functionalities as needed. Strip all Directives and Sections
138157 -- from the list of blocks.
66 loadFile,
77 parseFunctionality,
88 collectFunctionalityDefinitions,
9 stripFunctionalities,
910 assignFunctionalities
1011 )
1112 import Test.Falderal.Partitioner (
7374
7475 determineFunctionalitiesToSkip [] = []
7576 determineFunctionalitiesToSkip (SkipFunctionality name:rest) =
76 (name:determineFunctionalitiesToSkip rest)
77 ((NamedFunctionality name):determineFunctionalitiesToSkip rest)
7778 determineFunctionalitiesToSkip (_:rest) =
7879 determineFunctionalitiesToSkip rest
7980
131132 dispatch _ _ = putStrLn header
132133
133134 --
135 -- Loading a set of files
136 -- NOTE: this runs each file into the last -- so only use it for formatting.
137 --
138
139 loadFiles [] = do
140 return ([], [])
141 loadFiles (fileName:rest) = do
142 (ls, bs) <- loadFile fileName
143 (restLs, restBs) <- loadFiles rest
144 return (ls ++ restLs, bs ++ restBs)
145
146 --
134147 -- Orchestrating the tests
135148 --
136149
146159 (lines, blocks) <- loadFile fileName
147160 fds <- return $ collectFunctionalityDefinitions lines
148161 fds' <- return $ clearFuncs fds funcsToClear
149 blocks' <- return $ assignFunctionalities blocks [] (fds' ++ funcDefs)
150 blocks'' <- return $ removeFuncsToSkip blocks' funcsToSkip
162 blocks' <- return $ stripFunctionalities blocks funcsToSkip False
163 blocks'' <- return $ assignFunctionalities blocks' [] (fds' ++ funcDefs)
151164 [haskellBlocks, shellBlocks] <- return $ partitionTests preds blocks''
152165 haskellBlocks' <- testHaskell haskellBlocks flags
153166 shellBlocks' <- testShell shellBlocks flags
158171 -- Transforming tests before running them
159172 --
160173
161 -- NOTE: this runs each file into the last -- not so good, defn's and such bleed
162 loadFiles [] = do
163 return ([], [])
164 loadFiles (fileName:rest) = do
165 (ls, bs) <- loadFile fileName
166 (restLs, restBs) <- loadFiles rest
167 return (ls ++ restLs, bs ++ restBs)
168
169174 clearFuncs [] names = []
170175 clearFuncs (def@(name,fn):rest) names
171176 | name `elem` names = clearFuncs rest names
172177 | otherwise = (def:clearFuncs rest names)
173
174 removeFuncsToSkip blocks funcsToSkip =
175 blocks
176178
177179 --
178180 -- Running the tests
107107 --------------------------------
108108
109109 EOF
110 cd eg
111 falderal test echo.falderal >../actual.txt
112 cd ..
110 falderal test eg/echo.falderal >actual.txt
113111 diff -u expected.txt actual.txt
114112 EECHO=$?
115113 rm -f expected.txt actual.txt
147145 rm -f expected.txt actual.txt
148146
149147 echo 'Testing functionality definition on command line...'
148
150149 cat >expected.txt <<EOF
151150 falderal: Can't find functionality "Count lines" in []
152151 EOF
187186 falderal -c "Echo" -f "Echo:shell command \"echo '%(test-text)'\"" test eg/echo.falderal >actual.txt
188187 diff -u expected.txt actual.txt
189188 ECL4=$?
189 rm -f expected.txt actual.txt
190
191 echo 'Testing functionality skipping from the command line...'
192
193 cat >expected.txt <<EOF
194 --------------------------------
195 Total tests: 0, failures: 0
196 --------------------------------
197
198 EOF
199 falderal test -k "Echo" eg/echo.falderal >actual.txt
200 diff -u expected.txt actual.txt
201 EECHO=$?
190202 rm -f expected.txt actual.txt
191203
192204 echo 'Testing that Tests-for pragma needs to be specified...'