Skip to content

Commit 375a46f

Browse files
committed
Merge remote-tracking branch 'origin/master' into custom-profile-pr-rfc
2 parents ced10bd + cdf7f63 commit 375a46f

File tree

159 files changed

+3075
-689
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+3075
-689
lines changed

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ license = "MIT OR Apache-2.0"
99
homepage = "https://crates.io"
1010
repository = "https://github.com/rust-lang/cargo"
1111
documentation = "https://docs.rs/cargo"
12+
readme = "README.md"
1213
description = """
1314
Cargo, a package manager for Rust.
1415
"""
@@ -36,6 +37,7 @@ git2-curl = "0.11.0"
3637
glob = "0.3.0"
3738
hex = "0.3"
3839
home = "0.5"
40+
humantime = "1.2.0"
3941
ignore = "0.4.7"
4042
lazy_static = "1.2.0"
4143
jobserver = "0.1.13"
@@ -60,7 +62,7 @@ tar = { version = "0.4.18", default-features = false }
6062
tempfile = "3.0"
6163
termcolor = "1.0"
6264
toml = "0.5.3"
63-
url = { version = "2.0", features = ['serde'] }
65+
url = "2.0"
6466
walkdir = "2.2"
6567
clap = "2.31.2"
6668
unicode-width = "0.1.5"
@@ -102,6 +104,7 @@ features = [
102104

103105
[dev-dependencies]
104106
cargo-test-macro = { path = "crates/cargo-test-macro", version = "0.1.0" }
107+
cargo-test-support = { path = "crates/cargo-test-support", version = "0.1.0" }
105108

106109
[[bin]]
107110
name = "cargo"

azure-pipelines.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
x86_64-msvc:
4444
TOOLCHAIN: stable-x86_64-pc-windows-msvc
4545
OTHER_TARGET: i686-pc-windows-msvc
46+
4647
- job: rustfmt
4748
pool:
4849
vmImage: ubuntu-16.04
@@ -54,6 +55,8 @@ jobs:
5455
displayName: "Check rustfmt (cargo)"
5556
- bash: cd crates/cargo-test-macro && cargo fmt --all -- --check
5657
displayName: "Check rustfmt (cargo-test-macro)"
58+
- bash: cd crates/cargo-test-support && cargo fmt --all -- --check
59+
displayName: "Check rustfmt (cargo-test-support)"
5760
- bash: cd crates/crates-io && cargo fmt --all -- --check
5861
displayName: "Check rustfmt (crates-io)"
5962
- bash: cd crates/resolver-tests && cargo fmt --all -- --check
@@ -71,6 +74,20 @@ jobs:
7174
variables:
7275
TOOLCHAIN: stable
7376

77+
- job: build_std
78+
pool:
79+
vmImage: ubuntu-16.04
80+
steps:
81+
- template: ci/azure-install-rust.yml
82+
- bash: rustup component add rust-src
83+
displayName: "Install rust-src"
84+
- bash: cargo build
85+
- bash: cargo test --test build-std
86+
displayName: "tests"
87+
variables:
88+
TOOLCHAIN: nightly
89+
CARGO_RUN_BUILD_STD_TESTS: 1
90+
7491
- job: docs
7592
pool:
7693
vmImage: ubuntu-16.04
@@ -88,4 +105,3 @@ jobs:
88105
displayName: "Build mdbook documentation"
89106
variables:
90107
TOOLCHAIN: stable
91-

ci/azure-test-all.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ steps:
1616
- bash: rustup component add clippy || echo "clippy not available"
1717
displayName: "Install clippy (maybe)"
1818

19-
# This is needed for standard library tests.
20-
- bash: rustup component add rust-src
21-
condition: and(succeeded(), eq(variables['TOOLCHAIN'], 'nightly'))
22-
displayName: "Install rust-src (maybe)"
23-
2419
# Deny warnings on CI to avoid warnings getting into the codebase, and note the
2520
# `force-system-lib-on-osx` which is intended to fix compile issues on OSX where
2621
# compiling curl from source on OSX yields linker errors on Azure.
@@ -31,3 +26,6 @@ steps:
3126
# fix the link errors.
3227
- bash: cargo test --features 'deny-warnings curl/force-system-lib-on-osx'
3328
displayName: "cargo test"
29+
30+
- bash: cargo test -p cargo-test-support
31+
displayName: "cargo test -p cargo-test-support"

crates/cargo-test-macro/src/lib.rs

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extern crate proc_macro;
33
use proc_macro::*;
44

55
#[proc_macro_attribute]
6-
pub fn cargo_test(_attr: TokenStream, item: TokenStream) -> TokenStream {
6+
pub fn cargo_test(attr: TokenStream, item: TokenStream) -> TokenStream {
77
let span = Span::call_site();
88
let mut ret = TokenStream::new();
99
ret.extend(Some(TokenTree::from(Punct::new('#', Spacing::Alone))));
@@ -13,6 +13,8 @@ pub fn cargo_test(_attr: TokenStream, item: TokenStream) -> TokenStream {
1313
test.into(),
1414
))));
1515

