Skip to content

Commit

Permalink
Remove nightlytests feature flag. Run all tests on all versions of Ru…
Browse files Browse the repository at this point in the history
…st. (#172)

* Enable TryFrom on stable

* Include skeptic and logging tests into travis matrix

* remove nightlytests feature flag

* Set minimum required Rust version to 1.40.0

* Set version to 0.10.0-alpha

Co-authored-by: Andrey Kutejko <andrey.kutejko@sizmek.com>
  • Loading branch information
andy128k and Andrey Kutejko committed Aug 11, 2020
1 parent fa81306 commit eb068f9
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 55 deletions.
11 changes: 5 additions & 6 deletions .travis.yml
Expand Up @@ -5,22 +5,21 @@ rust:
- beta
- stable
- nightly
- 1.37.0
- 1.40.0
matrix:
include:
- rust: nightly
env: JOB=test CARGO_FEATURES="skeptic_tests nightlytests logging"
- rust: stable
env: JOB=style_check
allow_failures:
- env: JOB=style_check
- env: JOB=test CARGO_FEATURES="skeptic_tests nightlytests logging"
fast_finish: true
env:
matrix:
- JOB=test
- JOB=test CARGO_FEATURES=""
- JOB=test CARGO_FEATURES="skeptic_tests"
- JOB=test CARGO_FEATURES="logging"
- JOB=test CARGO_FEATURES="skeptic_tests logging"
global:
- CARGO_FEATURES=""
- RUST_BACKTRACE=1
- TRAVIS_CARGO_NIGHTLY_FEATURE=""
- PKGNAME=derive_builder
Expand Down
3 changes: 3 additions & 0 deletions derive_builder/CHANGELOG.md
Expand Up @@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
- Requires Rust 1.40.0 or newer (was 1.37.0) #169

## [0.9.0] - 2019-11-07
- Add `setter(custom)` to allow implementing a custom setter #154

Expand Down
9 changes: 4 additions & 5 deletions derive_builder/Cargo.toml
@@ -1,14 +1,14 @@
[package]
name = "derive_builder"
version = "0.9.0"
version = "0.10.0-alpha"
authors = ["Colin Kiegel <kiegel@gmx.de>",
"Pascal Hertleif <killercup@gmail.com>",
"Jan-Erik Rediger <janerik@fnordig.de>",
"Ted Driggs <ted.driggs@outlook.com>"]

description = "Rust macro to automatically implement the builder pattern for arbitrary structs."
repository = "https://github.com/colin-kiegel/rust-derive-builder"
documentation = "https://docs.rs/derive_builder/0.9.0"
documentation = "https://docs.rs/derive_builder/0.10.0-alpha"

license = "MIT/Apache-2.0"
categories = ["development-tools", "rust-patterns"]
Expand All @@ -25,7 +25,6 @@ proc-macro = true
[features]
logging = [ "log", "env_logger", "derive_builder_core/logging" ]
skeptic_tests = ["skeptic"]
nightlytests = ["compiletest_rs"]
clippy = ["derive_builder_core/clippy"]

[dependencies]
Expand All @@ -34,9 +33,8 @@ proc-macro2 = "1.0"
quote = "1.0"
log = { version = "0.4", optional = true }
env_logger = { version = "0.5", optional = true }
derive_builder_core = { version = "=0.9.0", path = "../derive_builder_core" }
derive_builder_core = { version = "=0.10.0-alpha", path = "../derive_builder_core" }
skeptic = { version = "0.13", optional = true }
compiletest_rs = { version = "0.3.18", optional = true }

[dependencies.syn]
version = "1.0"
Expand All @@ -49,3 +47,4 @@ env_logger = { version = "0.5", optional = true }

[dev-dependencies]
pretty_assertions = "0.6"
compiletest_rs = "0.5"
2 changes: 1 addition & 1 deletion derive_builder/README.md
@@ -1,5 +1,5 @@
[![Build status](https://travis-ci.org/colin-kiegel/rust-derive-builder.svg?branch=master)](https://travis-ci.org/colin-kiegel/rust-derive-builder)
[![Rust version]( https://img.shields.io/badge/rust-1.37+-blue.svg)]()
[![Rust version]( https://img.shields.io/badge/rust-1.40+-blue.svg)]()
[![Documentation](https://docs.rs/derive_builder/badge.svg)](https://docs.rs/derive_builder)
[![Latest version](https://img.shields.io/crates/v/derive_builder.svg)](https://crates.io/crates/derive_builder)
[![All downloads](https://img.shields.io/crates/d/derive_builder.svg)](https://crates.io/crates/derive_builder)
Expand Down
2 changes: 1 addition & 1 deletion derive_builder/build/skeptic.rs
Expand Up @@ -14,7 +14,7 @@ mod log_disabled {
fn main() {
println!("INFO: Run with `RUST_LOG=build_script_build=trace` for debug information.");
#[cfg(feature = "logging")]
env_logger::init().unwrap();
env_logger::init();

let mut files = generate_doc_tpl_tests().unwrap();
files.push("README.md".to_string());
Expand Down
14 changes: 3 additions & 11 deletions derive_builder/src/lib.rs
Expand Up @@ -265,36 +265,28 @@
//! to add `#![feature(try_from)]` to your crate to use it.
//!
//! ```rust
//! // #![feature(try_from)]
//! # #![cfg_attr(feature = "nightlytests", feature(try_from))]
//! # #[cfg(feature = "nightlytests")]
//! # #[macro_use]
//! # extern crate derive_builder;
//! #
//! # #[cfg(feature = "nightlytests")]
//! #[derive(Builder, Debug, PartialEq)]
//! #[builder(try_setter, setter(into))]
//! struct Lorem {
//! pub name: String,
//! pub ipsum: u8,
//! }
//!
//! # #[cfg(feature = "nightlytests")]
//! #[derive(Builder, Debug, PartialEq)]
//! struct Ipsum {
//! #[builder(try_setter, setter(into, name = "foo"))]
//! pub dolor: u8,
//! }
//!
//! fn main() {
//! # #[cfg(feature = "nightlytests")]
//! LoremBuilder::default()
//! .try_ipsum(1u16).unwrap()
//! .name("hello")
//! .build()
//! .expect("1 fits into a u8");
//!
//! # #[cfg(feature = "nightlytests")]
//! IpsumBuilder::default()
//! .try_foo(1u16).unwrap()
//! .build()
Expand Down Expand Up @@ -580,17 +572,17 @@ use darling::FromDeriveInput;
use options::Options;
use proc_macro::TokenStream;
#[cfg(feature = "logging")]
use std::sync::{Once, ONCE_INIT};
use std::sync::Once;

#[cfg(feature = "logging")]
static INIT_LOGGER: Once = ONCE_INIT;
static INIT_LOGGER: Once = Once::new();

#[doc(hidden)]
#[proc_macro_derive(Builder, attributes(builder))]
pub fn derive(input: TokenStream) -> TokenStream {
#[cfg(feature = "logging")]
INIT_LOGGER.call_once(|| {
env_logger::init().unwrap();
env_logger::init();
});

let ast = parse_macro_input!(input as syn::DeriveInput);
Expand Down
2 changes: 1 addition & 1 deletion derive_builder/tests/compile-fail/private_build_fn.rs
Expand Up @@ -25,7 +25,7 @@ fn main() {
let lorem1 = LoremBuilder::default().my_build();

let lorem2 = LoremBuilder::default().build().unwrap();
//~^ ERROR method `build` is private
//~^ ERROR `build` is private

println!("{:?} vs {:?}", lorem1, lorem2);
}
2 changes: 1 addition & 1 deletion derive_builder/tests/compile-fail/private_builder.rs
Expand Up @@ -18,7 +18,7 @@ fn main() {
//~^ ERROR struct `LoremBuilder` is private
.public("Hello")
.build()
//~^ ERROR method `build` is private
//~^ ERROR `build` is private
.unwrap();

assert_eq!(x.public, "Hello".to_string());
Expand Down
Expand Up @@ -5,15 +5,15 @@ extern crate derive_builder;

#[derive(Debug, PartialEq, Default, Builder, Clone)]
#[builder(setter(name = "foo"))]
//~^ ERROR Unexpected field `name`
//~^ ERROR Unknown field: `name`
struct Lorem {
ipsum: &'static str,
pub dolor: &'static str,
}

#[test]
fn renamed_setter() {
fn main() {
let x = LoremBuilder::default()
//~^ ERROR use of undeclared type or module `LoremBuilder`
.ipsum("ipsum")
.foo("dolor")
.build()
Expand Down
19 changes: 2 additions & 17 deletions derive_builder/tests/compiletests.rs
@@ -1,11 +1,5 @@
#![cfg(feature = "nightlytests")]
extern crate compiletest_rs as compiletest;

// note:
// - `env::var("PROFILE")` is only available vor build scripts
// http://doc.crates.io/environment-variables.html
const PROFILE: &'static str = "debug";

use std::env;
use std::path::PathBuf;

Expand All @@ -23,17 +17,8 @@ fn run_mode(mode: &'static str) {

config.mode = cfg_mode;
config.src_base = test_dir;

// note:
// - cargo respects the environment variable `env::var("CARGO_TARGET_DIR")`,
// however if this is not set and a virtual manifest is used, we will *not*
// know the path :-(
// In that case try to set `CARGO_TARGET_DIR` manually, e.g.
// `/path/to/my_workspace/target`.
let build_dir = env::var("CARGO_TARGET_DIR").unwrap_or(format!("{}/target", base_dir));
let artefacts_dir = format!("{}/{}", build_dir, PROFILE);

config.target_rustcflags = Some(format!("-L {} -L {}/deps", artefacts_dir, artefacts_dir));
config.link_deps();
config.clean_rmeta();

compiletest::run_tests(&config);
}
Expand Down
8 changes: 0 additions & 8 deletions derive_builder/tests/try_setter.rs
@@ -1,6 +1,3 @@
#![cfg(feature = "nightlytests")]
#![feature(try_from)]

#[macro_use]
extern crate derive_builder;

Expand All @@ -18,7 +15,6 @@ impl From<IpAddr> for MyAddr {
}
}

#[cfg(feature = "nightlytests")]
impl<'a> TryFrom<&'a str> for MyAddr {
type Error = AddrParseError;

Expand Down Expand Up @@ -47,7 +43,6 @@ fn exact_helper() -> Result<Lorem, String> {
.build()
}

#[cfg(feature = "nightlytests")]
fn try_helper() -> Result<Lorem, String> {
LoremBuilder::default()
.try_source("1.2.3.4")
Expand All @@ -66,7 +61,6 @@ fn infallible_set() {
}

#[test]
#[cfg(feature = "nightlytests")]
fn fallible_set() {
let mut builder = LoremBuilder::default();
let try_result = builder.try_source("1.2.3.4");
Expand All @@ -79,13 +73,11 @@ fn fallible_set() {
}

#[test]
#[cfg(feature = "nightlytests")]
fn with_helper() {
assert_eq!(exact_helper().unwrap(), try_helper().unwrap());
}

#[test]
#[cfg(feature = "nightlytests")]
fn renamed() {
IpsumBuilder::default()
.try_set_source("0.0.0.0")
Expand Down
2 changes: 1 addition & 1 deletion derive_builder_core/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "derive_builder_core"
version = "0.9.0"
version = "0.10.0-alpha"
authors = ["Colin Kiegel <kiegel@gmx.de>",
"Pascal Hertleif <killercup@gmail.com>",
"Jan-Erik Rediger <janerik@fnordig.de>",
Expand Down

0 comments on commit eb068f9

Please sign in to comment.