-
Notifications
You must be signed in to change notification settings - Fork 6
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
Replace ignore
with ignore-if
.
#120
Conversation
This was previously slightly inconsistent in its use of punctuation (etc.). While here, clarify one slightly clunky phrasing.
@ltratt that's perfect for my use case in YK PR! |
@@ -1,4 +1,4 @@ | |||
// ignore: this test is intentionally ignored |
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.
So do we lose the ability to say why a test is ignored then?
I think forcing a reason was a good thing. I can barely remember why I did things last week, let alone why someone else did something 2 years ago :)
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.
See d09c0dc -- this PR makes things much more flexible!
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 see, a later commit adds a comment token.
Hrm. I wonder if there's a way we can force the user to provide a reason. Lazy devs will not add one.
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.
That's a human/per-project problem, not a lang_tester problem :)
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'd argue that your change made it a human/per-project problem. Before you had to provide a reason. No ifs, not buts.
Perhaps if you use ignore-if
, you have to also provide a ignore-reason
line too?
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.
ignore: <reason>
always had <reason>
as optional, so this PR doesn't change the optionality. I don't want to mandate how people use this: indeed, the comment syntax is far more flexible than what we had before IMHO.
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 didn't realise that it was optional, so I'll back down.
src/lib.rs
Outdated
//! * `ignore: [<string>]` specifies that this file should be ignored for the reason set out in | ||
//! `<string>` (if any). Note that `<string>` is purely for user information and has no effect | ||
//! on the running of tests. | ||
//! * `ignore-if-cmd: <cmd>` defines a shell command that will be run to determine whether to |
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.
Should ignore-if-cmd
be ignore-if
or are they two separate facilities?
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.
Oops, that's a typo from an earlier design. Fixed in 679ac45.
Based on my preliminary look, we've added something very general: a shell command. My worry is that forking will slow down the test suite. For now, we only need the ability to ignore something based on environment variables. I wonder if
If you needed to skip tests based on the output of shell commands (will we need it? I don't know), it would be doable, but more effort. You'd have to get the test runner to run the shell command and set an env var. That then raises the question: should there be (I bet that was your earlier design?) |
I don't think |
If knowing the opt level requires a shell-out, you could do it by getting your runner (e.g.
I could buy that, so if you still agree that the current design is acceptable, I'll do a deeper review. Let me know. |
I started with |
I think we should add a test that uses a |
Any thoughts on what? |
src/tester.rs
Outdated
@@ -128,6 +130,25 @@ impl LangTester { | |||
self | |||
} | |||
|
|||
/// If set, defines what top-level lines will be treated as comments if they begin 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.
top-level is confusing me a bit here.
If you look at a typical lang_test, it looks like:
// Compiler:
// stdout:
// match me!
And now we are adding the ability to have an inner comment, so a test can look like:
// Compiler:
// stdout:
// # flibble
// match me!
So when you say "defines what top-level lines will be treated as comments", I'm thinking of the top-level //
comments, not the `#' ones.
Do you see my concern?
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.
If you can think of a better phrasing, I'm all ears, but I think this comes under the heading of "this is how lang_tester works and you can't avoid knowing a bit about how a) your language parses comments b) your runner extracts test c) how lang_tester parses things".
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've just realised something else. By top-level, you mean it must appear at the same level as (e.g.) Compiler:
.
So in fact my example above is invalid. But should it be? I've often wanted to comment why I'm matching something, so perhaps comments should be allowed anywhere, and then all of this "top-level" talk disappears?
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 could allow comments elsewhere too, but I worry a bit that will create "comments" by accident. Maybe I'm worrying too much?
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 true that you might accidentally comment something you want to match.
I'll leave the decision up to you. I'm aware that I've been pedantic/annoying enough for one PR!
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.
On reflection I agree that generalising this is probably a good idea. Try 2223188.
Huh. I didn't ask for any thoughts :P |
/// # A literal string beginning with `#` | ||
/// ``` | ||
/// If set, defines what lines will be treated as comments if, ignoring the current level of | ||
/// indentation, they begin with `comment_prefix`. |
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.
This all LGTM. I wonder if here we should say:
If set, defines what lines of a lang_tester test will be treated as comments if, ignoring the current level of indentation, they begin with
comment_prefix
.Note that this is not to be confused with another language's comment lines in a test file when extracting the lang_tester test (e.g. using [LangTester::take_while].
Second sentence is iffy, but I hope you can see what I'm aiming at?
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 see what you're aiming at, but I don't think it's a good idea, in part because you don't have to embed lang_tester stuff in comments.
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.
Indeed. It's difficult to put into words.
Maybe we should just move on and wait for a user to squeal?
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.
Maybe we should just move on and wait for a user to squeal?
I tend to agree.
I think it's just this test outstanding now? |
I'm still awaiting an idea of what one could actually do here from you! The problem is that one is not in control of the environment, so it's hard to know what (say) an environment variable that's always set (or not) might be. I was astonished recently to find situations where even |
I don't mean to test environment variables. I mean to test some shell command with more than a single argument, e.g.:
This should skip the test, as grep exits 0 on a match. (I want to check that (obviously guard such a test for unix platforms) |
How? |
Great! thanks. And sorry (not sorry) for being persistent :) Please squash. |
`ignore` is a blunt tool. `ignore-if` allows users to be selective if/when they ignore tests. `ignore-if: true` is equivalent to the old `ignore`.
Squashed. |
This PR's main aim is to remove
ignore
and addignore-if: <cmd>
which allows a test to flexibly specify when it should/shouldn't be ignored (9ffa2b2). However, this means that the ability to specify a human string for why a test is ignored is lost so this PR also adds the ability to allow comment lines (d09c0dc).My guess is that the main way this will be used is with
test
so you might have things likeignore-if: test $YKB_TRACER == "swt"
orignore-if: test $YKB_TRACER != "swt"
and so on. @Pavel-Durov does this allow you to specify tests in your yk PR in the way you need?This is a breaking change, so if we do think this is useful and fits in with lang_tester's design, then it does imply a breaking release.