Skip to content

Commit 7e62c8d

Browse files
oughta: Rename from FileCheck
1 parent 9cd8223 commit 7e62c8d

37 files changed

+174
-171
lines changed

.github/workflows/ci.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,19 @@ jobs:
6767
(cd grease-cli && cabal check)
6868
(cd doc/diagrams && cabal check)
6969
(cd elf-edit-core-dump && cabal check)
70-
(cd filecheck && cabal check)
70+
(cd oughta && cabal check)
7171
7272
- name: Configure build
7373
shell: bash
7474
run: cabal configure --enable-tests
7575

76-
- name: Build FileCheck
76+
- name: Build Oughta
7777
shell: bash
78-
run: cabal build pkg:filecheck
78+
run: cabal build pkg:oughta
7979

80-
- name: Test FileCheck
80+
- name: Test Oughta
8181
shell: bash
82-
run: cabal test pkg:filecheck
82+
run: cabal test pkg:oughta
8383

8484
- name: Build grease-cli
8585
shell: bash
@@ -106,7 +106,7 @@ jobs:
106106
# identifiers from library dependencies. Since we are only building
107107
# Haddocks to ensure well-formedness, we consider this an acceptable
108108
# tradeoff.
109-
run: cabal haddock --disable-documentation pkg:grease pkg:grease-cli pkg:elf-edit-core-dump pkg:filecheck
109+
run: cabal haddock --disable-documentation pkg:grease pkg:grease-cli pkg:elf-edit-core-dump pkg:oughta
110110

111111
- name: Save cache store cache
112112
uses: actions/cache/save@v4

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ jobs:
2222
https://github.com/ndmitchell/hlint/releases/download/v3.8/hlint-3.8-x86_64-linux.tar.gz
2323
tar xvf hlint.tar.gz
2424
25-
./hlint-3.8/hlint grease{,-aarch32,-ppc,-x86}/src grease-cli/{main,src,tests} filecheck/{src,test}
25+
./hlint-3.8/hlint grease{,-aarch32,-ppc,-x86}/src grease-cli/{main,src,tests} oughta/{src,test}

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ packages:
66
grease-x86/grease-x86.cabal
77
doc/diagrams/grease-diagrams.cabal
88
elf-edit-core-dump
9-
filecheck/filecheck.cabal
9+
oughta/oughta.cabal
1010

1111
deps/macaw/base/
1212
deps/macaw/crucible-macaw-debug/

doc/dev.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ As always, see `--help` for more options.
6868
We treat a small number of hlint warnings as errors in CI. To run hlint locally, try:
6969

7070
```sh
71-
hlint grease{,-aarch32,-ppc,-x86}/src grease-cli/{main,src,tests} filecheck/{src,test}
71+
hlint grease{,-aarch32,-ppc,-x86}/src grease-cli/{main,src,tests} oughta/{src,test}
7272
```
7373

7474
## Source code

grease-cli/grease-cli.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,12 @@ test-suite grease-tests
201201
, containers
202202
, crucible-llvm
203203
, directory
204-
, filecheck
205204
, filepath
206205
, hedgehog
207206
, lumberjack
208207
, macaw-base
209208
, optparse-applicative
209+
, oughta
210210
, parameterized-utils
211211
, prettyprinter
212212
, tasty

grease-cli/tests/Main.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import Control.Monad.IO.Class (MonadIO, liftIO)
4949

5050
import qualified Options.Applicative as Opt
5151

52-
import FileCheck qualified as FileCheck
52+
import Oughta qualified as Ota
5353
import qualified Lumberjack as LJ
5454

5555
import qualified Test.Tasty as T
@@ -504,7 +504,7 @@ llvmTests = do
504504
res <- simulateLlvmSyntax opts la'
505505
logResults la' res
506506
Text.IO.writeFile (FilePath.replaceExtension path "out") logTxt
507-
let output = FileCheck.Output (Text.encodeUtf8 logTxt)
507+
let output = Ota.Output (Text.encodeUtf8 logTxt)
508508
let prelude =
509509
Text.unlines
510510
[ "function ok() check 'All goals passed!' end"
@@ -515,13 +515,13 @@ llvmTests = do
515515
, "end"
516516
, "function no_heuristic() check 'Unable to find a heuristic for any goal' end"
517517
]
518-
let prog0 = FileCheck.fromLineComments path ";; " content
519-
let prog = FileCheck.addPrefix prelude prog0
520-
FileCheck.Result r <- FileCheck.check prog output
518+
let prog0 = Ota.fromLineComments path ";; " content
519+
let prog = Ota.addPrefix prelude prog0
520+
Ota.Result r <- Ota.check prog output
521521
case r of
522522
Left f -> throwIO f
523523
Right s ->
524-
let ms = FileCheck.successMatches s in
524+
let ms = Ota.successMatches s in
525525
T.U.assertBool "Test has some assertions" (not (Seq.null ms))
526526

