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

Filter test files to exclude hidden and non-gleam files #63

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

glennj
Copy link

@glennj glennj commented May 3, 2024

Filter the files in the test directory to exclude possible bad ones.

Fixes #62

@glennj glennj requested a review from a team as a code owner May 3, 2024 11:25
Comment on lines +20 to +24
let files =
list.map(files, charlist.to_string)
|> list.filter(fn(file) {
string.ends_with(file, "test.gleam") && !string.starts_with(file, ".")
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead of just reading in the test directory, the .meta/config.json file could be parsed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that would preclude students from uploading any additional test files. However I suppose the likelihood of that happening is extremely small.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true 🤷

@glennj
Copy link
Author

glennj commented May 3, 2024

@lpil I think I'm running into a dependency problem with the tests I'm adding:

  • I'm changing a file in the exercism_test_runner package
  • However, the gleam.toml in the new test dir depends on exercism_test_runner, fetching the published package.

Do I need to publish my changes before I can test them?

$ bin/setup-locally.sh
Downloading packages
 Downloaded 14 packages in 0.11s
[...]
  Compiling exercism_test_runner
[...]
   Compiled in 6.24s
$ bin/run.sh bad_test_files $PWD/tests/bad_test_files{,}
Copying config and dependencies...
bad_test_files: compiling...
bad_test_files: testing...
   Compiled in 0.04s
    Running bad_test_files_test.main
exception error: #{function => <<"read_module">>,line => 75,
                   message => <<"Assertion pattern match failed">>,
                   module => <<"exercism/test_runner">>,
                   value => {error,{unexpected_token,panic,{position,0}}},
                   gleam_error => let_assert}
  in function  exercism@test_runner:read_module/1 (/Users/glennj/src/exercism/tracks/gleam-test-runner/packages/build/dev/erlang/exercism_test_runner/_gleam_artefacts/exercism@test_runner.erl, line 107)
  in call from gleam@list:do_map/3 (/Users/glennj/src/exercism/tracks/gleam-test-runner/packages/build/dev/erlang/gleam_stdlib/_gleam_artefacts/gleam@list.erl, line 119)
  in call from exercism@test_runner:main/0 (/Users/glennj/src/exercism/tracks/gleam-test-runner/packages/build/dev/erlang/exercism_test_runner/_gleam_artefacts/exercism@test_runner.erl, line 134)bad_test_files: done

Try moving the altered test_runner.gleam into the new test:

$ cp runner/src/exercism/test_runner.gleam tests/bad_test_files/build/packages/exercism_test_runner/src/exercism/test_runner.gleam
$ bin/run.sh bad_test_files $PWD/tests/bad_test_files{,}
[same exception as above]

Try moving the altered test_runner.gleam into the project's build hierarchy

$ cp runner/src/exercism/test_runner.gleam packages/build/packages/exercism_test_runner/src/exercism/test_runner.gleam
$ bin/run.sh bad_test_files $PWD/tests/bad_test_files{,}
Copying config and dependencies...
bad_test_files: compiling...
bad_test_files: testing...
   Compiled in 0.04s
    Running bad_test_files_test.main
.......
Ran 7 tests, 0 failed
bad_test_files: done

@lpil
Copy link
Member

lpil commented May 8, 2024

This repo contains both the Gleam test runner library, and also the Exercism test runner for Gleam that uses that library.

They are two different things and the library is distributed on Hex (so everyone can use it) so it needs to be published prior to being used by Exercism.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gleam test fails with vim swap files in test directory
3 participants