pub fn krate(build: &Build,
             compiler: &Compiler,
             target: &str,
             mode: Mode,
             test_kind: TestKind,
             krate: Option<&str>) {
    let (name, path, features, root) = match mode {
        Mode::Libstd => {
            ("libstd", "src/libstd", build.std_features(), "std")
        }
        Mode::Libtest => {
            ("libtest", "src/libtest", String::new(), "test")
        }
        Mode::Librustc => {
            ("librustc", "src/rustc", build.rustc_features(), "rustc-main")
        }
        _ => panic!("can only test libraries"),
    };
    println!("{} {} stage{} ({} -> {})", test_kind, name, compiler.stage,
             compiler.host, target);

    // If we're not doing a full bootstrap but we're testing a stage2 version of
    // libstd, then what we're actually testing is the libstd produced in
    // stage1. Reflect that here by updating the compiler that we're working
    // with automatically.
    let compiler = if build.force_use_stage1(compiler, target) {
        Compiler::new(1, compiler.host)
    } else {
        compiler.clone()
    };

    // Build up the base `cargo test` command.
    //
    // Pass in some standard flags then iterate over the graph we've discovered
    // in `cargo metadata` with the maps above and figure out what `-p`
    // arguments need to get passed.
    let mut cargo = build.cargo(&compiler, mode, target, test_kind.subcommand());
    cargo.arg("--manifest-path")
         .arg(build.src.join(path).join("Cargo.toml"))
         .arg("--features").arg(features);

    match krate {
        Some(krate) => {
            cargo.arg("-p").arg(krate);
        }
        None => {
            let mut visited = HashSet::new();
            let mut next = vec![root];
            while let Some(name) = next.pop() {
                // Right now jemalloc is our only target-specific crate in the
                // sense that it's not present on all platforms. Custom skip it
                // here for now, but if we add more this probably wants to get
                // more generalized.
                //
                // Also skip `build_helper` as it's not compiled normally for
                // target during the bootstrap and it's just meant to be a
                // helper crate, not tested. If it leaks through then it ends up
                // messing with various mtime calculations and such.
                if !name.contains("jemalloc") && name != "build_helper" {
                    cargo.arg("-p").arg(&format!("{}:0.0.0", name));
                }
                for dep in build.crates[name].deps.iter() {
                    if visited.insert(dep) {
                        next.push(dep);
                    }
                }
            }
        }
    }

    // The tests are going to run with the *target* libraries, so we need to
    // ensure that those libraries show up in the LD_LIBRARY_PATH equivalent.
    //
    // Note that to run the compiler we need to run with the *host* libraries,
    // but our wrapper scripts arrange for that to be the case anyway.
    let mut dylib_path = dylib_path();
    dylib_path.insert(0, build.sysroot_libdir(&compiler, target));
    cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());

    if target.contains("emscripten") || build.remote_tested(target) {
        cargo.arg("--no-run");
    }

    cargo.arg("--");

    if build.config.quiet_tests {
        cargo.arg("--quiet");
    }

    let _time = util::timeit();

    if target.contains("emscripten") {
        build.run(&mut cargo);
        krate_emscripten(build, &compiler, target, mode);
    } else if build.remote_tested(target) {
        build.run(&mut cargo);
        krate_remote(build, &compiler, target, mode);
    } else {
        cargo.args(&build.flags.cmd.test_args());
        build.run(&mut cargo);
    }
}
/// Run all unit tests plus documentation tests for an entire crate DAG defined
/// by a `Cargo.toml`
///
/// This is what runs tests for crates like the standard library, compiler, etc.
/// It essentially is the driver for running `cargo test`.
///
/// Currently this runs all tests for a DAG by passing a bunch of `-p foo`
/// arguments, and those arguments are discovered from `cargo metadata`.
Run all unit tests plus documentation tests for an entire crate DAG defined
by a `Cargo.toml`

This is what runs tests for crates like the standard library, compiler, etc.
It essentially is the driver for running `cargo test`.