527527
llvmBcTests :: T.TestTree
File renamed without changes.
Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
# FileCheck
1+
# Oughta
22

33
## Overview
44

5-
FileCheck is a Haskell library inspired by the [command-line tool of the same
6-
name][llvm]. It is used to test programs that output text. The testing paradigm
7-
essentially combines golden testing with `grep`.
5+
Oughta is a Haskell library for testing programs that output text. The testing
6+
paradigm essentially combines golden testing with `grep`.
87

9-
[llvm]: https://llvm.org/docs/CommandGuide/FileCheck.html
8+
Oughta draws inspiration from LLVM's [FileCheck] and Rust's [compiletest].
109

11-
More precisely, FileCheck allows you to build parsers for the output of your
12-
program. The inputs to FileCheck are the output of the program under test and a
13-
separate, generally quite short program written in the FileCheck parsing DSL.
10+
[FileCheck]: https://llvm.org/docs/CommandGuide/FileCheck.html
11+
[compiletest]: https://rustc-dev-guide.rust-lang.org/tests/compiletest.html
12+
13+
More precisely, Oughta provides a DSL to build *recognizers* (i.e., parsers that
14+
simply accept or reject an string). The inputs to Oughta are a string (usually,
15+
the output of the program under test) and a separate, generally quite short
16+
program written in the Oughta DSL.
1417

1518
The simplest DSL procedure is `check`, which checks that the output contains a
1619
string. For example, the following test would pass:
@@ -28,10 +31,10 @@ check "world"
2831
## Example
2932

3033
Let's say that you have decided to write the first ever Haskell implementation
31-
of a POSIX shell, `hsh`. Here's how to test it with FileCheck.
34+
of a POSIX shell, `hsh`. Here's how to test it with Oughta.
3235

3336
If the input to the program under test is a file format that supports comments,
34-
it is often convenient to embed FileCheck DSL programs in the input itself. For
37+
it is often convenient to embed Oughta DSL programs in the input itself. For
3538
example, here's a test for `echo`:
3639

3740
```sh
@@ -48,7 +51,7 @@ module Main (main) where
4851

4952
import Control.Monad (filterM, forM)
5053
import Data.ByteString qualified as BS
51-
import FileCheck qualified as FC
54+
import Oughta qualified
5255
import System.Directory qualified as Dir
5356
import Test.Tasty.HUnit qualified as TTH
5457
import Test.Tasty qualified as TT
@@ -63,9 +66,9 @@ test sh = do
6366
content <- BS.readFile sh
6467
(stdout, _stderr) <- runScript content
6568
let comment = "# " -- shell script start-of-line comment
66-
let prog = FC.fromLineComments sh comment content
67-
result <- FC.check prog (FC.Output stdout)
68-
TTH.assertBool (sh ++ " contained some assertions") (not (FC.resultNull result))
69+
let prog = Oughta.fromLineComments sh comment content
70+
result <- Oughta.check prog (Oughta.Output stdout)
71+
TTH.assertBool (sh ++ " contained some assertions") (not (Oughta.resultNull result))
6972

7073
main :: IO ()
7174
main = do
@@ -88,16 +91,16 @@ test :: FilePath -> IO ()
8891
test sh = do
8992
-- snip --
9093
let stdoutComment = "# STDOUT: "
91-
let prog = FC.fromLineComments sh stdoutComment content
92-
stdoutResult <- FC.check prog (FC.Output stdout)
94+
let prog = Oughta.fromLineComments sh stdoutComment content
95+
stdoutResult <- Oughta.check prog (Oughta.Output stdout)
9396

9497
let stderrComment = "# STDERR: "
95-
let prog' = FC.fromLineComments sh stderrComment content
96-
stderrResult <- FC.check prog' (FC.Output stderr)
98+
let prog' = Oughta.fromLineComments sh stderrComment content
99+
stderrResult <- Oughta.check prog' (Oughta.Output stderr)
97100

98101
TTH.assertBool
99102
(sh ++ " contained some assertions")
100-
(not (FC.resultNull stdoutResult && FC.resultNull stderrResult))
103+
(not (Oughta.resultNull stdoutResult && Oughta.resultNull stderrResult))
101104
```
102105

103106
Test cases would then look like so:
@@ -111,8 +114,8 @@ echo 'Hello, stderr!' 1>&2
111114

112115
## Cookbook
113116

114-
This section demonstrates how to accomplish common tasks with the FileCheck DSL.
115-
The FileCheck DSL is just [Lua][lua], extended with an API for easy parsing.
117+
This section demonstrates how to accomplish common tasks with the Oughta DSL.
118+
The DSL is just [Lua][lua], extended with an API for easy parsing.
116119

117120
[Lua]: https://www.lua.org/
118121

