Skip to content

Commit

Permalink
Auto merge of #1992 - carols10cents:cleanup, r=alexcrichton
Browse files Browse the repository at this point in the history
Hiii! These are just a few small cleanup things that I took care of while working on #1991, but these should all be less controversial than that one is :)
  • Loading branch information
bors committed Sep 20, 2015
2 parents de11b58 + bacb6be commit 4080ea8
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 51 deletions.
4 changes: 2 additions & 2 deletions src/cargo/core/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use util::{CargoResult, graph};
use rustc_serialize::{Encoder,Encodable};
use core::source::Source;

/// Informations about a package that is available somewhere in the file system.
/// Information about a package that is available somewhere in the file system.
///
/// A package is a `Cargo.toml` file, plus all the files that are part of it.
/// A package is a `Cargo.toml` file plus all the files that are part of it.
// TODO: Is manifest_path a relic?
#[derive(Clone, Debug)]
pub struct Package {
Expand Down
10 changes: 5 additions & 5 deletions src/cargo/core/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::collections::hash_map::HashMap;
use core::{Source, SourceId, SourceMap, Summary, Dependency, PackageId, Package};
use util::{CargoResult, ChainError, Config, human, profile};

/// Source of informations about a group of packages.
/// Source of information about a group of packages.
///
/// See also `core::Source`.
pub trait Registry {
Expand Down Expand Up @@ -32,11 +32,11 @@ impl Registry for Vec<Package> {
///
/// The resolution phase of Cargo uses this to drive knowledge about new
/// packages as well as querying for lists of new packages. It is here that
/// sources are updated and (e.g. network operations) as well as overrides are
/// sources are updated (e.g. network operations) and overrides are
/// handled.
///
/// The general idea behind this registry is that it is centered around the
/// `SourceMap` structure contained within which is a mapping of a `SourceId` to
/// `SourceMap` structure, contained within which is a mapping of a `SourceId` to
/// a `Source`. Each `Source` in the map has been updated (using network
/// operations if necessary) and is ready to be queried for packages.
pub struct PackageRegistry<'cfg> {
Expand Down Expand Up @@ -213,7 +213,7 @@ impl<'cfg> PackageRegistry<'cfg> {
// possible. This is where the concept of a lockfile comes into play.
//
// If a summary points at a package id which was previously locked, then we
// override the summary's id itself as well as all dependencies to be
// override the summary's id itself, as well as all dependencies, to be
// rewritten to the locked versions. This will transform the summary's
// source to a precise source (listed in the locked version) as well as
// transforming all of the dependencies from range requirements on imprecise
Expand Down Expand Up @@ -242,7 +242,7 @@ impl<'cfg> PackageRegistry<'cfg> {
// one of a few cases can arise:
//
// 1. We have a lock entry for this dependency from the same
// source as its listed as coming from. In this case we make
// source as it's listed as coming from. In this case we make
// sure to lock to precisely the given package id.
//
// 2. We have a lock entry for this dependency, but it's from a
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn clean(manifest_path: &Path, opts: &CleanOptions) -> CargoResult<()> {
let root = try!(src.root_package());
let target_dir = opts.config.target_dir(&root);

// If we have a spec, then we need to delete some package,s otherwise, just
// If we have a spec, then we need to delete some packages, otherwise, just
// remove the whole target directory and be done with it!
let spec = match opts.spec {
Some(spec) => spec,
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use sources::{PathSource};
use util::config::{ConfigValue, Config};
use util::{CargoResult, internal, human, ChainError, profile};

/// Contains informations about how a package should be compiled.
/// Contains information about how a package should be compiled.
pub struct CompileOptions<'a> {
pub config: &'a Config,
/// Number of concurrent jobs to use.
Expand Down
6 changes: 3 additions & 3 deletions src/cargo/ops/cargo_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ fn run_verify(config: &Config, pkg: &Package, tar: &Path)
// implicitly converted to registry-based dependencies, so we rewrite those
// dependencies here.
//
// We also be sure to point all paths at `dst` instead of the previous
// location that the package was original read from. In locking the
// We also make sure to point all paths at `dst` instead of the previous
// location that the package was originally read from. In locking the
// `SourceId` we're telling it that the corresponding `PathSource` will be
// considered updated and won't actually read any packages.
// considered updated and we won't actually read any packages.
let registry = try!(SourceId::for_central(config));
let precise = Some("locked".to_string());
let new_src = try!(SourceId::for_path(&dst)).with_precise(precise);
Expand Down
7 changes: 0 additions & 7 deletions src/cargo/ops/cargo_test.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::ffi::{OsString, OsStr};
use std::path::Path;

use core::Source;
use sources::PathSource;
use ops::{self, ExecEngine, ProcessEngine, Compilation};
use util::{self, CargoResult, CargoTestError, ProcessError};

Expand Down Expand Up @@ -63,11 +61,6 @@ pub fn run_benches(manifest_path: &Path,
fn compile_tests<'a>(manifest_path: &Path,
options: &TestOptions<'a>)
-> CargoResult<Compilation<'a>> {
let config = options.compile_opts.config;
let mut source = try!(PathSource::for_path(&manifest_path.parent().unwrap(),
config));
try!(source.update());

let mut compilation = try!(ops::compile(manifest_path, &options.compile_opts));
compilation.tests.sort();
Ok(compilation)
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/ops/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use util::CargoResult;
/// Resolve all dependencies for the specified `package` using the previous
/// lockfile as a guide if present.
///
/// This function will also generate a write the result of resolution as a new
/// This function will also write the result of resolution as a new
/// lockfile.
pub fn resolve_pkg(registry: &mut PackageRegistry, package: &Package)
-> CargoResult<Resolve> {
Expand Down Expand Up @@ -73,7 +73,7 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry,
// 2. The specified package's summary will have its dependencies
// modified to their precise variants. This will instruct the
// first step of the resolution process to not query for ranges
// but rather precise dependency versions.
// but rather for precise dependency versions.
//
// This process must handle altered dependencies, however, as
// it's possible for a manifest to change over time to have
Expand Down
8 changes: 4 additions & 4 deletions src/cargo/sources/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<'cfg> PathSource<'cfg> {

/// List all files relevant to building this package inside this source.
///
/// This function will use the appropriate methods to determine what is the
/// This function will use the appropriate methods to determine the
/// set of files underneath this source's directory which are relevant for
/// building `pkg`.
///
Expand Down Expand Up @@ -115,7 +115,7 @@ impl<'cfg> PathSource<'cfg> {
// We check all packages in this source that are ancestors of the
// specified package (including the same package) to see if they're at
// the root of the git repository. This isn't always true, but it'll get
// us there most of the time!.
// us there most of the time!
let repo = self.packages.iter()
.map(|pkg| pkg.root())
.filter(|path| root.starts_with(path))
Expand All @@ -139,11 +139,11 @@ impl<'cfg> PathSource<'cfg> {

let mut ret = Vec::new();

// We use information from the git repository to guide use in traversing
// We use information from the git repository to guide us in traversing
// its tree. The primary purpose of this is to take advantage of the
// .gitignore and auto-ignore files that don't matter.
//
// Here we're also careful to look at both tracked an untracked files as
// Here we're also careful to look at both tracked and untracked files as
// the untracked files are often part of a build and may become relevant
// as part of a future commit.
let index_files = index.iter().map(|entry| {
Expand Down
25 changes: 24 additions & 1 deletion tests/test_cargo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,30 @@ consider running `cargo update` to update a path dependency's locked version
"));
});

// test!(compiling_project_with_invalid_manifest)
test!(ignores_carriage_return_in_lockfile {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
authors = []
version = "0.0.1"
"#)
.file("src/main.rs", r#"
mod a; fn main() {}
"#)
.file("src/a.rs", "");

assert_that(p.cargo_process("build"),
execs().with_status(0));

let lockfile = p.root().join("Cargo.lock");
let mut lock = String::new();
File::open(&lockfile).unwrap().read_to_string(&mut lock).unwrap();
let lock = lock.replace("\n", "\r\n");
File::create(&lockfile).unwrap().write_all(lock.as_bytes()).unwrap();
assert_that(p.cargo("build"),
execs().with_status(0));
});

test!(crate_version_env_vars {
let p = project("foo")
Expand Down
25 changes: 0 additions & 25 deletions tests/test_cargo_generate_lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,6 @@ use hamcrest::assert_that;

fn setup() {}

test!(ignores_carriage_return {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
authors = []
version = "0.0.1"
"#)
.file("src/main.rs", r#"
mod a; fn main() {}
"#)
.file("src/a.rs", "");

assert_that(p.cargo_process("build"),
execs().with_status(0));

let lockfile = p.root().join("Cargo.lock");
let mut lock = String::new();
File::open(&lockfile).unwrap().read_to_string(&mut lock).unwrap();
let lock = lock.replace("\n", "\r\n");
File::create(&lockfile).unwrap().write_all(lock.as_bytes()).unwrap();
assert_that(p.cargo("build"),
execs().with_status(0));
});

test!(adding_and_removing_packages {
let p = project("foo")
.file("Cargo.toml", r#"
Expand Down

0 comments on commit 4080ea8

Please sign in to comment.