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

Improve tools/unit_tests.py #958

Merged
merged 2 commits into from
Oct 11, 2018
Merged

Improve tools/unit_tests.py #958

merged 2 commits into from
Oct 11, 2018

Conversation

ry
Copy link
Member

@ry ry commented Oct 11, 2018

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.

@ry ry requested a review from piscisaureus October 11, 2018 04:24
"--allow-write",
"--allow-net",
"--allow-env",
])
Copy link
Member Author

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.

@ry ry force-pushed the unit_test_output branch 2 times, most recently from 5beb7b6 to 51b14ff Compare October 11, 2018 05:20
raise TypeError("Bad js/unit_test.ts output")
if expected != actual:
print "expected", expected, "actual", actual
raise TypeError("expected tests did not equal actual")
Copy link
Contributor

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).

Copy link
Member Author

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.
@ry
Copy link
Member Author

ry commented Oct 11, 2018

@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
Copy link
Member

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 }>;

Copy link
Member

@piscisaureus piscisaureus left a 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!

@ry ry merged commit d4f72e1 into denoland:master Oct 11, 2018
@ry ry deleted the unit_test_output branch October 11, 2018 20:56
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.

3 participants