Skip to content

move extra::test to libtest #12343

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

Merged
merged 1 commit into from
Feb 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions mk/crates.mk
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
################################################################################

TARGET_CRATES := std extra green rustuv native flate arena glob term semver \
uuid serialize sync getopts collections num
uuid serialize sync getopts collections num test
HOST_CRATES := syntax rustc rustdoc fourcc
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
TOOLS := compiletest rustdoc rustc
Expand All @@ -63,7 +63,8 @@ DEPS_native := std
DEPS_syntax := std term serialize collections
DEPS_rustc := syntax native:rustllvm flate arena serialize sync getopts \
collections extra
DEPS_rustdoc := rustc native:sundown serialize sync getopts collections
DEPS_rustdoc := rustc native:sundown serialize sync getopts collections \
test
DEPS_flate := std native:miniz
DEPS_arena := std collections
DEPS_glob := std
Expand All @@ -76,8 +77,9 @@ 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
TOOL_DEPS_compiletest := test green rustuv getopts
TOOL_DEPS_rustdoc := rustdoc green rustuv
TOOL_DEPS_rustc := rustc green rustuv
TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs
Expand Down
5 changes: 1 addition & 4 deletions src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@
#[allow(non_camel_case_types)];
#[deny(warnings)];

extern crate extra;
extern crate test;
extern crate getopts;

use std::os;
use std::io;
use std::io::fs;

use getopts::{optopt, optflag, reqopt};
use extra::test;

use common::config;
use common::mode_run_pass;
use common::mode_run_fail;
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use std::str;
use std::task;
use std::vec;

use extra::test::MetricMap;
use test::MetricMap;

