-
-
Notifications
You must be signed in to change notification settings - Fork 607
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
Use D to run the testsuite #8162
Conversation
Thanks for your pull request, @wilzbach! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#8162" |
90942c0
to
8851c86
Compare
test/run.d
Outdated
env[key] = default_; | ||
} | ||
|
||
// Sets the environment variables required by d_do_test |
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.
// Sets the environment variables required by d_do_test and sh_do_test.sh
I anticipate that d_do_test might go away at some point (if Make goes away), but setting environment variables will likely still be required for the Bash tests.
test/run.d
Outdated
} | ||
} | ||
} | ||
|
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.
immutable testDirs = ["runnable", "compilable", "fail_compilation"];
Can be used in a few places.
test/run.d
Outdated
} | ||
|
||
// ensure output directories exist | ||
foreach (dir; ["compilable", "fail_compilation", "runnable"]) |
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.
foreach (dir; testDirs)
test/run.d
Outdated
{ | ||
switch (t) | ||
{ | ||
case "clean": |
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 had a problem with this, my tab-autocomplete added a trailing slash to the test directory (i.e. ./run.d compilable/
). We could handle this by removing the trailing slash, maybe this?
if (t.endsWith(dirSeparator))
t = t[0 .. $ - 1];
test/run.d
Outdated
break; | ||
|
||
case "all": | ||
newTargets.put(findFiles("runnable")); |
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.
foreach (testDir; testDirs)
newTargets.put(findFinds(testDir));
test/run.d
Outdated
break; | ||
|
||
default: | ||
newTargets ~= t; |
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 results in odd error messages in some cases. Maybe the following check would work well?
if (!testDirs.canFind(t.dirName))
{
writefln("Error: invalid target '%s'", t);
exit(1);
}
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 already check for file existence in filterTargets
:
./run.d compilable/foo
Warning: compilable/foo can't be found
What's the odd error message you get?
return "solaris"; | ||
else version(SunOS) | ||
return "solaris"; | ||
else |
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.
No windows!??!! :)
I went ahead and tested that this runs on windows and it looks like it does. Just had to add the version(Windows)
case here.
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.
(windows is on the top of this list now)
Could we add a "v|verbose" flag to see things like the |
Another thought...now that we have full control of the test suite, maybe it would be helpful to print a summary of the results at the end of the test. Something like:
|
Done. Though I only added it in a very naive way for now. We can always expand on this later.
Good idea, but an overkill for this PR. Let's focus on getting this to a mergeable state and let's expand on it afterwards? |
661ae1d
to
fdabda4
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.
Okay I finally found time to work more on this and it should be ready now to replace the run_individual_tests.d
script.
This improvement is a huge superset of the functionality of this test runner that we added a few weeks ago and hasn't been integrated in any CI process (except for a single test at CircleCi).
The long run goal is to replace the Makefile with run.d
, but for now run.d
should already allow running the tests on Windows and remove the dependence on GNUmake.
tl;dr: nothing depends on it + we can slowly improve run.d
if there are still some slight differences between it and the Makefile (these probably won't be caught in the review anyhow).
|
||
// default target | ||
if (!args.length) | ||
args = ["all"]; |
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.
Not sure on the default behavior. I'm leaning towards printing the help page if now arguments are passed (current behavior of the run_individual_tests.d
tool.
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 that running all the tests by default is a more intuitive approach
foreach (t; targets) | ||
{ | ||
if (!force && resultsDir.buildPath(t ~ ".out").timeLastModified.ifThrown(SysTime.init) > | ||
scriptDir.buildPath(t).timeLastModified) |
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 also check the timestamp of DMD or the build tools here too.
return "solaris"; | ||
else version(SunOS) | ||
return "solaris"; | ||
else |
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.
(windows is on the top of this list now)
Looks like you forgot to delete the check for the run individual test. Delete it and we are ready to go. (this will solve the circleci failure) |
Do we still need the Makefile after this? Maybe we should consider deleting it. |
No we don't :)
The failure was due to change of the file name. Changing it made the CI happy again and I think it doesn't hurt to keep testing this in the CI. After all, eventually we want all CIs to use it. |
@marler8997 @JinShil are you two also okay with finally moving forward with this? |
test/run.d
Outdated
if (!args.length) | ||
args = ["all"]; | ||
|
||
alias normalizeTestName = f => format!"%s/%s"(f.absolutePath.dirName.baseName, f.baseName); |
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.
std.path.pathSeparator
instead of /
?
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 went with buildPath
test/tools/d_do_test.d
Outdated
} | ||
else | ||
{ | ||
auto process = spawnProcess(["./tools/sh_do_test.sh", input_dir, test_name]); | ||
auto process = spawnProcess([scriptDir ~ "/tools/sh_do_test.sh", input_dir, test_name]); |
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.
The /
will probably work fine in the posix/Bash environment. I don't know if it will or won't cause problems on Windows if we ever get to a point where we can run this outside of that environment. I suggest using std.path.pathSeparator
.
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 went with buildPath
exit(0); | ||
break; | ||
|
||
case "run_runnable_tests", "runnable": |
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.
The "run_" prefix seems redundant, but I'm just being picky.
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.
run_runnable_tests
is the name of the existing Makefile target and at least for the transition I wanted to keep the most commonly used Makefile targets
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, but I'm wondering if the use of /
as a delimiter will cause problems on Windows if run outside of a Posix/Bash environment. I'm also not sure how DMD handles /
and \
when used as a separator in its arguments on Windows
test/run.d
Outdated
@@ -0,0 +1,342 @@ | |||
#!/usr/bin/env rdmd | |||
/** | |||
Allows running tests individually |
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.
Probably not an entirely accurate summary anymore. It may be prudent to elaborate.
dbe4caf
to
e8626e4
Compare
So there have been many complaints about how hard running the test suite on Windows is.
Here's an excerpt:
This PR allows to run the testsuite without GNUMake by making the
run_individual_tests.d
wrapper no longer dependent on the Makefile.It's not perfect yet and I still have to test a few things, i.e.
results_dir
)$HOST_DMD
instead ofdmd
for building the tools$DMD
and$MODEL
is passed in everywherebut apart from that I think this already shows the general direction and it can already execute all tests, e.g.
(I opened this already, s.t. no duplicate work on this happens)