From a92d162026dd8696f71f95f79fc62ab8236b6fc3 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Tue, 13 May 2014 11:55:44 +0200 Subject: [PATCH] Some basic acceptance tests for better SVH. --- src/test/auxiliary/svh-a-base.rs | 37 +++++++++++++++++ src/test/auxiliary/svh-a-change-lit.rs | 37 +++++++++++++++++ .../auxiliary/svh-a-change-significant-cfg.rs | 39 ++++++++++++++++++ .../auxiliary/svh-a-change-trait-bound.rs | 37 +++++++++++++++++ src/test/auxiliary/svh-a-comment.rs | 38 ++++++++++++++++++ src/test/auxiliary/svh-a-doc.rs | 40 +++++++++++++++++++ src/test/auxiliary/svh-a-macro.rs | 39 ++++++++++++++++++ src/test/auxiliary/svh-a-no-change.rs | 37 +++++++++++++++++ src/test/auxiliary/svh-a-redundant-cfg.rs | 39 ++++++++++++++++++ src/test/auxiliary/svh-a-whitespace.rs | 39 ++++++++++++++++++ src/test/auxiliary/svh-b.rs | 23 +++++++++++ src/test/compile-fail/svh-change-lit.rs | 24 +++++++++++ .../svh-change-significant-cfg.rs | 24 +++++++++++ .../compile-fail/svh-change-trait-bound.rs | 24 +++++++++++ src/test/run-pass/svh-add-comment.rs | 23 +++++++++++ src/test/run-pass/svh-add-doc.rs | 23 +++++++++++ src/test/run-pass/svh-add-macro.rs | 23 +++++++++++ src/test/run-pass/svh-add-nothing.rs | 23 +++++++++++ src/test/run-pass/svh-add-redundant-cfg.rs | 23 +++++++++++ src/test/run-pass/svh-add-whitespace.rs | 23 +++++++++++ 20 files changed, 615 insertions(+) create mode 100644 src/test/auxiliary/svh-a-base.rs create mode 100644 src/test/auxiliary/svh-a-change-lit.rs create mode 100644 src/test/auxiliary/svh-a-change-significant-cfg.rs create mode 100644 src/test/auxiliary/svh-a-change-trait-bound.rs create mode 100644 src/test/auxiliary/svh-a-comment.rs create mode 100644 src/test/auxiliary/svh-a-doc.rs create mode 100644 src/test/auxiliary/svh-a-macro.rs create mode 100644 src/test/auxiliary/svh-a-no-change.rs create mode 100644 src/test/auxiliary/svh-a-redundant-cfg.rs create mode 100644 src/test/auxiliary/svh-a-whitespace.rs create mode 100644 src/test/auxiliary/svh-b.rs create mode 100644 src/test/compile-fail/svh-change-lit.rs create mode 100644 src/test/compile-fail/svh-change-significant-cfg.rs create mode 100644 src/test/compile-fail/svh-change-trait-bound.rs create mode 100644 src/test/run-pass/svh-add-comment.rs create mode 100644 src/test/run-pass/svh-add-doc.rs create mode 100644 src/test/run-pass/svh-add-macro.rs create mode 100644 src/test/run-pass/svh-add-nothing.rs create mode 100644 src/test/run-pass/svh-add-redundant-cfg.rs create mode 100644 src/test/run-pass/svh-add-whitespace.rs diff --git a/src/test/auxiliary/svh-a-base.rs b/src/test/auxiliary/svh-a-base.rs new file mode 100644 index 00000000000..b83e96fc47d --- /dev/null +++ b/src/test/auxiliary/svh-a-base.rs @@ -0,0 +1,37 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The `svh-a-*.rs` files are all deviations from the base file +//! svh-a-base.rs with some difference (usually in `fn foo`) that +//! should not affect the strict version hash (SVH) computation +//! (#14132). + +#![feature(macro_rules)] + +#![crate_id = "a"] + +macro_rules! three { + () => { 3 } +} + +pub trait U {} +pub trait V {} +impl U for () {} +impl V for () {} + +static A_CONSTANT : int = 2; + +pub fn foo(_: int) -> int { + 3 +} + +pub fn an_unused_name() -> int { + 4 +} diff --git a/src/test/auxiliary/svh-a-change-lit.rs b/src/test/auxiliary/svh-a-change-lit.rs new file mode 100644 index 00000000000..81c2c39bd52 --- /dev/null +++ b/src/test/auxiliary/svh-a-change-lit.rs @@ -0,0 +1,37 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The `svh-a-*.rs` files are all deviations from the base file +//! svh-a-base.rs with some difference (usually in `fn foo`) that +//! should not affect the strict version hash (SVH) computation +//! (#14132). + +#![feature(macro_rules)] + +#![crate_id = "a"] + +macro_rules! three { + () => { 3 } +} + +pub trait U {} +pub trait V {} +impl U for () {} +impl V for () {} + +static A_CONSTANT : int = 2; + +pub fn foo(_: int) -> int { + 0 +} + +pub fn an_unused_name() -> int { + 4 +} diff --git a/src/test/auxiliary/svh-a-change-significant-cfg.rs b/src/test/auxiliary/svh-a-change-significant-cfg.rs new file mode 100644 index 00000000000..33dd3868566 --- /dev/null +++ b/src/test/auxiliary/svh-a-change-significant-cfg.rs @@ -0,0 +1,39 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The `svh-a-*.rs` files are all deviations from the base file +//! svh-a-base.rs with some difference (usually in `fn foo`) that +//! should not affect the strict version hash (SVH) computation +//! (#14132). + +#![feature(macro_rules)] + +#![crate_id = "a"] + +macro_rules! three { + () => { 3 } +} + +pub trait U {} +pub trait V {} +impl U for () {} +impl V for () {} + +static A_CONSTANT : int = 2; + +#[cfg(some_flag)] +pub fn foo(_: int) -> int { + 3 +} + +#[cfg(not(some_flag))] +pub fn an_unused_name() -> int { + 4 +} diff --git a/src/test/auxiliary/svh-a-change-trait-bound.rs b/src/test/auxiliary/svh-a-change-trait-bound.rs new file mode 100644 index 00000000000..04c320d4016 --- /dev/null +++ b/src/test/auxiliary/svh-a-change-trait-bound.rs @@ -0,0 +1,37 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The `svh-a-*.rs` files are all deviations from the base file +//! svh-a-base.rs with some difference (usually in `fn foo`) that +//! should not affect the strict version hash (SVH) computation +//! (#14132). + +#![feature(macro_rules)] + +#![crate_id = "a"] + +macro_rules! three { + () => { 3 } +} + +pub trait U {} +pub trait V {} +impl U for () {} +impl V for () {} + +static A_CONSTANT : int = 2; + +pub fn foo(_: int) -> int { + 3 +} + +pub fn an_unused_name() -> int { + 4 +} diff --git a/src/test/auxiliary/svh-a-comment.rs b/src/test/auxiliary/svh-a-comment.rs new file mode 100644 index 00000000000..208f39ffedc --- /dev/null +++ b/src/test/auxiliary/svh-a-comment.rs @@ -0,0 +1,38 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The `svh-a-*.rs` files are all deviations from the base file +//! svh-a-base.rs with some difference (usually in `fn foo`) that +//! should not affect the strict version hash (SVH) computation +//! (#14132). + +#![feature(macro_rules)] + +#![crate_id = "a"] + +macro_rules! three { + () => { 3 } +} + +pub trait U {} +pub trait V {} +impl U for () {} +impl V for () {} + +static A_CONSTANT : int = 2; + +pub fn foo(_: int) -> int { + // a comment does not affect the svh + 3 +} + +pub fn an_unused_name() -> int { + 4 +} diff --git a/src/test/auxiliary/svh-a-doc.rs b/src/test/auxiliary/svh-a-doc.rs new file mode 100644 index 00000000000..667a3b28cea --- /dev/null +++ b/src/test/auxiliary/svh-a-doc.rs @@ -0,0 +1,40 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The `svh-a-*.rs` files are all deviations from the base file +//! svh-a-base.rs with some difference (usually in `fn foo`) that +//! should not affect the strict version hash (SVH) computation +//! (#14132). + +#![feature(macro_rules)] + +#![crate_id = "a"] + +macro_rules! three { + () => { 3 } +} + +pub trait U {} +pub trait V {} +impl U for () {} +impl V for () {} + +static A_CONSTANT : int = 2; + +// Adding some documentation does not affect the svh. + +/// foo always returns three. +pub fn foo(_: int) -> int { + 3 +} + +pub fn an_unused_name() -> int { + 4 +} diff --git a/src/test/auxiliary/svh-a-macro.rs b/src/test/auxiliary/svh-a-macro.rs new file mode 100644 index 00000000000..f4279b44b4e --- /dev/null +++ b/src/test/auxiliary/svh-a-macro.rs @@ -0,0 +1,39 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The `svh-a-*.rs` files are all deviations from the base file +//! svh-a-base.rs with some difference (usually in `fn foo`) that +//! should not affect the strict version hash (SVH) computation +//! (#14132). + +#![feature(macro_rules)] + +#![crate_id = "a"] + +macro_rules! three { + () => { 3 } +} + +pub trait U {} +pub trait V {} +impl U for () {} +impl V for () {} + +static A_CONSTANT : int = 2; + +pub fn foo(_: int) -> int { + // a macro invocation in a function body does not affect the svh, + // as long as it yields the same code. + three!() +} + +pub fn an_unused_name() -> int { + 4 +} diff --git a/src/test/auxiliary/svh-a-no-change.rs b/src/test/auxiliary/svh-a-no-change.rs new file mode 100644 index 00000000000..b83e96fc47d --- /dev/null +++ b/src/test/auxiliary/svh-a-no-change.rs @@ -0,0 +1,37 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The `svh-a-*.rs` files are all deviations from the base file +//! svh-a-base.rs with some difference (usually in `fn foo`) that +//! should not affect the strict version hash (SVH) computation +//! (#14132). + +#![feature(macro_rules)] + +#![crate_id = "a"] + +macro_rules! three { + () => { 3 } +} + +pub trait U {} +pub trait V {} +impl U for () {} +impl V for () {} + +static A_CONSTANT : int = 2; + +pub fn foo(_: int) -> int { + 3 +} + +pub fn an_unused_name() -> int { + 4 +} diff --git a/src/test/auxiliary/svh-a-redundant-cfg.rs b/src/test/auxiliary/svh-a-redundant-cfg.rs new file mode 100644 index 00000000000..203dadd633e --- /dev/null +++ b/src/test/auxiliary/svh-a-redundant-cfg.rs @@ -0,0 +1,39 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The `svh-a-*.rs` files are all deviations from the base file +//! svh-a-base.rs with some difference (usually in `fn foo`) that +//! should not affect the strict version hash (SVH) computation +//! (#14132). + +#![feature(macro_rules)] + +#![crate_id = "a"] + +macro_rules! three { + () => { 3 } +} + +pub trait U {} +pub trait V {} +impl U for () {} +impl V for () {} + +static A_CONSTANT : int = 2; + +// cfg attribute does not affect the svh, as long as it yields the same code. +#[cfg(not(an_unused_name))] +pub fn foo(_: int) -> int { + 3 +} + +pub fn an_unused_name() -> int { + 4 +} diff --git a/src/test/auxiliary/svh-a-whitespace.rs b/src/test/auxiliary/svh-a-whitespace.rs new file mode 100644 index 00000000000..9b332a294d6 --- /dev/null +++ b/src/test/auxiliary/svh-a-whitespace.rs @@ -0,0 +1,39 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The `svh-a-*.rs` files are all deviations from the base file +//! svh-a-base.rs with some difference (usually in `fn foo`) that +//! should not affect the strict version hash (SVH) computation +//! (#14132). + +#![feature(macro_rules)] + +#![crate_id = "a"] + +macro_rules! three { + () => { 3 } +} + +pub trait U {} +pub trait V {} +impl U for () {} +impl V for () {} + +static A_CONSTANT : int = 2; + +pub fn foo(_: int) -> int { + + 3 + +} + +pub fn an_unused_name() -> int { + 4 +} diff --git a/src/test/auxiliary/svh-b.rs b/src/test/auxiliary/svh-b.rs new file mode 100644 index 00000000000..713fed591c8 --- /dev/null +++ b/src/test/auxiliary/svh-b.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! This is a client of the `a` crate defined in "svn-a-base.rs". The +//! rpass and cfail tests (such as "run-pass/svh-add-comment.rs") use +//! it by swapping in a different object code library crate built from +//! some variant of "svn-a-base.rs", and then we are checking if the +//! compiler properly ignores or accepts the change, based on whether +//! the change could affect the downstream crate content or not +//! (#14132). + +#![crate_id = "b"] + +extern crate a; + +pub fn foo() { assert_eq!(a::foo::<()>(0), 3); } diff --git a/src/test/compile-fail/svh-change-lit.rs b/src/test/compile-fail/svh-change-lit.rs new file mode 100644 index 00000000000..179fb11d5fe --- /dev/null +++ b/src/test/compile-fail/svh-change-lit.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// note that these aux-build directives must be in this order +// aux-build:svh-a-base.rs +// aux-build:svh-b.rs +// aux-build:svh-a-change-lit.rs + +#![feature(macro_rules)] + +extern crate a; +extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on +//~^ NOTE: perhaps this crate needs to be recompiled + +fn main() { + b::foo() +} diff --git a/src/test/compile-fail/svh-change-significant-cfg.rs b/src/test/compile-fail/svh-change-significant-cfg.rs new file mode 100644 index 00000000000..1f65f3873a9 --- /dev/null +++ b/src/test/compile-fail/svh-change-significant-cfg.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// note that these aux-build directives must be in this order +// aux-build:svh-a-base.rs +// aux-build:svh-b.rs +// aux-build:svh-a-change-significant-cfg.rs + +#![feature(macro_rules)] + +extern crate a; +extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on +//~^ NOTE: perhaps this crate needs to be recompiled + +fn main() { + b::foo() +} diff --git a/src/test/compile-fail/svh-change-trait-bound.rs b/src/test/compile-fail/svh-change-trait-bound.rs new file mode 100644 index 00000000000..4e4f7b232f4 --- /dev/null +++ b/src/test/compile-fail/svh-change-trait-bound.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// note that these aux-build directives must be in this order +// aux-build:svh-a-base.rs +// aux-build:svh-b.rs +// aux-build:svh-a-change-trait-bound.rs + +#![feature(macro_rules)] + +extern crate a; +extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on +//~^ NOTE: perhaps this crate needs to be recompiled + +fn main() { + b::foo() +} diff --git a/src/test/run-pass/svh-add-comment.rs b/src/test/run-pass/svh-add-comment.rs new file mode 100644 index 00000000000..bc9a371edf7 --- /dev/null +++ b/src/test/run-pass/svh-add-comment.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// note that these aux-build directives must be in this order +// aux-build:svh-a-base.rs +// aux-build:svh-b.rs +// aux-build:svh-a-comment.rs + +#![feature(macro_rules)] + +extern crate a; +extern crate b; + +fn main() { + b::foo() +} diff --git a/src/test/run-pass/svh-add-doc.rs b/src/test/run-pass/svh-add-doc.rs new file mode 100644 index 00000000000..6599e493d25 --- /dev/null +++ b/src/test/run-pass/svh-add-doc.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// note that these aux-build directives must be in this order +// aux-build:svh-a-base.rs +// aux-build:svh-b.rs +// aux-build:svh-a-doc.rs + +#![feature(macro_rules)] + +extern crate a; +extern crate b; + +fn main() { + b::foo() +} diff --git a/src/test/run-pass/svh-add-macro.rs b/src/test/run-pass/svh-add-macro.rs new file mode 100644 index 00000000000..f4bfe3d8c7c --- /dev/null +++ b/src/test/run-pass/svh-add-macro.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// note that these aux-build directives must be in this order +// aux-build:svh-a-base.rs +// aux-build:svh-b.rs +// aux-build:svh-a-macro.rs + +#![feature(macro_rules)] + +extern crate a; +extern crate b; + +fn main() { + b::foo() +} diff --git a/src/test/run-pass/svh-add-nothing.rs b/src/test/run-pass/svh-add-nothing.rs new file mode 100644 index 00000000000..7f702bd7ab5 --- /dev/null +++ b/src/test/run-pass/svh-add-nothing.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// note that these aux-build directives must be in this order +// aux-build:svh-a-base.rs +// aux-build:svh-b.rs +// aux-build:svh-a-no-change.rs + +#![feature(macro_rules)] + +extern crate a; +extern crate b; + +fn main() { + b::foo() +} diff --git a/src/test/run-pass/svh-add-redundant-cfg.rs b/src/test/run-pass/svh-add-redundant-cfg.rs new file mode 100644 index 00000000000..b5a84843a54 --- /dev/null +++ b/src/test/run-pass/svh-add-redundant-cfg.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// note that these aux-build directives must be in this order +// aux-build:svh-a-base.rs +// aux-build:svh-b.rs +// aux-build:svh-a-redundant-cfg.rs + +#![feature(macro_rules)] + +extern crate a; +extern crate b; + +fn main() { + b::foo() +} diff --git a/src/test/run-pass/svh-add-whitespace.rs b/src/test/run-pass/svh-add-whitespace.rs new file mode 100644 index 00000000000..4a8058c9664 --- /dev/null +++ b/src/test/run-pass/svh-add-whitespace.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// note that these aux-build directives must be in this order +// aux-build:svh-a-base.rs +// aux-build:svh-b.rs +// aux-build:svh-a-whitespace.rs + +#![feature(macro_rules)] + +extern crate a; +extern crate b; + +fn main() { + b::foo() +}