-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add a testing script #6
Conversation
Requires `Process.chdir(_)` from wren-essentials
d545674
to
56f9acb
Compare
scripts/test_all.wren
Outdated
var testDir = "./tests/" | ||
var testFiles = Directory.list(testDir) | ||
.where {|f| Strings.globMatch(f, "*.wren")} | ||
.map {|f| testDir + f[0..-6]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this just stripping extension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a nicer way, but we have no basename
yet. :)
scripts/test_all.wren
Outdated
var tmpfile = ".git.root.%(Process.pid)" | ||
Process.exec("sh", ["-c", "git rev-parse --show-toplevel > %(tmpfile)"]) | ||
var rootdir = File.read(tmpfile).trim() | ||
File.delete(tmpfile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is all this because you don't often work out of the root directory of projects? Many of my utility scripts ASSUME this... this isn't bad, but it's also not entirely portable...
Can we get the absolute pathing given argument 0, the script name itself? Or is that stripped of path info?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not exactly public but you have the Path
class at your disposal as well for navigation around a path string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ cd tests
$ cat > path.wren
import "os" for Process
System.print(Process.arguments)
System.print(Process.allArguments)
System.print(Process.cwd)
^D
$ wrenc ./path.wren
[]
[wrenc, ./path.wren]
/Users/glennjackman_1/src/other/wren/joshgoebel/wren-testie/tests
It's just because the error message for running a test file is so maddening unless you're at the repo root
$ wrenc ./expect.wren
Could not load module 'testie'.
at (script) (././expect.wren line 1)
I haven't really gotten the module resolver. I thought imports of relative paths are relative to the directory of the file currently being evaluated, and this is why scripts/test_all.wren
has to import "../testie"
-- but then that error message baffles me: relative to tests/expect.wren
, testie is in ../
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't really gotten the module resolver. I thought imports of relative paths are relative to the directory of the file currently being evaluated,
Correct. And the original script (first argument to wrenc
) root is used for walking up the directory to find wren_modules
folders.
Pretty sure there is a bug in Path
class here:
./../testie
normalizes totestie
, which is wrong.
PR forthcoming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't assume we're bug free. :) Might spend lots of time writing code to get around bugs that are much simpler to fix than the code you're writing to avoid them. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking I should remove the check for git rootdir, and maybe just replace it with a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You try my PR and see if it works fine without?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to work fine, but because I have to list a relative dir, I'm pretty much stuck at forcing execution from the project root.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh?
Ok, now we have an issue where this wouldn't just work with the release version of I'm wondering if we should have some sort of |
I'd say it's the script's job since wren is not very introspective, and that assertVersion is a good idea. |
Oh that might be nice. Excited to try this later. |
* Add a testing script. Requires `Process.chdir(_)` from wren-essentials * do not show empty lists Co-authored-by: Josh Goebel <me@joshgoebel.com>
RequiresProcess.chdir(_)
from wren-console andStrings.globMatch(_, _)
from wren-essentialsLatest iteration no longer has these requirements.