Currently this runs all tests for a DAG by passing a bunch of `-p foo`
arguments, and those arguments are discovered from `cargo metadata`.
Run all unit tests plus documentation tests for an entire crate DAG defined by a ` Cargo . toml ` This is what runs tests for crates like the standard library compiler etc . It essentially is the driver for running ` cargo test ` . Currently this runs all tests for a DAG by passing a bunch of ` - p foo ` arguments and those arguments are discovered from ` cargo metadata ` .
pub fn krate(build: &Build,
             compiler: &Compiler,
             target: &str,
             mode: Mode,
             test_kind: TestKind,
             krate: Option<&str>) {
    let (name, path, features, root) = match mode {
        Mode::Libstd => {
            ("libstd", "src/libstd", build.std_features(), "std")
        }
        Mode::Libtest => {
            ("libtest", "src/libtest", String::new(), "test")
        }
        Mode::Librustc => {
            ("librustc", "src/rustc", build.rustc_features(), "rustc-main")
        }
        _ => panic!("can only test libraries"),
    };
    println!("{} {} stage{} ({} -> {})", test_kind, name, compiler.stage,
             compiler.host, target);
    // If we're not doing a full bootstrap but we're testing a stage2 version of
    // libstd, then what we're actually testing is the libstd produced in
    // stage1. Reflect that here by updating the compiler that we're working
    // with automatically.
    let compiler = if build.force_use_stage1(compiler, target) {
        Compiler::new(1, compiler.host)
    } else {
        compiler.clone()
    };
    // Build up the base `cargo test` command.
    //
    // Pass in some standard flags then iterate over the graph we've discovered
    // in `cargo metadata` with the maps above and figure out what `-p`
    // arguments need to get passed.
    let mut cargo = build.cargo(&compiler, mode, target, test_kind.subcommand());
    cargo.arg("--manifest-path")
         .arg(build.src.join(path).join("Cargo.toml"))
         .arg("--features").arg(features);
    match krate {
        Some(krate) => {
            cargo.arg("-p").arg(krate);
        }
        None => {
            let mut visited = HashSet::new();
            let mut next = vec![root];
            while let Some(name) = next.pop() {
                // Right now jemalloc is our only target-specific crate in the
                // sense that it's not present on all platforms. Custom skip it
                // here for now, but if we add more this probably wants to get
                // more generalized.
                //
                // Also skip `build_helper` as it's not compiled normally for
                // target during the bootstrap and it's just meant to be a
                // helper crate, not tested. If it leaks through then it ends up
                // messing with various mtime calculations and such.
                if !name.contains("jemalloc") && name != "build_helper" {
                    cargo.arg("-p").arg(&format!("{}:0.0.0", name));
                }
                for dep in build.crates[name].deps.iter() {
                    if visited.insert(dep) {
                        next.push(dep);
                    }
                }
            }
        }
    }
    // The tests are going to run with the *target* libraries, so we need to
    // ensure that those libraries show up in the LD_LIBRARY_PATH equivalent.
    //
    // Note that to run the compiler we need to run with the *host* libraries,
    // but our wrapper scripts arrange for that to be the case anyway.
    let mut dylib_path = dylib_path();
    dylib_path.insert(0, build.sysroot_libdir(&compiler, target));
    cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
    if target.contains("emscripten") || build.remote_tested(target) {
        cargo.arg("--no-run");
    }
    cargo.arg("--");
    if build.config.quiet_tests {
        cargo.arg("--quiet");
    }
    let _time = util::timeit();
    if target.contains("emscripten") {
        build.run(&mut cargo);
        krate_emscripten(build, &compiler, target, mode);
    } else if build.remote_tested(target) {
        build.run(&mut cargo);
        krate_remote(build, &compiler, target, mode);
    } else {
        cargo.args(&build.flags.cmd.test_args());
        build.run(&mut cargo);
    }
}
pub fn krate ( build : & Build , compiler : & Compiler , target : & str , mode : Mode , test_kind : TestKind , krate : Option < & str > ) { let ( name , path , features , root ) = match mode { Mode :: Libstd => { ( " " , " " , build . std_features ( ) , " " ) } Mode :: Libtest => { ( " " , " " , String :: new ( ) , " " ) } Mode :: Librustc => { ( " " , " " , build . rustc_features ( ) , " " ) } _ => panic ! ( " " ) , } ; println ! ( " " test_kind name compiler stage compiler host target ) ; // If we're not doing a full bootstrap but we're testing a stage2 version of // libstd, then what we're actually testing is the libstd produced in // stage1. Reflect that here by updating the compiler that we're working // with automatically. let compiler = if build . force_use_stage1 ( compiler , target ) { Compiler :: new ( 1 , compiler . host ) } else { compiler . clone ( ) } ; // Build up the base `cargo test` command. // // Pass in some standard flags then iterate over the graph we've discovered // in `cargo metadata` with the maps above and figure out what `-p` // arguments need to get passed. let mut cargo = build . cargo ( & compiler , mode , target , test_kind . subcommand ( ) ) ; cargo . arg ( " " ) . arg ( build . src . join ( path ) . join ( " " ) ) . arg ( " " ) . arg ( features ) ; match krate { Some ( krate ) => { cargo . arg ( " " ) . arg ( krate ) ; } None => { let mut visited = HashSet :: new ( ) ; let mut next = vec ! [ root ] ; while let Some ( name ) = next . pop ( ) { // Right now jemalloc is our only target-specific crate in the // sense that it's not present on all platforms. Custom skip it // here for now, but if we add more this probably wants to get // more generalized. // // Also skip `build_helper` as it's not compiled normally for // target during the bootstrap and it's just meant to be a // helper crate, not tested. If it leaks through then it ends up // messing with various mtime calculations and such. if ! name . contains ( " " ) && name != " " { cargo . arg ( " " ) . arg ( & format ! ( " " name ) ) ; } for dep in build . crates [ name ] . deps . iter ( ) { if visited . insert ( dep ) { next . push ( dep ) ; } } } } } // The tests are going to run with the *target* libraries, so we need to // ensure that those libraries show up in the LD_LIBRARY_PATH equivalent. // // Note that to run the compiler we need to run with the *host* libraries, // but our wrapper scripts arrange for that to be the case anyway. let mut dylib_path = dylib_path ( ) ; dylib_path . insert ( 0 , build . sysroot_libdir ( & compiler , target ) ) ; cargo . env ( dylib_path_var ( ) , env :: join_paths ( & dylib_path ) . unwrap ( ) ) ; if target . contains ( " " ) || build . remote_tested ( target ) { cargo . arg ( " " ) ; } cargo . arg ( " " ) ; if build . config . quiet_tests { cargo . arg ( " " ) ; } let _time = util :: timeit ( ) ; if target . contains ( " " ) { build . run ( & mut cargo ) ; krate_emscripten ( build , & compiler , target , mode ) ; } else if build . remote_tested ( target ) { build . run ( & mut cargo ) ; krate_remote ( build , & compiler , target , mode ) ; } else { cargo . args ( & build . flags . cmd . test_args ( ) ) ; build . run ( & mut cargo ) ; } }
Run all unit tests plus documentation tests for an entire crate DAG defined
by a `Cargo.toml`
Run all unit tests plus documentation tests for an entire crate DAG defined by a ` Cargo . toml `
build
&Build
compiler
&Compiler
target
&str
mode
Mode
test_kind
TestKind
krate
Option<&str>
build
&Build
compiler
&Compiler
target
&str
mode
Mode
test_kind
TestKind
krate
Option<&str>