Skip to content
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

Merged
merged 1 commit into from
May 7, 2018
Merged

Use D to run the testsuite #8162

merged 1 commit into from
May 7, 2018

Conversation

wilzbach
Copy link
Member

@wilzbach wilzbach commented Apr 11, 2018

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.

  • can allow environment variables that can be overwritten in the Makefile, overwritten here too (e.g. results_dir)
  • use $HOST_DMD instead of dmd for building the tools
  • ensure that the correct $DMD and $MODEL is passed in everywhere
  • normalize the file names, s.t. this script can be run from anywhere
  • make sure it actually runs on Windows

but apart from that I think this already shows the general direction and it can already execute all tests, e.g.

./run_individual_tests.d fail_compilation
./run_individual_tests.d clean
./run_individual_tests.d all
./run_individual_tests.d fail_compilation -j10
./run_individual_tests.d fail_compilation/fail11562.d
./run_individual_tests.d fail_compilation AUTO_UPDATE=1

(I opened this already, s.t. no duplicate work on this happens)

@dlang-bot dlang-bot added the WIP Work In Progress - not ready for review or pulling label Apr 11, 2018
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @wilzbach!

Bugzilla references

Your 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 locally

If 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"

@wilzbach wilzbach force-pushed the d-make branch 2 times, most recently from 90942c0 to 8851c86 Compare April 11, 2018 12:00
test/run.d Outdated
env[key] = default_;
}

// Sets the environment variables required by d_do_test
Copy link
Contributor

@marler8997 marler8997 Apr 11, 2018

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
}
}
}

Copy link
Contributor

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"])
Copy link
Contributor

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":
Copy link
Contributor

@marler8997 marler8997 Apr 11, 2018

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"));
Copy link
Contributor

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;
Copy link
Contributor

@marler8997 marler8997 Apr 11, 2018

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);
}

Copy link
Member Author

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
Copy link
Contributor

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.

Copy link
Member Author

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)

@marler8997
Copy link
Contributor

Could we add a "v|verbose" flag to see things like the d_do_test commands that are being run?

@marler8997
Copy link
Contributor

marler8997 commented Apr 12, 2018

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:

----------------------------------------------
Test Result Summary
----------------------------------------------
failed runnable/test123.d
failed compilable/a.d
failed compilable/adfjalsdf.d
----------------------------------------------
100 Passed 20 Failed

@wilzbach
Copy link
Member Author

Could we add a "v|verbose" flag to see things like the d_do_test commands that are being run?

Done. Though I only added it in a very naive way for now. We can always expand on this later.

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:

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?
It's already a rather large PR.

@wilzbach wilzbach force-pushed the d-make branch 2 times, most recently from 661ae1d to fdabda4 Compare April 29, 2018 20:51
@wilzbach wilzbach removed the WIP Work In Progress - not ready for review or pulling label Apr 29, 2018
@wilzbach wilzbach changed the title [WIP] Use D to run the testsuite Use D to run the testsuite Apr 29, 2018
Copy link
Member Author

@wilzbach wilzbach left a 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"];
Copy link
Member Author

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.

Copy link
Contributor

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)
Copy link
Member Author

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
Copy link
Member Author

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)

@RazvanN7
Copy link
Contributor

RazvanN7 commented May 2, 2018

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)

@RazvanN7
Copy link
Contributor

RazvanN7 commented May 2, 2018

Do we still need the Makefile after this? Maybe we should consider deleting it.

@wilzbach
Copy link
Member Author

wilzbach commented May 2, 2018

Do we still need the Makefile after this? Maybe we should consider deleting it.

No we don't :)
But currently a lot of CIs still depend on it, so the idea is slowly to migrate away from it.
Also, this new run.d test runner probably still needs a bit of real life testing and feedback.

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)

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.

@wilzbach
Copy link
Member Author

wilzbach commented May 2, 2018

@marler8997 @JinShil are you two also okay with finally moving forward with this?
We can always work out the subtleties in follow-ups.

test/run.d Outdated
if (!args.length)
args = ["all"];

alias normalizeTestName = f => format!"%s/%s"(f.absolutePath.dirName.baseName, f.baseName);
Copy link
Contributor

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 /?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with buildPath

}
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]);
Copy link
Contributor

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.

Copy link
Member Author

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":
Copy link
Contributor

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.

Copy link
Member Author

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

Copy link
Contributor

@JinShil JinShil left a 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
Copy link
Contributor

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.

@dlang-bot dlang-bot merged commit f94107e into dlang:master May 7, 2018
@wilzbach wilzbach deleted the d-make branch May 25, 2018 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants