Skip to content

Conversation

@wilzbach
Copy link
Contributor

@wilzbach wilzbach commented Feb 8, 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.

@wilzbach wilzbach added Severity:Documentation Review:Trivial typos, formatting, comments labels Feb 8, 2018
@JackStouffer
Copy link
Contributor

I don't understand why users need to know this Phobos specific implementation detail.

At most, this would be a short note saying Std prefixed versions are reserved for Phobos.

@JackStouffer JackStouffer removed the Review:Trivial typos, formatting, comments label Feb 8, 2018
@wilzbach
Copy link
Contributor Author

wilzbach commented Feb 8, 2018

People complained about this e.g. @timotheecour @FeepingCreature
I think the problem is that

  1. Some people are used to test Phobos module with just rdmd -unittest -main foo.d
  2. People are packaging Phobos in their own ways (distros, company repos, etc.)

Even just (2) is reason enough for this to be in the changelog.

@FeepingCreature
Copy link
Contributor

FeepingCreature commented Feb 8, 2018

When building with -deps -unittest, DMD will recurse into Phobos unittests, even when building something unrelated. However, since StdUnittest is not set, the Phobos unittests are semantically invalid.

@JackStouffer
Copy link
Contributor

Wow, that worse than I originally understood. That means people's builds are broken because of the change to StdUnittest right?

If so we need to either revert until the change @jmdavis was making (only running tests for compiled files) is in. Or, version out the effected unittests a-la

version(StdUnittest) unittest
{
}

@FeepingCreature
Copy link
Contributor

FeepingCreature commented Feb 8, 2018

Indeed, though note that luckily this only seems to happen on master so far. What worries me is that there doesn't seem to be a build step to detect this issue.

In the medium term, it would probably be useful to have a command line flag to prevent -deps from recursing into certain packages, such as those that are linked in as libraries. Phobos could then be excluded via a default flag.

@jmdavis
Copy link
Member

jmdavis commented Feb 8, 2018

If so we need to either revert until the change @jmdavis was making (only running tests for compiled files) is in.

I'm doing no such thing. I suggested that it looked like we needed to go in that direction, and I suspect that a DIP is required. I'm not a compiler dev and have no idea how to go about implementing such a fix. This is almost certainly not something that is going to be fixed quickly. So, if version(StdUnittest) is causing problems, then either it needs to be given the axe, or all of the affected unittest blocks need to be marked with version(stdUnittest), as disgusting as that may be. However, unfortunately, this is exactly the sort of thing that we're not going to catch with the autotester, because it requires compiling other programs that use phobos rather than compiling phobos.

@timotheecour
Copy link
Contributor

timotheecour commented Feb 8, 2018 via email

@JackStouffer
Copy link
Contributor

Sorry, meant to say that you suggested it as a solution.

Regardless, it looks like for the time being StdUnittest needs to be removed from Phobos. Thoughts @wilzbach?

It's a shame to remove this optimization, but it also sucks that we are slowing down peoples unittest builds by running our own unittests. That has to really suck for people who are using something like systime or parallelism, as those can take more than 10 seconds.

@wilzbach
Copy link
Contributor Author

wilzbach commented Feb 8, 2018

However, unfortunately, this is exactly the sort of thing that we're not going to catch with the autotester,

Yeah, but that's why we have been working hard to get the Project Tester up, running and moderately stable.

@FeepingCreature that's one of the advantages of open-sourcing your libraries.

What worries me is that there doesn't seem to be a build step to detect this issue.

It's simple, no one is using -deps in their projects. At least not the ~35 projects we test.
And without Bugzilla issue, it's not a regression (we don't monitor IRC for bug reports).

Or, version out the effected unittests a-la

If those aren't too many, that's imho the best way to go. version(StdUnittest) is solving another real problem.

@jmdavis
Copy link
Member

jmdavis commented Feb 8, 2018

would something like this https://forum.dlang.org/post/mailman.3193.1518032575.9493.digitalmars-d@puremagic.com provide a better, less hacky and invasive solution?

Honestly, I think that this needs to be automatic unless there's a technical reason why it can't be. It's ridiculous to be running unittest blocks in modules that were only imported. And as soon as you're turning unittest blocks on or off manually, there are going to be mistakes.

Maybe such a feature would be worthwhile for being able to selectively run tests, but I don't think that it's a great way to go for fixing the problem of unittest blocks from other projects being compiled in when they shouldn't be.

@FeepingCreature
Copy link
Contributor

As I understand/conjecture it, the problem isn't even necessarily that they're compiled in so much as that they have to be processed in order to identify import statements that they may contain, so -deps is accurate. Hence why this problem only occurs in the -deps -unittest combination.

@n8sh
Copy link
Member

n8sh commented Feb 11, 2018

So, if version(StdUnittest) is causing problems, then either it needs to be given the axe, or all of the affected unittest blocks need to be marked with version(stdUnittest)

FYI I've done that in #6159

@jpf91
Copy link
Contributor

jpf91 commented Mar 4, 2018

Honestly, I think that this needs to be automatic unless there's a technical reason why it can't be. It's ridiculous to be running unittest blocks in modules that were only imported. And as soon as you're turning unittest blocks on or off manually, there are going to be mistakes.

👍

However, simply not running unittests for modules not being compiled would break the 'keep unittests in external file'+single file compilation idiom. I think there's a bigger problem here manifesting in

Essentially, we need a way of telling the compiler

  1. which modules are pre-compiled/available in an external library
  2. which modules are part of the current build sources

Ideally, (2) can be inferred by collecting all imported modules (through import chains) and removing the modules in (1). If every library provided a mylib.dmodule file which simply mapped a list of D modules to library files, you could do dmd -dmylib main.d instead of dmd -lmylib -I /usr/include/d/mylib/ -i=+main,-mylib -unittest=+main,-mylib -import=mylib. We could even reuse the pkg-config files which meson already uses/generates for D libraries. I guess I should write a DIP?

@JackStouffer
Copy link
Contributor

Any further discussion on this should be moved to the forums or slack.

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.

8 participants