this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

can filter tests

+50 -47
+4
CHANGELOG.md
··· 1 1 # Changelog 2 2 3 + ## v1.7.0 - 2025-09-24 4 + 5 + - Can filter tests by `--test-name-filter=NAME` 6 + 3 7 ## v1.6.2 - 2025-08-23 4 8 5 9 - Fixed a bug where the number of passes was reported as the total number of
+5 -39
README.md
··· 1 - # gleeunit 2 - 3 - A simple test runner for Gleam, using EUnit on Erlang and a custom runner on JS. 4 - 5 - [![Package Version](https://img.shields.io/hexpm/v/gleeunit)](https://hex.pm/packages/gleeunit) 6 - [![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/gleeunit/) 7 - 8 - 9 - ```sh 10 - gleam add gleeunit@1 --dev 11 - ``` 12 - ```gleam 13 - // In test/yourapp_test.gleam 14 - import gleeunit 1 + # gleeunit fork 15 2 16 - pub fn main() { 17 - gleeunit.main() 18 - } 19 - ``` 3 + 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. 20 4 21 - Now any public function with a name ending in `_test` in the `test` directory 22 - will be found and run as a test. 5 + I will not be adding it to hex under a different name or anything like that. You'll have to manually add 6 + it to your `gleam.toml` dev dependencies: 23 7 24 - ```gleam 25 - pub fn some_function_test() { 26 - assert some_function() == "Hello!" 27 - } 28 8 ``` 29 - 30 - Run the tests by entering `gleam test` in the command line. 31 - 32 - ### Deno 33 - 34 - If using the Deno JavaScript runtime, you will need to add the following to your 35 - `gleam.toml`. 36 - 37 - ```toml 38 - [javascript.deno] 39 - allow_read = [ 40 - "gleam.toml", 41 - "test", 42 - "build", 43 - ] 9 + gleeunit = { git = "https://tangled.sh/@bthom.tngl.sh/gleeunit", ref = "v1.7.0" } 44 10 ```
+4 -2
gleam.toml
··· 1 1 name = "gleeunit" 2 - version = "1.6.2" 2 + version = "1.7.0" 3 3 licences = ["Apache-2.0"] 4 4 description = "A simple test runner for Gleam, using EUnit on Erlang" 5 5 repository = { type = "github", user = "lpil", repo = "gleeunit" } ··· 10 10 allow_read = ["gleam.toml", "test", "build"] 11 11 12 12 [dependencies] 13 - gleam_stdlib = ">= 0.60.0 and < 1.0.0" 13 + gleam_stdlib = ">= 0.40.0 and < 1.0.0" 14 + argv = ">= 1.0.2 and < 2.0.0" 15 + simplifile = ">= 2.3.0 and < 3.0.0" 14 16 15 17 [dev-dependencies] 16 18 testhelper = { "path" = "./testhelper" }
+6 -1
manifest.toml
··· 2 2 # You typically do not need to edit this file 3 3 4 4 packages = [ 5 + { name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" }, 6 + { name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" }, 5 7 { name = "gleam_stdlib", version = "0.60.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "621D600BB134BC239CB2537630899817B1A42E60A1D46C5E9F3FAE39F88C800B" }, 8 + { name = "simplifile", version = "2.3.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0A868DAC6063D9E983477981839810DC2E553285AB4588B87E3E9C96A7FB4CB4" }, 6 9 { name = "testhelper", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], source = "local", path = "testhelper" }, 7 10 ] 8 11 9 12 [requirements] 10 - gleam_stdlib = { version = ">= 0.60.0 and < 1.0.0" } 13 + argv = { version = ">= 1.0.2 and < 2.0.0" } 14 + gleam_stdlib = { version = ">= 0.40.0 and < 1.0.0" } 15 + simplifile = { version = ">= 2.3.0 and < 3.0.0" } 11 16 testhelper = { path = "./testhelper" }
+31 -5
src/gleeunit.gleam
··· 1 + import argv 1 2 import gleam/list 2 3 import gleam/result 3 4 import gleam/string 5 + import simplifile 4 6 5 7 /// Find and run all test functions for the current project using Erlang's EUnit 6 8 /// test framework, or a custom JavaScript test runner. ··· 18 20 fn do_main() -> Nil { 19 21 let options = [Verbose, NoTty, Report(#(GleeunitProgress, [Colored(True)]))] 20 22 21 - let result = 22 - find_files(matching: "**/*.{erl,gleam}", in: "test") 23 - |> list.map(gleam_to_erlang_module_name) 24 - |> list.map(dangerously_convert_string_to_atom(_, Utf8)) 25 - |> run_eunit(options) 23 + let result = case argv.load().arguments { 24 + ["--test-name-filter=" <> test_name, ..] -> { 25 + find_files(matching: "**/*.{erl,gleam}", in: "test") 26 + |> list.filter(fn(file) { 27 + let assert Ok(contents) = simplifile.read("test/" <> file) 28 + string.contains(contents, test_name) 29 + }) 30 + |> list.map(gleam_to_erlang_module_name) 31 + |> list.map(fn(module) { 32 + #( 33 + dangerously_convert_string_to_atom(module, Utf8), 34 + dangerously_convert_string_to_atom(test_name, Utf8), 35 + ) 36 + }) 37 + |> run_eunit_specific_test(options) 38 + } 39 + // If the filter argument isn't provided we want to run every test! 40 + _ -> 41 + find_files(matching: "**/*.{erl,gleam}", in: "test") 42 + |> list.map(gleam_to_erlang_module_name) 43 + |> list.map(dangerously_convert_string_to_atom(_, Utf8)) 44 + |> run_eunit(options) 45 + } 26 46 27 47 let code = case result { 28 48 Ok(_) -> 0 ··· 78 98 79 99 @external(erlang, "gleeunit_ffi", "run_eunit") 80 100 fn run_eunit(a: List(Atom), b: List(EunitOption)) -> Result(Nil, a) 101 + 102 + @external(erlang, "gleeunit_ffi", "run_eunit") 103 + fn run_eunit_specific_test( 104 + a: List(#(Atom, Atom)), 105 + b: List(EunitOption), 106 + ) -> Result(Nil, a)