Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gleam test fails with vim swap files in test directory #62

Open
glennj opened this issue May 3, 2024 · 2 comments · May be fixed by #63
Open

gleam test fails with vim swap files in test directory #62

glennj opened this issue May 3, 2024 · 2 comments · May be fixed by #63
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed x:module/test-runner Work on Test Runners

Comments

@glennj
Copy link

glennj commented May 3, 2024

This has been bedeviling me for a while.

$ gleam test
   Compiled in 0.02s
    Running largest_series_product_test.main
exception error: #{function => <<"read_module">>,line => 74,
                   message => <<"Assertion pattern match failed">>,
                   module => <<"exercism/test_runner">>,
                   value => {error,not_utf8},
                   gleam_error => let_assert}
  in function  exercism@test_runner:read_module/1 (/Users/glennj/src/exercism/exercism.io/gleam/largest-series-product/build/dev/erlang/exercism_test_runner/_gleam_artefacts/exercism@test_runner.erl, line 96)
  in call from gleam@list:do_map/3 (/Users/glennj/src/exercism/exercism.io/gleam/largest-series-product/build/dev/erlang/gleam_stdlib/_gleam_artefacts/[email protected], line 119)
  in call from exercism@test_runner:main/0 (/Users/glennj/src/exercism/exercism.io/gleam/largest-series-product/build/dev/erlang/exercism_test_runner/_gleam_artefacts/exercism@test_runner.erl, line 134)

I finally figured out it that it occurred while I was editing the test suite (in vim). The vim swap file is not an ASCII file, and it cannot be read as a module:

$ find src/ test/ -type f -exec file '{}' +
src//largest_series_product.gleam:            ASCII text
test//.largest_series_product_test.gleam.swp: Vim swap file, version 9.1, pid 1428, user glennj, host exercism-playground, file ~glennj/src/exercism/exercism.io/gleam/largest-series-product/test/largest_series_product_test.gleam
test//largest_series_product_test.gleam:      c program text, ASCII text

In exercism/test_runner.gleam, can we filter out hidden files?

Something like this naive filtering

pub fn main() {
  let assert Ok(files) = read_directory("test")
  let files = list.filter(files, fn(file) {
      case charlist.to_string(file) {
        "." <> _ -> False
        _ -> True
      }
    })
@glennj
Copy link
Author

glennj commented May 3, 2024

The quick solution (for me) is to get vim to put my swap files elsewhere. But vim is not the only source of offending files.

@lpil
Copy link
Member

lpil commented May 3, 2024

How annoying! It would be good to have this fixed

@lpil lpil added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed x:module/test-runner Work on Test Runners labels May 3, 2024
@glennj glennj linked a pull request May 3, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed x:module/test-runner Work on Test Runners
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants