-
Notifications
You must be signed in to change notification settings - Fork 161
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
Allow local variables in test files #1633
Conversation
70ee2bf
to
0e25190
Compare
Codecov Report
@@ Coverage Diff @@
## master #1633 +/- ##
==========================================
+ Coverage 85.13% 85.15% +0.02%
==========================================
Files 110 110
Lines 56964 56964
==========================================
+ Hits 48494 48506 +12
+ Misses 8470 8458 -12
|
2a6e32f
to
ae082f0
Compare
@ChrisJefferson you've asked for further suggestions - what about making it possible to specify whether the test file or a separate example should just run without entering a break loop or crashing (so diffs are permitted)? |
ae082f0
to
f552349
Compare
We could certainly do that |
I wonder if we can also write a tool which automatically generates such a "local" line for an existing Of course for this won't work perfect, because a few tests may want to define a global (to test it), but those should be rare exceptions. |
I'm sure we could -- there is a "nice" way of doing that (hooking into the access to undefined variable, and recording when it occurs), and a "nasty" way (just look through the output for the error we know we will see), and either way stick a new |
f552349
to
029bb23
Compare
Perhaps rebase and squash the fixup commits? |
c2343fd
to
f6a3b35
Compare
@ChrisJefferson ping? |
40f0acf
to
df2ee3f
Compare
8eb2ea3
to
bed4eac
Compare
Back from the depths of time, I believe all issues are fixed and this PR is ready to merge. |
3beaa18
to
e676b3d
Compare
When you write #@exec -> #@Local, do you mean #@exec -> #@global? Otherwise, I don't follow... In case you do mean that: Well, in the end, I can certainly accept either; and I don't want to hold up the PR with bikeshedding; it's just that once a feature is out there, it is difficult to take it back. Since #@global would be much more limited in scope, I think it'd be very easy to document and easy to understand and use correctly; whereas I am afraid that I don't fully understand all potential ramifications of #@exec, and so I worry about abuse... Like, one thing I am concerned about is that apparently all #@exec in the whole .tst file are collected and executed at once before everything else in the script. So I could add #@exec lines at the bottom, and they'd be executed first thing, which I find highly surprising. I guess I'd be less concerned if @#exec was executed in lock step with other commands, i.e., only at the point they appear in the file. Or alternatively, if they were restricted to only appear at the top of the file, before any non-comment non-empty line. OTOH, the added power of #@exec might very well be a boon in ways I cannot foresee yet... Would be interesting to know what others thinks, too? E.g. @markuspf @stevelinton @wilfwilson etc. |
One problem with |
e676b3d
to
4c0a69c
Compare
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.
Now that you clarified that #@exec can only be used at the top, I am happy enough :-)
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 had a little look, I like the new features, and I don't have any objections.
Could you rebase again so we can merge this? |
4c0a69c
to
4acc5e2
Compare
This is an experiment in allowing local variables to be declared in test files.
The current (horrible) notation is to write:
#@local <list of variables to be local>
as the first line of the test. If this line is present, any other introduced variables will produce a warning, as if we were in a function.There are two reasons to do this:
You don't pollute the global name space, local names do not exist at the end of the test.
(More importantly) you can run the test in two threads simultaniously, as the two local contexts will not interfere.
This will fail, to demonstrate the new warnings being produced.
UPDATEUPDATE:
This PR also now features
#@if, #@else, #@endif
, which provides an easy way to skip parts of a given test, or give different returns for a given test. This is now used to make the 32-bit, 64-bit and unix tests only run on the correct platforms.