···11# Changelog
2233+## v1.7.0 - 2025-09-24
44+55+- Can filter tests by `--test-name-filter=NAME`
66+37## v1.6.2 - 2025-08-23
4859- Fixed a bug where the number of passes was reported as the total number of
+5-39
README.md
···11-# gleeunit
22-33-A simple test runner for Gleam, using EUnit on Erlang and a custom runner on JS.
44-55-[](https://hex.pm/packages/gleeunit)
66-[](https://hexdocs.pm/gleeunit/)
77-88-99-```sh
1010-gleam add gleeunit@1 --dev
1111-```
1212-```gleam
1313-// In test/yourapp_test.gleam
1414-import gleeunit
11+# gleeunit fork
1521616-pub fn main() {
1717- gleeunit.main()
1818-}
1919-```
33+This is a fork of [gleeunit](https://github.com/lpil/gleeunit) that adds ability to filter by test name with the `--test-name-filter=NAME` flag.
2042121-Now any public function with a name ending in `_test` in the `test` directory
2222-will be found and run as a test.
55+I will not be adding it to hex under a different name or anything like that. You'll have to manually add
66+it to your `gleam.toml` dev dependencies:
2372424-```gleam
2525-pub fn some_function_test() {
2626- assert some_function() == "Hello!"
2727-}
288```
2929-3030-Run the tests by entering `gleam test` in the command line.
3131-3232-### Deno
3333-3434-If using the Deno JavaScript runtime, you will need to add the following to your
3535-`gleam.toml`.
3636-3737-```toml
3838-[javascript.deno]
3939-allow_read = [
4040- "gleam.toml",
4141- "test",
4242- "build",
4343-]
99+gleeunit = { git = "https://tangled.sh/@bthom.tngl.sh/gleeunit", ref = "v1.7.0" }
4410```
+4-2
gleam.toml
···11name = "gleeunit"
22-version = "1.6.2"
22+version = "1.7.0"
33licences = ["Apache-2.0"]
44description = "A simple test runner for Gleam, using EUnit on Erlang"
55repository = { type = "github", user = "lpil", repo = "gleeunit" }
···1010allow_read = ["gleam.toml", "test", "build"]
11111212[dependencies]
1313-gleam_stdlib = ">= 0.60.0 and < 1.0.0"
1313+gleam_stdlib = ">= 0.40.0 and < 1.0.0"
1414+argv = ">= 1.0.2 and < 2.0.0"
1515+simplifile = ">= 2.3.0 and < 3.0.0"
14161517[dev-dependencies]
1618testhelper = { "path" = "./testhelper" }
+6-1
manifest.toml
···22# You typically do not need to edit this file
3344packages = [
55+ { name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
66+ { name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" },
57 { name = "gleam_stdlib", version = "0.60.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "621D600BB134BC239CB2537630899817B1A42E60A1D46C5E9F3FAE39F88C800B" },
88+ { name = "simplifile", version = "2.3.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0A868DAC6063D9E983477981839810DC2E553285AB4588B87E3E9C96A7FB4CB4" },
69 { name = "testhelper", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], source = "local", path = "testhelper" },
710]
811912[requirements]
1010-gleam_stdlib = { version = ">= 0.60.0 and < 1.0.0" }
1313+argv = { version = ">= 1.0.2 and < 2.0.0" }
1414+gleam_stdlib = { version = ">= 0.40.0 and < 1.0.0" }
1515+simplifile = { version = ">= 2.3.0 and < 3.0.0" }
1116testhelper = { path = "./testhelper" }
+31-5
src/gleeunit.gleam
···11+import argv
12import gleam/list
23import gleam/result
34import gleam/string
55+import simplifile
4657/// Find and run all test functions for the current project using Erlang's EUnit
68/// test framework, or a custom JavaScript test runner.
···1820fn do_main() -> Nil {
1921 let options = [Verbose, NoTty, Report(#(GleeunitProgress, [Colored(True)]))]
20222121- let result =
2222- find_files(matching: "**/*.{erl,gleam}", in: "test")
2323- |> list.map(gleam_to_erlang_module_name)
2424- |> list.map(dangerously_convert_string_to_atom(_, Utf8))
2525- |> run_eunit(options)
2323+ let result = case argv.load().arguments {
2424+ ["--test-name-filter=" <> test_name, ..] -> {
2525+ find_files(matching: "**/*.{erl,gleam}", in: "test")
2626+ |> list.filter(fn(file) {
2727+ let assert Ok(contents) = simplifile.read("test/" <> file)
2828+ string.contains(contents, test_name)
2929+ })
3030+ |> list.map(gleam_to_erlang_module_name)
3131+ |> list.map(fn(module) {
3232+ #(
3333+ dangerously_convert_string_to_atom(module, Utf8),
3434+ dangerously_convert_string_to_atom(test_name, Utf8),
3535+ )
3636+ })
3737+ |> run_eunit_specific_test(options)
3838+ }
3939+ // If the filter argument isn't provided we want to run every test!
4040+ _ ->
4141+ find_files(matching: "**/*.{erl,gleam}", in: "test")
4242+ |> list.map(gleam_to_erlang_module_name)
4343+ |> list.map(dangerously_convert_string_to_atom(_, Utf8))
4444+ |> run_eunit(options)
4545+ }
26462747 let code = case result {
2848 Ok(_) -> 0
···78987999@external(erlang, "gleeunit_ffi", "run_eunit")
80100fn run_eunit(a: List(Atom), b: List(EunitOption)) -> Result(Nil, a)
101101+102102+@external(erlang, "gleeunit_ffi", "run_eunit")
103103+fn run_eunit_specific_test(
104104+ a: List(#(Atom, Atom)),
105105+ b: List(EunitOption),
106106+) -> Result(Nil, a)