-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Improve tools/unit_tests.py #958
Conversation
"--allow-write", | ||
"--allow-net", | ||
"--allow-env", | ||
]) |
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.
permW1N1E1 was removed because there are no unit tests which use all three.
5beb7b6
to
51b14ff
Compare
tools/unit_tests.py
Outdated
raise TypeError("Bad js/unit_test.ts output") | ||
if expected != actual: | ||
print "expected", expected, "actual", actual | ||
raise TypeError("expected tests did not equal actual") |
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.
nit but this probably ought to be an AssertionError (not a TypeError).
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.
Fixed.
Checks the output more carefully. The first line of output from js/unit_tests.ts should be something like "running 96 tests" And the last line should be something like "test result: ok. 96 passed; 0 failed; 0 ignored; 0 measured; 36 filtered out" This parses those strings and make sure they align. This will catch silent death bugs.
@piscisaureus PTAL |
run_unit_test(deno_exe, "permW1N0E0", ["--allow-write"]) | ||
run_unit_test(deno_exe, "permW0N1E0", ["--allow-net"]) | ||
run_unit_test(deno_exe, "permW0N0E1", ["--allow-env"]) | ||
# TODO We might accidentally miss some. We should be smarter about which we |
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.
Yeah i worry about that too.
We could also do some typescript trick with the DenoPermissions
type in the test runner so it only allows the 4 permutations listed here. Then it'd be obvious when a new test uses a flag combination that doesn't get run.
type Exact<A extends object> = A & { __kind: keyof A };
type DenoPermissions =
Exact<{} | { write: true } | { net: true } | { env: true }>;
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 this was very needed!
Checks the output more carefully. The first line of output from
js/unit_tests.ts should be something like "running 96 tests"
And the last line should be something like
"test result: ok. 96 passed; 0 failed; 0 ignored; 0 measured; 36
filtered out"
This parses those strings and make sure they align.
This will catch silent death bugs.