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

move extra::test to libtest #12343

Merged
merged 1 commit into from
Feb 20, 2014
Merged

Conversation

liigo
Copy link
Contributor

@liigo liigo commented Feb 17, 2014

I don't think extra is a good/meaningful name for a library. libextra should disappear, and we move all of its sub modules out of it. This PR is just one of that steps: move extra::test to libtest.

I didn't add libtest to doc index, because it's an internal library currently.

Update:

All comments addressed. All tests passed. Rebased and squashed.

@huonw
Copy link
Member

huonw commented Feb 17, 2014

cc #8784.

ast::ViewItemUse(
~[@nospan(ast::ViewPathSimple(id_extra,
path_node(~[id_extra]),
~[@nospan(ast::ViewPathSimple(test_crate_id,
Copy link
Member

Choose a reason for hiding this comment

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

This is the problem here: it is making

mod __something {
     use test;

     // ... things using `test::foo()`
}

but libtest has no module test. One fix would be to add a module to libtest/lib.rs that reexports the relevant functions, e.g.

mod libtest_satisfy_the_test_runner { 
    pub use {test_main_static, 
             TestDescAndFn,
             TestDesc, StaticTestName,
             StaticTestFn, StaticBenchFn};
}

(Change the let test_crate_id = token::str_to_ident("test"); to "libtest_satisfy_the_test_runner".)

Hopefully someone has a better idea because that solution is really ugly. :(

Copy link
Member

Choose a reason for hiding this comment

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

This is why libstd has mod std inside of it, I think this just means that libtest needs to have mod test inside of it (for the same hack-ish reasons)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@huonw @alexcrichton Thank you, I'll try.

@alexcrichton
Copy link
Member

Stylistically instead of

mod tests {
    extern crate test;
    use self::test::BenchHarness;
}

I prefer

mod tests {
    extern crate test;

    #[bench] fn bench(bh: &mut test::BenchHarness) { /* ... */ }
}

Could you update code examples and such to this?

@huonw
Copy link
Member

huonw commented Feb 17, 2014

@alexcrichton I disagree: BenchHarness is long enough as it is, and, anyway, the convention from the style guide is to import types unqualified.

@alexcrichton
Copy link
Member

Ah I suppose so, I guess I was just a little rattled at all the use self::test::BenchHarness immediately after extern crate test

@liigo
Copy link
Contributor Author

liigo commented Feb 18, 2014

@huonw @alexcrichton Why we name BenchHarness so long? I would like to rename it to Bench in another PR. Any idea?

@alexcrichton
Copy link
Member

Let's not rename BenchHarness as part of this PR.

@@ -76,6 +77,7 @@ DEPS_getopts := std
DEPS_collections := std serialize
DEPS_fourcc := syntax std
DEPS_num := std extra
DEPS_test := std extra collections getopts serialize term

TOOL_DEPS_compiletest := extra green rustuv getopts
Copy link
Member

Choose a reason for hiding this comment

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

It also looks like compiletest should lose its extra dependency and pick up its test dependency.

@liigo
Copy link
Contributor Author

liigo commented Feb 19, 2014

I have updated this PR, all comments addressed. Ready to review and merge.
There is a note: in PR's description also. @alexcrichton @huonw ?

ast::DUMMY_NODE_ID)
};
*/
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't be including chunks of commented out code, if it's no longer necessary it should be deleted.

Copy link
Member

Choose a reason for hiding this comment

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

I also think this logic needs to be preserved, this is the purpose of the 'mod test' in `libtest/lib.rs'

Copy link
Member

Choose a reason for hiding this comment

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

We could just let libtest manage its own test scope, i.e. only insert extern crate test when we're not in test, otherwise, if we are in test, do nothing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I'll restore the commented out code in rustc, and add mod test to libtest, come back later. Though I don't know why we need do these special cases both in rustc and libtest. A simple extern crate test (in the current commit) just make it works (all tests passed). @alexcrichton @huonw

Copy link
Member

Choose a reason for hiding this comment

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

If you inject extern crate test then you get this duality where libtest is being tested with another version of libtest. This causes all sorts of resolve pains when you want to start using one or the other. I think that it may be ok, but I would rather bootstrap libtest with itself if possible.

Copy link
Member

Choose a reason for hiding this comment

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

(It also leads to the weirdest error messages "expected test::Foo but found test::Foo".)

@liigo
Copy link
Contributor Author

liigo commented Feb 20, 2014

@huonw @alexcrichton I've updated this PR, added mod test to libtest. Please take another review. Thank you!

bors added a commit that referenced this pull request Feb 20, 2014
…richton

I don't think `extra` is a good/meaningful name for a library. `libextra` should disappear, and we move all of its sub modules out of it. This PR is just one of that steps: move `extra::test` to `libtest`.

I didn't add `libtest` to doc index, because it's an internal library currently.

**Update:**

All comments addressed. All tests passed. Rebased and squashed.
@bors bors closed this Feb 20, 2014
@bors bors merged commit 53b9d1a into rust-lang:master Feb 20, 2014
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.

5 participants