-
Notifications
You must be signed in to change notification settings - Fork 13
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
[fontc] More code reuse in fontc tests #584
Conversation
Also as a general observation (not having really looked at this in much detail before) a bunch(/most/all?) of the tests in |
/// | ||
/// When you need more control, just the `compile` fn/`TestCompile` type | ||
/// directly | ||
struct SimpleCompile { |
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 like the elimination of boilerplate but I'm not sure why you need a new type, just improve TestCompile?
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.
Filed as #594 to unblock merging
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.
LGTM with one nit
I looked into that, and it isn't obvious how to present this sort of simple interface there, while preserving the flexibility of the existing type. This solution doesn't feel great, but it does feel like a small improvement. |
fn new(source: &str) -> std::io::Result<Self> { | ||
let temp_dir = tempdir()?; | ||
let build_dir = temp_dir.path(); | ||
let result = compile(Args::for_test(build_dir, source)); |
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 don't particularly like that the heavy-lifting part of the code where things get compiled is hidden in a default new() constructor.. Why not use a free function that takes a str and returns a struct and is named with something like "compile" to make it clear this is, well, compiling?
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.
+1, I like the current result = compile()
pattern. I also like how this PR removes some of the boilerplate. Seems possible to combine.
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.
fair, how about SimpleCompile::compile
?
0d1e3a9
to
9088471
Compare
9088471
to
d3b2076
Compare
okay I'm inclined to get this in, it isn't a silver bullet but it marginally improves the status quo |
In the process of looking into how to add mark-mark tests I got a bit distracted trying to figure out a way to reduce the boilerplate in the existing tests.
This mostly does that, although it also slightly tweaks how some asserts are structured.