Skip to content

Extract tests from libcore to a separate crate #15245

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

Closed
wants to merge 1 commit into from

Conversation

sfackler
Copy link
Member

Libcore's test infrastructure is complicated by the fact that many lang
items are defined in the crate. The current approach (realcore/realstd
imports) is hacky and hard to work with (tests inside of core::cmp
haven't been run for months!).

Moving tests to a separate crate does mean that they can only test the
public API of libcore, but I don't feel that that is too much of an
issue. The only tests that I had to get rid of were some checking the
various numeric formatters, but those are also exercised through normal
format! calls in other tests.

@sfackler
Copy link
Member Author

This is necessary to finish the implementation of RFC 28.

@alexcrichton would you be able to handle the makefile updates for this? I got lost in the depths of test.mk. Once libcore isn't built for tests anymore I can cut all of the #[cfg(test)] stuff.

@huonw
Copy link
Member

huonw commented Jun 29, 2014

The only tests that I had to get rid of were some checking the
various numeric formatters, but those are also exercised through normal
format! calls in other tests.

Why couldn't these be moved?

@sfackler
Copy link
Member Author

The structs they were testing are private (core::fmt::num::Decimal etc)

@huonw
Copy link
Member

huonw commented Jun 29, 2014

Ah, yes, I see that most of the tests (all the "interesting" ones) in core::fmt::num could move, and it's just the few testing the private details that had to die (and as you say, they're exercised in the other tests there).

@alexcrichton
Copy link
Member

I don't think it will be easy to have make check-stage2-core not actually run rustc src/libcore/lib.rs --test, but it should be easy-enough to get core at least building with --test even if it's running 0 tests.

Could these perhaps be moved to one giant run-pass test? Something like:

src/test/run-pass/coretest.rs
src/test/run-pass/coretest/any.rs
src/test/run-pass/coretest/int.rs
...

That would at least involve fewer changes to the makefile infrastructure!

Could you also add a comment to the top of libcore (not a doc comment) explaining why there are 0 unit tests in the library itself?

@sfackler
Copy link
Member Author

There's a fair number of dubious #[cfg(test)] and #[cfg(not(test))] stuff in coretest that we'd ideally be able to get rid of. When I was poking around in the makefiles, it seemed like it might be possible to avoid building tests for libcore by filtering it out of TEST_TARGET_CRATES?

It seems like it'd be a bit unfortunate to move it to rpass since I don't think you'd be able to do TESTNAME filtering on it.

@alexcrichton
Copy link
Member

Ok, that makes sense. Another possibility would be a src/coretest/lib.rs folder which is only part of TEST_TARGET_CRATES?

@sfackler
Copy link
Member Author

@alexcrichton seem reasonable? I still have to strip all of the test cfg-ing from libcore and rebase.

@alexcrichton
Copy link
Member

I'm ok if you filter out core from TEST_TARGET_CRATES to avoid all the cfg-madness

@sfackler
Copy link
Member Author

Should be ready to go (modulo a rebase). Look good other than that?

@sfackler
Copy link
Member Author

@alexcrichton rebased, r?

@alexcrichton
Copy link
Member

I checked mk/tests.mk and src/libcore/lib.rs for a comment explaining the split of tests. Was it placed elsewhere?

r=me if there's a comment somewhere.

Libcore's test infrastructure is complicated by the fact that many lang
items are defined in the crate. The current approach (realcore/realstd
imports) is hacky and hard to work with (tests inside of core::cmp
haven't been run for months!).

Moving tests to a separate crate does mean that they can only test the
public API of libcore, but I don't feel that that is too much of an
issue. The only tests that I had to get rid of were some checking the
various numeric formatters, but those are also exercised through normal
format! calls in other tests.
@sfackler
Copy link
Member Author

Oh, whoops, updated with a comment in libcore/lib.rs

bors added a commit that referenced this pull request Jun 29, 2014
Libcore's test infrastructure is complicated by the fact that many lang
items are defined in the crate. The current approach (realcore/realstd
imports) is hacky and hard to work with (tests inside of core::cmp
haven't been run for months!).

Moving tests to a separate crate does mean that they can only test the
public API of libcore, but I don't feel that that is too much of an
issue. The only tests that I had to get rid of were some checking the
various numeric formatters, but those are also exercised through normal
format! calls in other tests.
@bors bors closed this Jun 30, 2014
@sfackler sfackler deleted the coretest branch November 26, 2016 05:53
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 17, 2023
Fix missing terminator in pattern matching of consts

fix rust-lang#15238
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants