mirror of
https://github.com/rust-lang/cargo
synced 2024-09-20 08:11:50 +00:00
Differentiates documentation and compilation in user output
Fix tests to work with new jobqueue
This commit is contained in:
parent
ec85eefd32
commit
925fb50850
|
@ -25,7 +25,8 @@ pub struct JobQueue<'a> {
|
|||
rx: Receiver<Message<'a>>,
|
||||
active: usize,
|
||||
pending: HashMap<Key<'a>, PendingBuild>,
|
||||
printed: HashSet<&'a PackageId>,
|
||||
compiled: HashSet<&'a PackageId>,
|
||||
documented: HashSet<&'a PackageId>,
|
||||
counts: HashMap<&'a PackageId, usize>,
|
||||
}
|
||||
|
||||
|
@ -61,7 +62,8 @@ impl<'a> JobQueue<'a> {
|
|||
rx: rx,
|
||||
active: 0,
|
||||
pending: HashMap::new(),
|
||||
printed: HashSet::new(),
|
||||
compiled: HashSet::new(),
|
||||
documented: HashSet::new(),
|
||||
counts: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +183,7 @@ impl<'a> JobQueue<'a> {
|
|||
});
|
||||
|
||||
// Print out some nice progress information
|
||||
try!(self.note_working_on(config, key.pkg, fresh));
|
||||
try!(self.note_working_on(config, &key, fresh));
|
||||
|
||||
// only the first message of each job is processed
|
||||
if let Ok(msg) = desc_rx.recv() {
|
||||
|
@ -199,9 +201,10 @@ impl<'a> JobQueue<'a> {
|
|||
// In general, we try to print "Compiling" for the first nontrivial task
|
||||
// run for a package, regardless of when that is. We then don't print
|
||||
// out any more information for a package after we've printed it once.
|
||||
fn note_working_on(&mut self, config: &Config, pkg: &'a PackageId,
|
||||
fn note_working_on(&mut self, config: &Config, key: &Key<'a>,
|
||||
fresh: Freshness) -> CargoResult<()> {
|
||||
if self.printed.contains(&pkg) {
|
||||
if (self.compiled.contains(key.pkg) && !key.profile.doc) ||
|
||||
(self.documented.contains(key.pkg) && key.profile.doc) {
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
|
@ -209,12 +212,17 @@ impl<'a> JobQueue<'a> {
|
|||
// Any dirty stage which runs at least one command gets printed as
|
||||
// being a compiled package
|
||||
Dirty => {
|
||||
self.printed.insert(pkg);
|
||||
try!(config.shell().status("Compiling", pkg));
|
||||
if key.profile.doc {
|
||||
self.documented.insert(key.pkg);
|
||||
try!(config.shell().status("Documenting", key.pkg));
|
||||
} else {
|
||||
self.compiled.insert(key.pkg);
|
||||
try!(config.shell().status("Compiling", key.pkg));
|
||||
}
|
||||
}
|
||||
Fresh if self.counts[pkg] == 0 => {
|
||||
self.printed.insert(pkg);
|
||||
try!(config.shell().verbose(|c| c.status("Fresh", pkg)));
|
||||
Fresh if self.counts[key.pkg] == 0 => {
|
||||
self.compiled.insert(key.pkg);
|
||||
try!(config.shell().verbose(|c| c.status("Fresh", key.pkg)));
|
||||
}
|
||||
Fresh => {}
|
||||
}
|
||||
|
|
|
@ -552,6 +552,7 @@ pub fn path2url(p: PathBuf) -> Url {
|
|||
|
||||
pub static RUNNING: &'static str = " Running";
|
||||
pub static COMPILING: &'static str = " Compiling";
|
||||
pub static DOCUMENTING: &'static str = " Documenting";
|
||||
pub static FRESH: &'static str = " Fresh";
|
||||
pub static UPDATING: &'static str = " Updating";
|
||||
pub static ADDING: &'static str = " Adding";
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::fs::File;
|
|||
use std::io::prelude::*;
|
||||
|
||||
use support::{project, execs};
|
||||
use support::{COMPILING, RUNNING, DOCTEST, FRESH};
|
||||
use support::{COMPILING, RUNNING, DOCTEST, FRESH, DOCUMENTING};
|
||||
use support::paths::CargoPathExt;
|
||||
use hamcrest::{assert_that};
|
||||
|
||||
|
@ -506,9 +506,9 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
|
|||
assert_that(p.cargo("doc").arg("-v"),
|
||||
execs().with_status(0)
|
||||
.with_stdout(&format!("\
|
||||
{compiling} foo v0.5.0 (file://[..])
|
||||
{documenting} foo v0.5.0 (file://[..])
|
||||
{running} `rustdoc [..]`
|
||||
", compiling = COMPILING, running = RUNNING)));
|
||||
", documenting = DOCUMENTING, running = RUNNING)));
|
||||
|
||||
File::create(&p.root().join("src/main.rs")).unwrap()
|
||||
.write_all(b"fn main() {}").unwrap();
|
||||
|
|
|
@ -565,25 +565,29 @@ test!(build_script_needed_for_host_and_target {
|
|||
|
||||
assert_that(p.cargo_process("build").arg("--target").arg(&target).arg("-v"),
|
||||
execs().with_status(0)
|
||||
.with_stdout(&format!("\
|
||||
{compiling} d1 v0.0.0 ({url})
|
||||
{running} `rustc d1[..]build.rs [..] --out-dir {dir}[..]target[..]build[..]d1-[..]`
|
||||
{running} `{dir}[..]target[..]build[..]d1-[..]build-script-build`
|
||||
{running} `{dir}[..]target[..]build[..]d1-[..]build-script-build`
|
||||
{running} `rustc d1[..]src[..]lib.rs [..]`
|
||||
{running} `rustc d1[..]src[..]lib.rs [..]`
|
||||
{compiling} d2 v0.0.0 ({url})
|
||||
.with_stdout_contains(&format!("\
|
||||
{compiling} d1 v0.0.0 ({url})", compiling = COMPILING, url = p.url()))
|
||||
.with_stdout_contains(&format!("\
|
||||
{running} `rustc d1[..]build.rs [..] --out-dir {dir}[..]target[..]build[..]d1-[..]`",
|
||||
running = RUNNING, dir = p.root().display()))
|
||||
.with_stdout_contains(&format!("\
|
||||
{running} `{dir}[..]target[..]build[..]d1-[..]build-script-build`", running = RUNNING,
|
||||
dir = p.root().display()))
|
||||
.with_stdout_contains(&format!("\
|
||||
{running} `rustc d1[..]src[..]lib.rs [..]`", running = RUNNING))
|
||||
.with_stdout_contains(&format!("\
|
||||
{compiling} d2 v0.0.0 ({url})", compiling = COMPILING, url = p.url()))
|
||||
.with_stdout_contains(&format!("\
|
||||
{running} `rustc d2[..]src[..]lib.rs [..] \
|
||||
-L /path/to/{host}`
|
||||
{compiling} foo v0.0.0 ({url})
|
||||
-L /path/to/{host}`", running = RUNNING, host = host))
|
||||
.with_stdout_contains(&format!("\
|
||||
{compiling} foo v0.0.0 ({url})", compiling = COMPILING, url = p.url()))
|
||||
.with_stdout_contains(&format!("\
|
||||
{running} `rustc build.rs [..] --out-dir {dir}[..]target[..]build[..]foo-[..] \
|
||||
-L /path/to/{host}`
|
||||
{running} `{dir}[..]target[..]build[..]foo-[..]build-script-build`
|
||||
-L /path/to/{host}`", running = RUNNING, dir = p.root().display(), host = host))
|
||||
.with_stdout_contains(&format!("\
|
||||
{running} `rustc src[..]main.rs [..] --target {target} [..] \
|
||||
-L /path/to/{target}`
|
||||
", compiling = COMPILING, running = RUNNING, target = target, host = host,
|
||||
url = p.url(),
|
||||
dir = p.root().display())));
|
||||
-L /path/to/{target}`", running = RUNNING, target = target)));
|
||||
});
|
||||
|
||||
test!(build_deps_for_the_right_arch {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::str;
|
||||
|
||||
use support::{project, execs, path2url};
|
||||
use support::{COMPILING, RUNNING};
|
||||
use support::{COMPILING, DOCUMENTING, RUNNING};
|
||||
use hamcrest::{assert_that, existing_file, existing_dir, is_not};
|
||||
|
||||
fn setup() {
|
||||
|
@ -23,9 +23,9 @@ test!(simple {
|
|||
|
||||
assert_that(p.cargo_process("doc"),
|
||||
execs().with_status(0).with_stdout(&format!("\
|
||||
{compiling} foo v0.0.1 ({dir})
|
||||
[..] foo v0.0.1 ({dir})
|
||||
[..] foo v0.0.1 ({dir})
|
||||
",
|
||||
compiling = COMPILING,
|
||||
dir = path2url(p.root()))));
|
||||
assert_that(&p.root().join("target/doc"), existing_dir());
|
||||
assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
|
||||
|
@ -65,9 +65,9 @@ test!(doc_twice {
|
|||
|
||||
assert_that(p.cargo_process("doc"),
|
||||
execs().with_status(0).with_stdout(&format!("\
|
||||
{compiling} foo v0.0.1 ({dir})
|
||||
{documenting} foo v0.0.1 ({dir})
|
||||
",
|
||||
compiling = COMPILING,
|
||||
documenting = DOCUMENTING,
|
||||
dir = path2url(p.root()))));
|
||||
|
||||
assert_that(p.cargo("doc"),
|
||||
|
@ -101,10 +101,11 @@ test!(doc_deps {
|
|||
|
||||
assert_that(p.cargo_process("doc"),
|
||||
execs().with_status(0).with_stdout(&format!("\
|
||||
{compiling} bar v0.0.1 ({dir})
|
||||
{compiling} foo v0.0.1 ({dir})
|
||||
[..] bar v0.0.1 ({dir})
|
||||
[..] bar v0.0.1 ({dir})
|
||||
{documenting} foo v0.0.1 ({dir})
|
||||
",
|
||||
compiling = COMPILING,
|
||||
documenting = DOCUMENTING,
|
||||
dir = path2url(p.root()))));
|
||||
|
||||
assert_that(&p.root().join("target/doc"), existing_dir());
|
||||
|
@ -148,9 +149,9 @@ test!(doc_no_deps {
|
|||
assert_that(p.cargo_process("doc").arg("--no-deps"),
|
||||
execs().with_status(0).with_stdout(&format!("\
|
||||
{compiling} bar v0.0.1 ({dir})
|
||||
{compiling} foo v0.0.1 ({dir})
|
||||
{documenting} foo v0.0.1 ({dir})
|
||||
",
|
||||
compiling = COMPILING,
|
||||
documenting = DOCUMENTING, compiling = COMPILING,
|
||||
dir = path2url(p.root()))));
|
||||
|
||||
assert_that(&p.root().join("target/doc"), existing_dir());
|
||||
|
@ -243,9 +244,10 @@ test!(doc_dash_p {
|
|||
assert_that(p.cargo_process("doc").arg("-p").arg("a"),
|
||||
execs().with_status(0)
|
||||
.with_stdout(&format!("\
|
||||
{compiling} b v0.0.1 (file://[..])
|
||||
{compiling} a v0.0.1 (file://[..])
|
||||
", compiling = COMPILING)));
|
||||
[..] b v0.0.1 (file://[..])
|
||||
[..] b v0.0.1 (file://[..])
|
||||
{documenting} a v0.0.1 (file://[..])
|
||||
", documenting = DOCUMENTING)));
|
||||
});
|
||||
|
||||
test!(doc_same_name {
|
||||
|
@ -428,9 +430,9 @@ test!(doc_release {
|
|||
assert_that(p.cargo("doc").arg("--release").arg("-v"),
|
||||
execs().with_status(0)
|
||||
.with_stdout(&format!("\
|
||||
{compiling} foo v0.0.1 ([..])
|
||||
{documenting} foo v0.0.1 ([..])
|
||||
{running} `rustdoc src[..]lib.rs [..]`
|
||||
", compiling = COMPILING, running = RUNNING)));
|
||||
", documenting = DOCUMENTING, running = RUNNING)));
|
||||
});
|
||||
|
||||
test!(doc_multiple_deps {
|
||||
|
|
Loading…
Reference in a new issue