here is how I run tests, via just test https://gist.github.com/rickhull/ad4af8984a40d538ea1e1999af613492
This is the within-block usage of expect, not a "unit test" (as I understand these terms). Is this the right way to do the accounting, or am I misusing or under-utilizing Roc / expect features?
We have typically been using top level expects defined in the same file as the source for testing.
then you would issue roc test right? how do you perform a comprehensive run across multiple files?
then you would issue
roc testright?
Yes
how do you perform a comprehensive run across multiple files?
In the past with a bash script although I would like (as a new feature) the roc binary to auto-discover all tests in a project.
you could allow roc test PATH where PATH is like a subdir. for a dir, recursive search all .roc files?
Sounds good to me :)
because I am doing platform development, and host functions are impure, then I cannot use toplevel expect for these functions right? i think I need the justfile runner
it's a little confusing about the different expect behaviors in different contexts (toplevel vs not, pure vs impure, roc test vs roc). I wonder if there is a way to unify the behaviors.
@Richard Feldman said:
the number one rule of
expectis that it never affects control flow in any way
no matter where it is used
it is a harmless report
maybe a better way to think of it is "debug print that an expectation was false, and then mark this test as 'must fail' when it finishes running"
Keep in mind that it's possible that things aren't yet implemented, or if they are it's a first pass and needs polish. I have been slow rolling the platform development and fixings bugs as I find them. Almost everything I've worked on has had a few significant bugs, and most of my time was spent trying to understand what the behaviour should be so I could properly isolate and describe the bug. If you find any issues it would be helpful to investigate, it's probably not you but just something is broken.
Thanks Luke; to answer my own question a bit, I keep all my "host functions" in platform/Host.roc, though it's not necessary to do it this way. I have now isolated all my impure function testing to test/host.roc, which only calls functions from platform/Host.roc; thus I don't need a "test runner" at this point as I only have a single test/*.roc file
I migrated all other test/*.roc tests to "unit tests" at the toplevel within the source-file-under-test
roc test DIR: https://github.com/roc-lang/roc/issues/9057
Last updated: Feb 20 2026 at 12:27 UTC