@@ -122,7 +125,7 @@ as simple as possible, and some repetition should be accepted for the sake of
122125
readability. It is often appropriate to just make a sequence of API calls with
123126
literal strings as arguments.
124127

125-
FileCheck is used to test itself. See the test suite for additional examples.
128+
Oughta is used to test itself. See the test suite for additional examples.
126129

127130
### Long matches
128131

@@ -156,7 +159,7 @@ check("I'm sorry, " .. name)
156159
```
157160
or with a `for`-loop:
158161
```
159-
Step 1: Learn about FileCheck
162+
Step 1: Learn about Oughta
160163
Step 2: Use it to test your project
161164
Step 3: Enjoy!
162165
```
@@ -190,7 +193,7 @@ The Lua API is *stateful*. It keeps track of a global variable `text` that
190193
is initialized to the output of the program under test. Various API functions
191194
cause the API to seek forward in `text`. This is analogous to working file-like
192195
objects in languages like C or Python. `text` should not be updated from Lua
193-
code; such updates will be ignored by FileCheck.
196+
code; such updates will be ignored by Oughta.
194197

195198
### High-level API
196199

@@ -219,24 +222,24 @@ Other utilities:
219222

220223
## Motivation
221224

222-
The overall FileCheck paradigm is a form of [data driven testing]. See that blog
225+
The overall Oughta paradigm is a form of [data driven testing]. See that blog
223226
post for considerable motivation and discussion.
224227

225228
[data driven testing]: https://matklad.github.io/2021/05/31/how-to-test.html#Data-Driven-Testing
226229

227-
In comparison to golden testing, FileCheck-style tests are *coarser*. They only
230+
In comparison to golden testing, Oughta-style tests are *coarser*. They only
228231
check particular parts of the program's output. This can cause less churn in
229232
the test suite when the program output changes in ways that are not relevant
230233
to the properties being tested. The fineness of golden testing can force
231234
devlopers to adopt [complex] [workarounds], these can sometimes be obviated by
232-
FileCheck-style testing.
235+
Oughta-style testing.
233236

234237
[complex]: https://rustc-dev-guide.rust-lang.org/tests/ui.html#normalization
235238
[workarounds]: https://github.com/GaloisInc/crucible/blob/dc0895f4435dc19a8cceee3272c9a508221bce51/crux-llvm/test/Test.hs#L226-L311
236239

237-
However, it is more complex. For example, it requires learning the FileCheck
238-
DSL. It can also cause unexpected successes, e.g., if the program output
239-
contains the pattern being checked, but not in the proper place.
240+
However, it is more complex. For example, it requires learning the Oughta DSL.
241+
It can also cause unexpected successes, e.g., if the program output contains the
242+
pattern being checked, but not in the proper place.
240243

241244
Why build a Haskell library when LLVM already provides their FileCheck tool?
242245
There are a variety of reasons:
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
cabal-version: 2.4
2-
name: filecheck
2+
name: oughta
33
version: 0.1.0.0
44
author: Galois, Inc.
55
maintainer: grease@galois.com
66
copyright: Galois, Inc. 2025
77
license: BSD-3-Clause
88
license-file: LICENSE
9-
synopsis: Like LLVM's FileCheck tool, but as a Haskell library.
9+
synopsis: A library to test programs that output text.
1010
description:
11-
Like LLVM's FileCheck tool, but as a Haskell library.
11+
A library to test programs that output text.
1212

13-
See upstream docs for details.
13+
See the README for details.
1414
extra-doc-files:
1515
README.md
1616
extra-source-files:
17-
src/FileCheck/filecheck.lua
17+
src/Oughta/oughta.lua
1818
category: Testing
1919

2020
source-repository head
2121
type: git
2222
location: https://github.com/GaloisInc/grease
23-
subdir: filecheck
23+
subdir: oughta
2424

2525
common shared
2626
default-language: GHC2021
@@ -134,23 +134,23 @@ library
134134
text,
135135

136136
exposed-modules:
137-
FileCheck
137+
Oughta
138138
other-modules:
139-
FileCheck.Exception
140-
FileCheck.Extract
141-
FileCheck.Lua
142-
FileCheck.LuaApi
143-
FileCheck.Pos
144-
FileCheck.Result
145-
FileCheck.Traceback
139+
Oughta.Exception
140+
Oughta.Extract
141+
Oughta.Lua
142+
Oughta.LuaApi
143+
Oughta.Pos
144+
Oughta.Result
145+
Oughta.Traceback
146146

147-
test-suite filecheck-tests
147+
test-suite oughta-tests
148148
import: shared
149149
type: exitcode-stdio-1.0
150150
hs-source-dirs: test
151-
build-depends:
152-
filecheck
153151
main-is: Test.hs
152+
build-depends:
153+
oughta
154154
build-depends:
155155
bytestring,
156156
directory,

0 commit comments

Comments
 (0)