mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
tests: Remove plugin tests
Compiler plugins were removed in rust-lang/rust#116412, so we don't need these tests. As for the `plugin` field on build-targets, it appears to be [stable-but-deprecated](https://doc.rust-lang.org/cargo/reference/cargo-targets.html#the-plugin-field), so I left it alone
This commit is contained in:
parent
65e297d1ec
commit
c12c4c3f8d
@ -411,92 +411,6 @@ fn linker() {
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cargo_test(nightly, reason = "plugins are unstable")]
|
|
||||||
fn plugin_with_extra_dylib_dep() {
|
|
||||||
if cross_compile::disabled() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let foo = project()
|
|
||||||
.file(
|
|
||||||
"Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "foo"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = []
|
|
||||||
|
|
||||||
[dependencies.bar]
|
|
||||||
path = "../bar"
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file(
|
|
||||||
"src/main.rs",
|
|
||||||
r#"
|
|
||||||
#![feature(plugin)]
|
|
||||||
#![plugin(bar)]
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.build();
|
|
||||||
let _bar = project()
|
|
||||||
.at("bar")
|
|
||||||
.file(
|
|
||||||
"Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "bar"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = []
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "bar"
|
|
||||||
plugin = true
|
|
||||||
|
|
||||||
[dependencies.baz]
|
|
||||||
path = "../baz"
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file(
|
|
||||||
"src/lib.rs",
|
|
||||||
r#"
|
|
||||||
#![feature(rustc_private)]
|
|
||||||
|
|
||||||
extern crate baz;
|
|
||||||
extern crate rustc_driver;
|
|
||||||
|
|
||||||
use rustc_driver::plugin::Registry;
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub fn __rustc_plugin_registrar(reg: &mut Registry) {
|
|
||||||
println!("{}", baz::baz());
|
|
||||||
}
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.build();
|
|
||||||
let _baz = project()
|
|
||||||
.at("baz")
|
|
||||||
.file(
|
|
||||||
"Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "baz"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = []
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "baz"
|
|
||||||
crate_type = ["dylib"]
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file("src/lib.rs", "pub fn baz() -> i32 { 1 }")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
let target = cross_compile::alternate();
|
|
||||||
foo.cargo("build --target").arg(&target).run();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn cross_tests() {
|
fn cross_tests() {
|
||||||
if !cross_compile::can_run_on_host() {
|
if !cross_compile::can_run_on_host() {
|
||||||
|
@ -132,7 +132,6 @@ mod patch;
|
|||||||
mod path;
|
mod path;
|
||||||
mod paths;
|
mod paths;
|
||||||
mod pkgid;
|
mod pkgid;
|
||||||
mod plugins;
|
|
||||||
mod proc_macro;
|
mod proc_macro;
|
||||||
mod profile_config;
|
mod profile_config;
|
||||||
mod profile_custom;
|
mod profile_custom;
|
||||||
|
@ -1,421 +0,0 @@
|
|||||||
//! Tests for rustc plugins.
|
|
||||||
|
|
||||||
use cargo_test_support::rustc_host;
|
|
||||||
use cargo_test_support::{basic_manifest, project};
|
|
||||||
|
|
||||||
#[cargo_test(nightly, reason = "plugins are unstable")]
|
|
||||||
fn plugin_to_the_max() {
|
|
||||||
let foo = project()
|
|
||||||
.file(
|
|
||||||
"Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "foo"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = []
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "foo_lib"
|
|
||||||
|
|
||||||
[dependencies.bar]
|
|
||||||
path = "../bar"
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file(
|
|
||||||
"src/main.rs",
|
|
||||||
r#"
|
|
||||||
#![feature(plugin)]
|
|
||||||
#![plugin(bar)]
|
|
||||||
extern crate foo_lib;
|
|
||||||
|
|
||||||
fn main() { foo_lib::foo(); }
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file(
|
|
||||||
"src/foo_lib.rs",
|
|
||||||
r#"
|
|
||||||
#![feature(plugin)]
|
|
||||||
#![plugin(bar)]
|
|
||||||
|
|
||||||
pub fn foo() {}
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.build();
|
|
||||||
let _bar = project()
|
|
||||||
.at("bar")
|
|
||||||
.file(
|
|
||||||
"Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "bar"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = []
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "bar"
|
|
||||||
plugin = true
|
|
||||||
|
|
||||||
[dependencies.baz]
|
|
||||||
path = "../baz"
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file(
|
|
||||||
"src/lib.rs",
|
|
||||||
r#"
|
|
||||||
#![feature(rustc_private)]
|
|
||||||
|
|
||||||
extern crate baz;
|
|
||||||
extern crate rustc_driver;
|
|
||||||
|
|
||||||
use rustc_driver::plugin::Registry;
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub fn __rustc_plugin_registrar(_reg: &mut Registry) {
|
|
||||||
println!("{}", baz::baz());
|
|
||||||
}
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.build();
|
|
||||||
let _baz = project()
|
|
||||||
.at("baz")
|
|
||||||
.file(
|
|
||||||
"Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "baz"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = []
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "baz"
|
|
||||||
crate_type = ["dylib"]
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file("src/lib.rs", "pub fn baz() -> i32 { 1 }")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
foo.cargo("build").run();
|
|
||||||
foo.cargo("doc").run();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cargo_test(nightly, reason = "plugins are unstable")]
|
|
||||||
fn plugin_with_dynamic_native_dependency() {
|
|
||||||
let build = project()
|
|
||||||
.at("builder")
|
|
||||||
.file(
|
|
||||||
"Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "builder"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = []
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "builder"
|
|
||||||
crate-type = ["dylib"]
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file("src/lib.rs", "#[no_mangle] pub extern fn foo() {}")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
let foo = project()
|
|
||||||
.file(
|
|
||||||
"Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "foo"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = []
|
|
||||||
|
|
||||||
[dependencies.bar]
|
|
||||||
path = "bar"
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file(
|
|
||||||
"src/main.rs",
|
|
||||||
r#"
|
|
||||||
#![feature(plugin)]
|
|
||||||
#![plugin(bar)]
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file(
|
|
||||||
"bar/Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "bar"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = []
|
|
||||||
build = 'build.rs'
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "bar"
|
|
||||||
plugin = true
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file(
|
|
||||||
"bar/build.rs",
|
|
||||||
r#"
|
|
||||||
use std::env;
|
|
||||||
use std::fs;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
|
||||||
let root = PathBuf::from(env::var("BUILDER_ROOT").unwrap());
|
|
||||||
let file = format!("{}builder{}",
|
|
||||||
env::consts::DLL_PREFIX,
|
|
||||||
env::consts::DLL_SUFFIX);
|
|
||||||
let src = root.join(&file);
|
|
||||||
let dst = out_dir.join(&file);
|
|
||||||
fs::copy(src, dst).unwrap();
|
|
||||||
if cfg!(target_env = "msvc") {
|
|
||||||
fs::copy(root.join("builder.dll.lib"),
|
|
||||||
out_dir.join("builder.dll.lib")).unwrap();
|
|
||||||
}
|
|
||||||
println!("cargo:rustc-flags=-L {}", out_dir.display());
|
|
||||||
}
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file(
|
|
||||||
"bar/src/lib.rs",
|
|
||||||
r#"
|
|
||||||
#![feature(rustc_private)]
|
|
||||||
|
|
||||||
extern crate rustc_driver;
|
|
||||||
use rustc_driver::plugin::Registry;
|
|
||||||
|
|
||||||
#[cfg_attr(not(target_env = "msvc"), link(name = "builder"))]
|
|
||||||
#[cfg_attr(target_env = "msvc", link(name = "builder.dll"))]
|
|
||||||
extern { fn foo(); }
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub fn __rustc_plugin_registrar(_reg: &mut Registry) {
|
|
||||||
unsafe { foo() }
|
|
||||||
}
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
build.cargo("build").run();
|
|
||||||
|
|
||||||
let root = build.root().join("target").join("debug");
|
|
||||||
foo.cargo("build -v").env("BUILDER_ROOT", root).run();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cargo_test]
|
|
||||||
fn plugin_integration() {
|
|
||||||
let p = project()
|
|
||||||
.file(
|
|
||||||
"Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "foo"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = []
|
|
||||||
build = "build.rs"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "foo"
|
|
||||||
plugin = true
|
|
||||||
doctest = false
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file("build.rs", "fn main() {}")
|
|
||||||
.file("src/lib.rs", "")
|
|
||||||
.file("tests/it_works.rs", "")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
p.cargo("test -v").run();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cargo_test]
|
|
||||||
fn doctest_a_plugin() {
|
|
||||||
let p = project()
|
|
||||||
.file(
|
|
||||||
"Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "foo"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = []
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
bar = { path = "bar" }
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file("src/lib.rs", "#[macro_use] extern crate bar;")
|
|
||||||
.file(
|
|
||||||
"bar/Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "bar"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = []
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "bar"
|
|
||||||
plugin = true
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file("bar/src/lib.rs", "pub fn bar() {}")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
p.cargo("test -v").run();
|
|
||||||
}
|
|
||||||
|
|
||||||
// See #1515
|
|
||||||
#[cargo_test]
|
|
||||||
fn native_plugin_dependency_with_custom_linker() {
|
|
||||||
let target = rustc_host();
|
|
||||||
|
|
||||||
let _foo = project()
|
|
||||||
.file(
|
|
||||||
"Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "foo"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = []
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
plugin = true
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file("src/lib.rs", "")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
let bar = project()
|
|
||||||
.at("bar")
|
|
||||||
.file(
|
|
||||||
"Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "bar"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = []
|
|
||||||
|
|
||||||
[dependencies.foo]
|
|
||||||
path = "../foo"
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file("src/lib.rs", "")
|
|
||||||
.file(
|
|
||||||
".cargo/config",
|
|
||||||
&format!(
|
|
||||||
r#"
|
|
||||||
[target.{}]
|
|
||||||
linker = "nonexistent-linker"
|
|
||||||
"#,
|
|
||||||
target
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
bar.cargo("build --verbose")
|
|
||||||
.with_status(101)
|
|
||||||
.with_stderr_contains(
|
|
||||||
"\
|
|
||||||
[COMPILING] foo v0.0.1 ([..])
|
|
||||||
[RUNNING] `rustc [..] -C linker=nonexistent-linker [..]`
|
|
||||||
[ERROR] [..]linker[..]
|
|
||||||
",
|
|
||||||
)
|
|
||||||
.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cargo_test(nightly, reason = "requires rustc_private")]
|
|
||||||
fn panic_abort_plugins() {
|
|
||||||
let p = project()
|
|
||||||
.file(
|
|
||||||
"Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "foo"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = []
|
|
||||||
|
|
||||||
[profile.dev]
|
|
||||||
panic = 'abort'
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
bar = { path = "bar" }
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file("src/lib.rs", "")
|
|
||||||
.file(
|
|
||||||
"bar/Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "bar"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = []
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
plugin = true
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file(
|
|
||||||
"bar/src/lib.rs",
|
|
||||||
r#"
|
|
||||||
#![feature(rustc_private)]
|
|
||||||
extern crate rustc_ast;
|
|
||||||
extern crate rustc_driver;
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
p.cargo("build").run();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cargo_test(nightly, reason = "requires rustc_private")]
|
|
||||||
fn shared_panic_abort_plugins() {
|
|
||||||
let p = project()
|
|
||||||
.file(
|
|
||||||
"Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "foo"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = []
|
|
||||||
|
|
||||||
[profile.dev]
|
|
||||||
panic = 'abort'
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
bar = { path = "bar" }
|
|
||||||
baz = { path = "baz" }
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file("src/lib.rs", "extern crate baz;")
|
|
||||||
.file(
|
|
||||||
"bar/Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "bar"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = []
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
plugin = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
baz = { path = "../baz" }
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file(
|
|
||||||
"bar/src/lib.rs",
|
|
||||||
r#"
|
|
||||||
#![feature(rustc_private)]
|
|
||||||
extern crate rustc_ast;
|
|
||||||
extern crate rustc_driver;
|
|
||||||
extern crate baz;
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file("baz/Cargo.toml", &basic_manifest("baz", "0.0.1"))
|
|
||||||
.file("baz/src/lib.rs", "")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
p.cargo("build -v").run();
|
|
||||||
}
|
|
@ -202,52 +202,6 @@ fn impl_and_derive() {
|
|||||||
p.cargo("run").with_stdout("X { success: true }").run();
|
p.cargo("run").with_stdout("X { success: true }").run();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cargo_test(nightly, reason = "plugins are unstable")]
|
|
||||||
fn plugin_and_proc_macro() {
|
|
||||||
let p = project()
|
|
||||||
.file(
|
|
||||||
"Cargo.toml",
|
|
||||||
r#"
|
|
||||||
[package]
|
|
||||||
name = "foo"
|
|
||||||
version = "0.0.1"
|
|
||||||
authors = []
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
plugin = true
|
|
||||||
proc-macro = true
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file(
|
|
||||||
"src/lib.rs",
|
|
||||||
r#"
|
|
||||||
#![feature(rustc_private)]
|
|
||||||
#![feature(proc_macro, proc_macro_lib)]
|
|
||||||
|
|
||||||
extern crate rustc_driver;
|
|
||||||
use rustc_driver::plugin::Registry;
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
|
||||||
use proc_macro::TokenStream;
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub fn __rustc_plugin_registrar(reg: &mut Registry) {}
|
|
||||||
|
|
||||||
#[proc_macro_derive(Questionable)]
|
|
||||||
pub fn questionable(input: TokenStream) -> TokenStream {
|
|
||||||
input
|
|
||||||
}
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
let msg = " `lib.plugin` and `lib.proc-macro` cannot both be `true`";
|
|
||||||
p.cargo("check")
|
|
||||||
.with_status(101)
|
|
||||||
.with_stderr_contains(msg)
|
|
||||||
.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn proc_macro_doctest() {
|
fn proc_macro_doctest() {
|
||||||
let foo = project()
|
let foo = project()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user