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

Allow @betterC tests in Phobos #6645

Merged
merged 4 commits into from
Aug 22, 2018
Merged

Conversation

wilzbach
Copy link
Member

Open questions:

  • Should we remove the test/betterC folder? (the @BetterC test extraction is imho a better replacement)

Requires: dlang/tools#357

@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 + phobos#6645"

@PetarKirov
Copy link
Member

PetarKirov commented Jul 31, 2018

I guess having a separate folder is good primary for integration tests or test code that doesn't fit into any particular std.* module.

@@ -73,7 +73,7 @@ setup_repos()
git checkout -f FETCH_HEAD
fi

for proj in dmd druntime ; do
for proj in dmd druntime tools ; do
Copy link
Member Author

Choose a reason for hiding this comment

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

The auto-tester and other CI behave like this already anyhow.

(Also locking tools to a specific version was done initially because it seemed as a good idea at the time, but in practice it just made updates more annoying.)

################################################################################

betterc-phobos-tests: $(addsuffix .betterc,$(D_MODULES))
betterc: betterc-phobos-tests betterc-run-tests
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 add an alias betterC: betterc if wanted.

posix.mak Outdated
-defaultlib= -debuglib= $(LINKDL) $<
./$(ROOT)/unittest/betterC/$(notdir $(basename $<))

betterc-run-tests: $(subst .d,.run,$(wildcard test/betterC/*.d))
Copy link
Member Author

Choose a reason for hiding this comment

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

There's probably not much value in keeping these separate tests anymore as @betterC is almost as powerful and we avoid lots of redundant declarations.

Copy link
Member

Choose a reason for hiding this comment

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

Yep, I'm ok with removing this target.

@@ -116,7 +118,7 @@ if (isExpressionTuple!values)
}

///
@safe unittest
@safe @betterC unittest
Copy link
Member Author

Choose a reason for hiding this comment

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

This won't be displayed on dlang.org yet, but the next step would be to figure out how to get Ddoc / Ddox to do so.
(it will be a lot easier for Ddox though.)

@wilzbach
Copy link
Member Author

Should we remove the test/betterC folder? (the @BetterC test extraction is imho a better replacement)

I guess having a separate folder is good primary for integration tests or test code that doesn't fit into any particular std.* module.

Yep, but do we have examples where we would actually need to do this for Phobos?
AFAICT the main goal is just to ensure that most of Phobos eventually works with -betterC and I think the @betterC works well in this regard. For everything else, I guess DMD's testsuite is better suited?

Copy link
Member

@andralex andralex left a comment

Choose a reason for hiding this comment

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

LGTM, feel free to zero in on the details in review. Thanks Seb!

@wilzbach
Copy link
Member Author

With dlang/tools#357 merged, this should be green now :)

@@ -0,0 +1,4 @@
module std.internal.attributes;

// Internal attributes to be to e.g. annotate unittest blocks
Copy link
Member

Choose a reason for hiding this comment

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

What does this attribute mean? That it only works with betterC, or that it works with regular D or betterC?

@PetarKirov
Copy link
Member

@WalterBright, the intention is similar to other languages attributes like pure - @betterC unittests need to execute successfully in normal D and with -betterC.

@@ -0,0 +1,4 @@
module std.internal.attributes;

// Internal attributes to be to e.g. annotate unittest blocks
Copy link
Member

Choose a reason for hiding this comment

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

/**
Used to annotate `unittest`s which need to be tested in a `-betterC` environment.

Such `unittest`s will be compiled and executed without linking druntime in, with a
`__traits(getUnitTests, mixin(__MODULE__))` style test runner.
Note that just like any other `unittest` in phobos, they will also be compiled and executed
without `-betterC`.
*/
package(std) enum betterC = 1;

posix.mak Outdated
test/betterC/%.run: test/betterC/%.d $(DMD) $(LIB)
mkdir -p $(ROOT)/unittest/betterC
$(DMD) $(DFLAGS) -of$(ROOT)/unittest/betterC/$(notdir $(basename $<)) -betterC $(UDFLAGS) \
-defaultlib= -debuglib= $(LINKDL) $<
Copy link
Member

Choose a reason for hiding this comment

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

-defaultlib= -debuglib= -> $(NODEFAULTLIB)

posix.mak Outdated
-defaultlib= -debuglib= $(LINKDL) $<
./$(ROOT)/unittest/betterC/$(notdir $(basename $<))

betterc-run-tests: $(subst .d,.run,$(wildcard test/betterC/*.d))
Copy link
Member

Choose a reason for hiding this comment

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

Yep, I'm ok with removing this target.

posix.mak Outdated
DUB_PATH=$(abspath $(shell which $(DUB)))
ifeq (,$(DUB_PATH))
DUB_PATH=$(DUB_DIR)/bin/dub
DUB=$(DUB_DIR)/bin/dub
Copy link
Member

Choose a reason for hiding this comment

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

DUB=$(DUB_PATH) ?

posix.mak Outdated
endif

$(DUB): | $(DUB_DIR) $(LIB)
cd $(DUB_DIR) && DFLAGS="$(DFLAGS) $(LIB) $(NODEFAULTLIB) $(LINKDL)" DMD=$${PWD}/$(DMD) ./build.sh
Copy link
Member

Choose a reason for hiding this comment

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

Why is $(NODEFAULTLIB) necessary here?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I guess because you want to use the version of druntime and phobos that were just built.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, I have to build dub from source, because auto-tester doesn't come with a dub version (kinda silly) and also no globally installed dmd (HOST_DMD is only exposed when building dmd and my PR to fix that has remained unanswered: braddr/at-client#9).

@wilzbach wilzbach force-pushed the unittest-betterC branch 4 times, most recently from dcf15af to 28e322c Compare August 15, 2018 14:40
@wilzbach
Copy link
Member Author

This is sadly blocked until I figure out a reliable way to use or build dub on the auto-tester.
At the moment, cloning dub and building it seems to work, but due to make's parallel execution this seems to happen in many parallel steps and some of them fail :/

@wilzbach
Copy link
Member Author

This is sadly blocked until I figure out a reliable way to use or build dub on the auto-tester.

Ah well, I want to start adding @betterC test and stop regressions, so I removed the last experimental commit that adds dub to the auto-tester (and will move this into a new PR) and just enabled the betterC on CircleCi.
This is a bit problematic, because the CircleCi tests aren't run on dmd nor druntime, but thanks to our new Buildkite setup I will later today setup Buildkite, s.t. it also runs all testsuites and we can prevent such problems.

@wilzbach
Copy link
Member Author

This is a bit problematic, because the CircleCi tests aren't run on dmd nor druntime, but thanks to our new Buildkite setup I will later today setup Buildkite, s.t. it also runs all testsuites and we can prevent such problems.

With #6669 and dlang/ci#287 merged, Buildkite will now run the buildkite-test target on every PR.
This means that the @betterC tests added here will also be run on every PR at dmd, druntime and of course Phobos and thus I think we can finally move on with this (:

$(NODEFAULTLIB) $(LINKDL) $<
./$(ROOT)/unittest/betterC/$(notdir $(basename $<))

betterc-run-tests: $(subst .d,.run,$(wildcard test/betterC/*.d))
Copy link
Member Author

Choose a reason for hiding this comment

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

As mentioned in earlier discussions, there's no real need to for these separate betterC tests anymore and I would be ok with removing them either in this PR or a follow-up.

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