-
Notifications
You must be signed in to change notification settings - Fork 368
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
Mechanism for reftests filtering #6105
Conversation
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.
otherwise lgtm
tests/reftests/gen.ml
Outdated
if base_name = filename then archive_hashes else | ||
let archive_hash, tags = | ||
match first_line_tags ~path:filename with | ||
| [] -> "", [] |
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.
String.split_on_char
never returns an empty list. Instead it is [""]
(see https://ocaml.org/manual/5.2/api/String.html#extract)
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 can add a comment for this, or fix the function, but []
and [""]
end up with the exact same result anyways.
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 think replacing it with assert false
would be a bit nicer
tests/reftests/gen.ml
Outdated
| ar::_ as tags -> ar, tags | ||
in | ||
let os_condition = match Filename.extension base_name with | ||
| "" -> "" | ||
| os -> | ||
Printf.sprintf "(= %%{os_type} %S)" | ||
String.(capitalize_ascii (sub os 1 (length os - 1))) | ||
in | ||
let tags_conditions = | ||
List.map (fun tag -> | ||
Printf.sprintf | ||
"(= %%{env:TEST%s=0} 1)" | ||
tag) | ||
tags | ||
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 think it's best to make the set of tags limited to make it easier to maintain, agree on what tags we allow and for the free typo detection
| ar::_ as tags -> ar, tags | |
in | |
let os_condition = match Filename.extension base_name with | |
| "" -> "" | |
| os -> | |
Printf.sprintf "(= %%{os_type} %S)" | |
String.(capitalize_ascii (sub os 1 (length os - 1))) | |
in | |
let tags_conditions = | |
List.map (fun tag -> | |
Printf.sprintf | |
"(= %%{env:TEST%s=0} 1)" | |
tag) | |
tags | |
in | |
| ar::tags -> ar, tags | |
in | |
let os_condition = match Filename.extension base_name with | |
| "" -> "" | |
| os -> | |
Printf.sprintf "(= %%{os_type} %S)" | |
String.(capitalize_ascii (sub os 1 (length os - 1))) | |
in | |
let tags_conditions = | |
List.map (function | |
| ("N0REP0") as tag -> | |
Printf.sprintf | |
"(= %%{env:TEST%s=0} 1)" | |
tag | |
| tag -> raise (Failure (Printf.sprintf "Tag '%s' unrecognized" tag))) | |
(if String.equal ar null_hash then ar :: tags else tags) | |
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'm not opposed to this, however right now we can only choose specific tests with a present tag. So we have to be wary of that if we want to maintain a proper tag list.
Also, repo hashes are also considered for filtering and those are kind of arbitrary in any case.
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.
Also, repo hashes are also considered for filtering and those are kind of arbitrary in any case.
yeah, i removed that handling in my suggestion because i thought it wasn't useful and complicates the list of environment variable that affects opam
So we have to be wary of that if we want to maintain a proper tag list.
i think this PR is good way to get the discussion started, but you're right, I've updated the suggestion to only handle N0REP0
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 feel we should not include repo hash to the tags in that case, as we won't have a reliable way to concile restrictions on both. Adding a first tag for the proposed use-case (that coincidentally appears along N0REP0) would be more orderly.
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.
As mentioned on slack i don't think we should have a "quick" tag, as maintaining it is more work than it's worth and its meaning can't really be defined either. What was bad about using N0REP0 like my code suggestion above?
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 not against using repo hashes as filters but I think it doesn't fit well with tag restrictions, because we won't apply those to repo hashes (at least not in a pretty way). And making N0REP0 the unique exception feels unsatisfactory.
We could constraint ourselves to using only well-defined tags, but in that case hashes don't really fit either, neither my initial goal of having an informal selection of tests for fast development feedback.
Incorporated Kate's suggestion. |
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.
Thanks!
Thanks |
This is an attempt to have a generalization to filter arbitrarily reftests, with the main objective being having a command that run quickly locally.
The approach is to use custom-defined tags in the testfiles and injecting corresponding variable in the dune command environment (in a way that doesn't affect exisiting behavior). The lack of expressivity in dune files limits filter expressivity but I think this is good enough as a first step toward something we'd want to use more systematically.
Also, this makes tests summary more broadly available to other rules