pub fn run(config: config, testfile: ~str) {

Expand Down
17 changes: 9 additions & 8 deletions src/doc/guide-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ runner.

The type signature of a benchmark function differs from a unit test:
it takes a mutable reference to type
`extra::test::BenchHarness`. Inside the benchmark function, any
`test::BenchHarness`. Inside the benchmark function, any
time-variable or "setup" code should execute first, followed by a call
to `iter` on the benchmark harness, passing a closure that contains
the portion of the benchmark you wish to actually measure the
Expand All @@ -185,9 +185,10 @@ amount.
For example:

~~~
extern crate extra;
extern crate test;

use std::vec;
use extra::test::BenchHarness;
use test::BenchHarness;

#[bench]
fn bench_sum_1024_ints(b: &mut BenchHarness) {
Expand Down Expand Up @@ -243,8 +244,8 @@ recognize that some calculation has no external effects and remove
it entirely.

~~~
extern crate extra;
use extra::test::BenchHarness;
extern crate test;
use test::BenchHarness;

#[bench]
fn bench_xor_1000_ints(bh: &mut BenchHarness) {
Expand Down Expand Up @@ -273,15 +274,15 @@ example above by adjusting the `bh.iter` call to
bh.iter(|| range(0, 1000).fold(0, |old, new| old ^ new))
~~~

Or, the other option is to call the generic `extra::test::black_box`
Or, the other option is to call the generic `test::black_box`
function, which is an opaque "black box" to the optimizer and so
forces it to consider any argument as used.

~~~
Copy link
Member

Choose a reason for hiding this comment

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

This code example will likely need extern crate test;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

use extra::test::black_box
extern crate test;

bh.iter(|| {
black_box(range(0, 1000).fold(0, |old, new| old ^ new));
test::black_box(range(0, 1000).fold(0, |old, new| old ^ new));
});
~~~

Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustdoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ testing this code, the `fib` function will be included (so it can compile).

Running tests often requires some special configuration to filter tests, find
libraries, or try running ignored examples. The testing framework that rustdoc
uses is build on `extra::test`, which is also used when you compile crates with
uses is build on crate `test`, which is also used when you compile crates with
rustc's `--test` flag. Extra arguments can be passed to rustdoc's test harness
with the `--test-args` flag.

Expand Down
6 changes: 3 additions & 3 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,10 @@ impl<T> Drop for TypedArena<T> {
}

#[cfg(test)]
mod test {
extern crate extra;
mod tests {
extern crate test;
use self::test::BenchHarness;
use super::{Arena, TypedArena};
use self::extra::test::BenchHarness;

struct Point {
x: int,
Expand Down
3 changes: 2 additions & 1 deletion src/libcollections/bitv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,8 @@ impl<'a> Iterator<uint> for BitPositions<'a> {

#[cfg(test)]
mod tests {
use extra::test::BenchHarness;
extern crate test;
use self::test::BenchHarness;

use bitv::{Bitv, SmallBitv, BigBitv, BitvSet, from_bools, from_fn,
from_bytes};
Expand Down
3 changes: 2 additions & 1 deletion src/libcollections/deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ pub trait Deque<T> : Mutable {

#[cfg(test)]
pub mod bench {
extern crate test;
use self::test::BenchHarness;
use std::container::MutableMap;
use std::{vec, rand};
use std::rand::Rng;
use extra::test::BenchHarness;

pub fn insert_rand_n<M:MutableMap<uint,uint>>(n: uint,
map: &mut M,
Expand Down
3 changes: 2 additions & 1 deletion src/libcollections/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,9 @@ impl<D:Decoder,T:Decodable<D>> Decodable<D> for DList<T> {

#[cfg(test)]
mod tests {
extern crate test;
use self::test::BenchHarness;
use deque::Deque;
use extra::test;
use std::rand;
use super::{DList, Node, ListInsertion};

Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#[feature(macro_rules, managed_boxes)];

extern crate serialize;
#[cfg(test)] extern crate extra; // benchmark tests need this
#[cfg(test)] extern crate test;

pub use bitv::Bitv;
pub use btree::BTree;
Expand Down
3 changes: 2 additions & 1 deletion src/libcollections/ringbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,9 @@ impl<D:Decoder,T:Decodable<D>> Decodable<D> for RingBuf<T> {

#[cfg(test)]
mod tests {
extern crate test;
use self::test::BenchHarness;
use deque::Deque;
use extra::test;
use std::clone::Clone;
use std::cmp::Eq;
use super::RingBuf;
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/smallintmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,9 @@ mod test_map {

#[cfg(test)]
mod bench {

extern crate test;
use self::test::BenchHarness;
use super::SmallIntMap;
use extra::test::BenchHarness;
use deque::bench::{insert_rand_n, insert_seq_n, find_rand_n, find_seq_n};

// Find seq
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/treemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1494,9 +1494,9 @@ mod test_treemap {

#[cfg(test)]
mod bench {

extern crate test;
use self::test::BenchHarness;
use super::TreeMap;
use extra::test::BenchHarness;
use deque::bench::{insert_rand_n, insert_seq_n, find_rand_n, find_seq_n};

// Find seq
Expand Down
11 changes: 1 addition & 10 deletions src/libextra/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,10 @@ Rust extras are part of the standard Rust distribution.

extern crate sync;
extern crate serialize;

extern crate collections;

// Utility modules

pub mod c_vec;

// And ... other stuff

pub mod url;
pub mod json;
pub mod tempfile;
Expand All @@ -56,15 +51,11 @@ pub mod stats;
#[cfg(unicode)]
mod unicode;

// Compiler support modules

pub mod test;

// A curious inner-module that's not exported that contains the binding
// 'extra' so that macro-expanded references to extra::serialize and such
// can be resolved within libextra.
#[doc(hidden)]
pub mod extra {
pub use serialize;
pub use test;
}

3 changes: 2 additions & 1 deletion src/libextra/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,8 @@ mod tests {

#[cfg(test)]
mod bench {
use extra::test::BenchHarness;
extern crate test;
use self::test::BenchHarness;
use std::vec;
use stats::Stats;

Expand Down
5 changes: 3 additions & 2 deletions src/libnum/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2546,11 +2546,12 @@ mod bigint_tests {

#[cfg(test)]
mod bench {
use super::{BigInt, BigUint};
extern crate test;
use self::test::BenchHarness;
use super::BigUint;
use std::iter;
use std::mem::replace;
use std::num::{FromPrimitive, Zero, One};
use extra::test::BenchHarness;

fn factorial(n: uint) -> BigUint {
let mut f: BigUint = One::one();
Expand Down
3 changes: 1 addition & 2 deletions src/libnum/rational.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,7 @@ mod test {

mod arith {
use super::{_0, _1, _2, _1_2, _3_2, _neg1_2, to_big};
use super::super::{Ratio, Rational, BigRational};

use super::super::{Ratio, Rational};

#[test]
fn test_add() {
Expand Down
Loading