2019-11-25 02:42:45 +00:00
|
|
|
//! Tests for proc-macros.
|
|
|
|
|
2019-09-12 17:14:29 +00:00
|
|
|
use cargo_test_support::project;
|
2016-09-01 17:29:24 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-08-21 11:46:31 +00:00
|
|
|
fn probe_cfg_before_crate_type_discovery() {
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2017-08-21 11:46:31 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[target.'cfg(not(stage300))'.dependencies.noop]
|
|
|
|
path = "../noop"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate noop;
|
2017-08-21 11:46:31 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
#[derive(Noop)]
|
|
|
|
struct X;
|
2017-08-21 11:46:31 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
fn main() {}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
let _noop = project()
|
|
|
|
.at("noop")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "noop"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2017-08-21 11:46:31 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[lib]
|
|
|
|
proc-macro = true
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
extern crate proc_macro;
|
|
|
|
use proc_macro::TokenStream;
|
2017-08-21 11:46:31 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
#[proc_macro_derive(Noop)]
|
|
|
|
pub fn noop(_input: TokenStream) -> TokenStream {
|
|
|
|
"".parse().unwrap()
|
|
|
|
}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2017-08-21 11:46:31 +00:00
|
|
|
|
2023-02-16 02:27:53 +00:00
|
|
|
p.cargo("check").run();
|
2017-08-21 11:46:31 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-09-01 17:29:24 +00:00
|
|
|
fn noop() {
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-09-01 17:29:24 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies.noop]
|
|
|
|
path = "../noop"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate noop;
|
2016-09-01 17:29:24 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
#[derive(Noop)]
|
|
|
|
struct X;
|
2016-09-01 17:29:24 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
fn main() {}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
let _noop = project()
|
|
|
|
.at("noop")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "noop"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-09-01 17:29:24 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[lib]
|
|
|
|
proc-macro = true
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
extern crate proc_macro;
|
|
|
|
use proc_macro::TokenStream;
|
2016-09-01 17:29:24 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
#[proc_macro_derive(Noop)]
|
|
|
|
pub fn noop(_input: TokenStream) -> TokenStream {
|
|
|
|
"".parse().unwrap()
|
|
|
|
}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-09-01 17:29:24 +00:00
|
|
|
|
2023-02-16 02:27:53 +00:00
|
|
|
p.cargo("check").run();
|
|
|
|
p.cargo("check").run();
|
2016-09-01 17:29:24 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-09-01 17:29:24 +00:00
|
|
|
fn impl_and_derive() {
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-09-01 17:29:24 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies.transmogrify]
|
|
|
|
path = "../transmogrify"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate transmogrify;
|
2016-09-01 17:29:24 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
trait ImplByTransmogrify {
|
|
|
|
fn impl_by_transmogrify(&self) -> bool;
|
|
|
|
}
|
2016-09-01 17:29:24 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
#[derive(Transmogrify, Debug)]
|
|
|
|
struct X { success: bool }
|
2016-09-01 17:29:24 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
fn main() {
|
|
|
|
let x = X::new();
|
|
|
|
assert!(x.impl_by_transmogrify());
|
|
|
|
println!("{:?}", x);
|
|
|
|
}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
let _transmogrify = project()
|
|
|
|
.at("transmogrify")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "transmogrify"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-09-01 17:29:24 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[lib]
|
|
|
|
proc-macro = true
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
extern crate proc_macro;
|
|
|
|
use proc_macro::TokenStream;
|
|
|
|
|
|
|
|
#[proc_macro_derive(Transmogrify)]
|
|
|
|
#[doc(hidden)]
|
|
|
|
pub fn transmogrify(input: TokenStream) -> TokenStream {
|
|
|
|
"
|
|
|
|
impl X {
|
|
|
|
fn new() -> Self {
|
|
|
|
X { success: true }
|
|
|
|
}
|
2016-09-01 17:29:24 +00:00
|
|
|
}
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
impl ImplByTransmogrify for X {
|
|
|
|
fn impl_by_transmogrify(&self) -> bool {
|
|
|
|
true
|
|
|
|
}
|
2016-09-01 17:29:24 +00:00
|
|
|
}
|
2020-09-27 00:59:58 +00:00
|
|
|
".parse().unwrap()
|
|
|
|
}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
|
|
|
|
p.cargo("build").run();
|
|
|
|
p.cargo("run").with_stdout("X { success: true }").run();
|
2016-09-01 17:29:24 +00:00
|
|
|
}
|
2016-09-01 17:42:23 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-01-17 23:48:35 +00:00
|
|
|
fn proc_macro_doctest() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let foo = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
[lib]
|
|
|
|
proc-macro = true
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
#![crate_type = "proc-macro"]
|
2017-01-17 23:48:35 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
extern crate proc_macro;
|
2017-01-17 23:48:35 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
use proc_macro::TokenStream;
|
2017-01-17 23:48:35 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
/// ```
|
|
|
|
/// assert!(true);
|
|
|
|
/// ```
|
|
|
|
#[proc_macro_derive(Bar)]
|
|
|
|
pub fn derive(_input: TokenStream) -> TokenStream {
|
|
|
|
"".parse().unwrap()
|
|
|
|
}
|
2017-01-17 23:48:35 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
#[test]
|
|
|
|
fn a() {
|
|
|
|
assert!(true);
|
|
|
|
}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
|
|
|
|
foo.cargo("test")
|
|
|
|
.with_stdout_contains("test a ... ok")
|
|
|
|
.with_stdout_contains_n("test [..] ... ok", 2)
|
|
|
|
.run();
|
2017-01-17 23:48:35 +00:00
|
|
|
}
|
2018-11-03 19:36:41 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-11-03 19:36:41 +00:00
|
|
|
fn proc_macro_crate_type() {
|
|
|
|
// Verify that `crate-type = ["proc-macro"]` is the same as `proc-macro = true`
|
|
|
|
// and that everything, including rustdoc, works correctly.
|
|
|
|
let foo = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
[dependencies]
|
|
|
|
pm = { path = "pm" }
|
|
|
|
"#,
|
2018-11-03 19:36:41 +00:00
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
//! ```
|
|
|
|
//! use foo::THING;
|
|
|
|
//! assert_eq!(THING, 123);
|
|
|
|
//! ```
|
|
|
|
#[macro_use]
|
|
|
|
extern crate pm;
|
|
|
|
#[derive(MkItem)]
|
|
|
|
pub struct S;
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::THING;
|
|
|
|
#[test]
|
|
|
|
fn it_works() {
|
|
|
|
assert_eq!(THING, 123);
|
|
|
|
}
|
2018-11-03 19:36:41 +00:00
|
|
|
}
|
2020-09-27 00:59:58 +00:00
|
|
|
"#,
|
2018-11-03 19:36:41 +00:00
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"pm/Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "pm"
|
|
|
|
version = "0.1.0"
|
|
|
|
[lib]
|
|
|
|
crate-type = ["proc-macro"]
|
|
|
|
"#,
|
2018-11-03 19:36:41 +00:00
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"pm/src/lib.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
extern crate proc_macro;
|
|
|
|
use proc_macro::TokenStream;
|
2018-11-03 19:36:41 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
#[proc_macro_derive(MkItem)]
|
|
|
|
pub fn mk_item(_input: TokenStream) -> TokenStream {
|
|
|
|
"pub const THING: i32 = 123;".parse().unwrap()
|
|
|
|
}
|
|
|
|
"#,
|
2018-11-03 19:36:41 +00:00
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
foo.cargo("test")
|
|
|
|
.with_stdout_contains("test tests::it_works ... ok")
|
|
|
|
.with_stdout_contains_n("test [..] ... ok", 2)
|
|
|
|
.run();
|
|
|
|
}
|
2018-11-06 18:32:56 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-11-06 18:32:56 +00:00
|
|
|
fn proc_macro_crate_type_warning() {
|
|
|
|
let foo = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
[lib]
|
|
|
|
crate-type = ["proc-macro"]
|
|
|
|
"#,
|
2018-11-06 18:32:56 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2023-02-16 02:27:53 +00:00
|
|
|
foo.cargo("check")
|
2018-11-06 18:32:56 +00:00
|
|
|
.with_stderr_contains(
|
|
|
|
"[WARNING] library `foo` should only specify `proc-macro = true` instead of setting `crate-type`")
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2022-01-22 04:55:19 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn proc_macro_conflicting_warning() {
|
|
|
|
let foo = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
[lib]
|
|
|
|
proc-macro = false
|
|
|
|
proc_macro = true
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2023-02-16 02:27:53 +00:00
|
|
|
foo.cargo("check")
|
2022-01-22 04:55:19 +00:00
|
|
|
.with_stderr_contains(
|
2022-03-09 15:54:17 +00:00
|
|
|
"[WARNING] conflicting between `proc-macro` and `proc_macro` in the `foo` library target.\n
|
|
|
|
`proc_macro` is ignored and not recommended for use in the future",
|
2022-01-22 04:55:19 +00:00
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-11-06 18:32:56 +00:00
|
|
|
fn proc_macro_crate_type_warning_plugin() {
|
|
|
|
let foo = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
[lib]
|
|
|
|
crate-type = ["proc-macro"]
|
|
|
|
plugin = true
|
|
|
|
"#,
|
2018-11-06 18:32:56 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2023-02-16 02:27:53 +00:00
|
|
|
foo.cargo("check")
|
2024-01-04 11:52:57 +00:00
|
|
|
.with_stderr_contains(
|
|
|
|
"[WARNING] support for rustc plugins has been removed from rustc. \
|
|
|
|
library `foo` should not specify `plugin = true`")
|
|
|
|
.with_stderr_contains(
|
|
|
|
"[WARNING] support for `plugin = true` will be removed from cargo in the future")
|
2018-11-06 18:32:56 +00:00
|
|
|
.with_stderr_contains(
|
|
|
|
"[WARNING] proc-macro library `foo` should not specify `plugin = true`")
|
|
|
|
.with_stderr_contains(
|
|
|
|
"[WARNING] library `foo` should only specify `proc-macro = true` instead of setting `crate-type`")
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-11-06 18:32:56 +00:00
|
|
|
fn proc_macro_crate_type_multiple() {
|
|
|
|
let foo = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
[lib]
|
|
|
|
crate-type = ["proc-macro", "rlib"]
|
|
|
|
"#,
|
2018-11-06 18:32:56 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2023-02-16 02:27:53 +00:00
|
|
|
foo.cargo("check")
|
2018-11-06 18:32:56 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[ERROR] failed to parse manifest at `[..]/foo/Cargo.toml`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
cannot mix `proc-macro` crate type with others
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.with_status(101)
|
|
|
|
.run();
|
|
|
|
}
|
2019-12-12 19:56:33 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn proc_macro_extern_prelude() {
|
|
|
|
// Check that proc_macro is in the extern prelude.
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
edition = "2018"
|
|
|
|
[lib]
|
|
|
|
proc-macro = true
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
|
|
|
use proc_macro::TokenStream;
|
|
|
|
#[proc_macro]
|
|
|
|
pub fn foo(input: TokenStream) -> TokenStream {
|
|
|
|
"".parse().unwrap()
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
p.cargo("test").run();
|
|
|
|
p.cargo("doc").run();
|
|
|
|
}
|
2020-06-03 14:38:21 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn proc_macro_built_once() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[workspace]
|
|
|
|
members = ['a', 'b']
|
2020-12-17 23:21:23 +00:00
|
|
|
resolver = "2"
|
2020-06-03 14:38:21 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"a/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "a"
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
[build-dependencies]
|
|
|
|
the-macro = { path = '../the-macro' }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("a/build.rs", "fn main() {}")
|
|
|
|
.file("a/src/main.rs", "fn main() {}")
|
|
|
|
.file(
|
|
|
|
"b/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "b"
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
the-macro = { path = '../the-macro', features = ['a'] }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("b/src/main.rs", "fn main() {}")
|
|
|
|
.file(
|
|
|
|
"the-macro/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "the-macro"
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
[lib]
|
|
|
|
proc_macro = true
|
|
|
|
|
|
|
|
[features]
|
|
|
|
a = []
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("the-macro/src/lib.rs", "")
|
|
|
|
.build();
|
2020-12-17 23:21:23 +00:00
|
|
|
p.cargo("build --verbose")
|
2020-06-03 14:38:21 +00:00
|
|
|
.with_stderr_unordered(
|
|
|
|
"\
|
|
|
|
[COMPILING] the-macro [..]
|
|
|
|
[RUNNING] `rustc --crate-name the_macro [..]`
|
|
|
|
[COMPILING] b [..]
|
|
|
|
[RUNNING] `rustc --crate-name b [..]`
|
|
|
|
[COMPILING] a [..]
|
|
|
|
[RUNNING] `rustc --crate-name build_script_build [..]`
|
|
|
|
[RUNNING] `[..]build[..]script[..]build[..]`
|
|
|
|
[RUNNING] `rustc --crate-name a [..]`
|
|
|
|
[FINISHED] [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|