16+
let build_std = contains_ident(&attr, "build_std");
17+
1618
for token in item {
1719
let group = match token {
1820
TokenTree::Group(g) => {
@@ -29,25 +31,20 @@ pub fn cargo_test(_attr: TokenStream, item: TokenStream) -> TokenStream {
2931
}
3032
};
3133

32-
let mut new_body = vec![
33-
TokenTree::from(Ident::new("let", span)),
34-
TokenTree::from(Ident::new("_test_guard", span)),
35-
TokenTree::from(Punct::new('=', Spacing::Alone)),
36-
TokenTree::from(Ident::new("crate", span)),
37-
TokenTree::from(Punct::new(':', Spacing::Joint)),
38-
TokenTree::from(Punct::new(':', Spacing::Alone)),
39-
TokenTree::from(Ident::new("support", span)),
40-
TokenTree::from(Punct::new(':', Spacing::Joint)),
41-
TokenTree::from(Punct::new(':', Spacing::Alone)),
42-
TokenTree::from(Ident::new("paths", span)),
43-
TokenTree::from(Punct::new(':', Spacing::Joint)),
44-
TokenTree::from(Punct::new(':', Spacing::Alone)),
45-
TokenTree::from(Ident::new("init_root", span)),
46-
TokenTree::from(Group::new(Delimiter::Parenthesis, TokenStream::new())),
47-
TokenTree::from(Punct::new(';', Spacing::Alone)),
48-
]
49-
.into_iter()
50-
.collect::<TokenStream>();
34+
let mut new_body =
35+
to_token_stream("let _test_guard = cargo_test_support::paths::init_root();");
36+
37+
// If this is a `build_std` test (aka `tests/build-std/*.rs`) then they
38+
// only run on nightly and they only run when specifically instructed to
39+
// on CI.
40+
if build_std {
41+
let ts = to_token_stream("if !cargo_test_support::is_nightly() { return }");
42+
new_body.extend(ts);
43+
let ts = to_token_stream(
44+
"if std::env::var(\"CARGO_RUN_BUILD_STD_TESTS\").is_err() { return }",
45+
);
46+
new_body.extend(ts);
47+
}
5148
new_body.extend(group.stream());
5249
ret.extend(Some(TokenTree::from(Group::new(
5350
group.delimiter(),
@@ -57,3 +54,14 @@ pub fn cargo_test(_attr: TokenStream, item: TokenStream) -> TokenStream {
5754

5855
return ret;
5956
}
57+
58+
fn contains_ident(t: &TokenStream, ident: &str) -> bool {
59+
t.clone().into_iter().any(|t| match t {
60+
TokenTree::Ident(i) => i.to_string() == ident,
61+
_ => false,
62+
})
63+
}
64+
65+
fn to_token_stream(code: &str) -> TokenStream {
66+
code.parse().unwrap()
67+
}

crates/cargo-test-support/Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "cargo-test-support"
3+
version = "0.1.0"
4+
authors = ["Alex Crichton <[email protected]>"]
5+
edition = "2018"
6+
7+
[lib]
8+
doctest = false
9+
10+
[dependencies]
11+
cargo = { path = "../.." }
12+
cargo-test-macro = { path = "../cargo-test-macro" }
13+
filetime = "0.2"
14+
flate2 = "1.0"
15+
git2 = "0.10"
16+
glob = "0.3"
17+
lazy_static = "1.0"
18+
remove_dir_all = "0.5"
19+
serde_json = "1.0"
20+
tar = "0.4"
21+
url = "2.0"

tests/testsuite/support/cross_compile.rs renamed to crates/cargo-test-support/src/cross_compile.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
use crate::{basic_bin_manifest, main_file, project};
12
use std::env;
23
use std::process::Command;
34
use std::sync::atomic::{AtomicBool, Ordering};
45
use std::sync::Once;
56

6-
use crate::support::{basic_bin_manifest, main_file, project};
7-
87
pub fn disabled() -> bool {
98
// First, disable if `./configure` requested so.
109
match env::var("CFG_DISABLE_CROSS_TESTS") {

tests/testsuite/support/git.rs renamed to crates/cargo-test-support/src/git.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,13 @@ use some of the helper functions in this file to interact with the repository.
3838
3939
*/
4040

41+
use crate::{path2url, project, Project, ProjectBuilder};
42+
use git2;
4143
use std::fs::{self, File};
4244
use std::io::prelude::*;
4345
use std::path::{Path, PathBuf};
44-
45-
use git2;
4646
use url::Url;
4747

48-
use crate::support::{path2url, project, Project, ProjectBuilder};
49-
5048
#[must_use]
5149
pub struct RepoBuilder {
5250
repo: git2::Repository,

tests/testsuite/support/install.rs renamed to crates/cargo-test-support/src/install.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
use crate::paths;
12
use std::env::consts::EXE_SUFFIX;
23
use std::path::{Path, PathBuf};
34

4-
use crate::support::paths;
5-
65
/// Used by `cargo install` tests to assert an executable binary
76
/// has been installed. Example usage:
87
///

tests/testsuite/support/mod.rs renamed to crates/cargo-test-support/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ use url::Url;
125125

126126
use self::paths::CargoPathExt;
127127

128+
#[macro_export]
128129
macro_rules! t {
129130
($e:expr) => {
130131
match $e {
@@ -134,6 +135,8 @@ macro_rules! t {
134135
};
135136
}
136137

138+
pub use cargo_test_macro::cargo_test;
139+
137140
pub mod cross_compile;
138141
pub mod git;
139142
pub mod paths;
@@ -409,7 +412,7 @@ impl Project {
409412
/// .with_stdout("bar\n")
410413
/// .run();
411414
pub fn process<T: AsRef<OsStr>>(&self, program: T) -> Execs {
412-
let mut p = crate::support::process(program);
415+
let mut p = process(program);
413416
p.cwd(self.root());
414417
execs().with_process_builder(p)
415418
}
@@ -1425,7 +1428,7 @@ pub fn lines_match(expected: &str, mut actual: &str) -> bool {
14251428
actual.is_empty() || expected.ends_with("[..]")
14261429
}
14271430

1428-
#[cargo_test]
1431+
#[test]
14291432
fn lines_match_works() {
14301433
assert!(lines_match("a b", "a b"));
14311434
assert!(lines_match("a[..]b", "a b"));

tests/testsuite/support/paths.rs renamed to crates/cargo-test-support/src/paths.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use filetime::{self, FileTime};
2+
use lazy_static::lazy_static;
13
use std::cell::RefCell;
24
use std::collections::HashMap;
35
use std::env;
@@ -7,9 +9,6 @@ use std::path::{Path, PathBuf};
79
use std::sync::atomic::{AtomicUsize, Ordering};
810
use std::sync::Mutex;
911

10-
use filetime::{self, FileTime};
11-
use lazy_static::lazy_static;
12-
1312
static CARGO_INTEGRATION_TEST_DIR: &str = "cit";
1413

1514
lazy_static! {

0 commit comments

Comments
 (0)