Skip to content

Commit

Permalink
Make serde-tests a standalone crate
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Aug 13, 2015
1 parent 85cd6f3 commit f011b01
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/target
/Cargo.lock
target
Cargo.lock
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ script:
- cargo build --verbose --no-default-features
- cargo build --verbose --features serde --no-default-features
- cargo test --verbose --features serde
- cargo test --verbose --manifest-path serde-tests/Cargo.toml
- rustdoc --test README.md -L target
- cargo doc --no-deps
after_success:
Expand Down
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ facilitate deserializing and serializing Rust structures.

[dependencies]
rustc-serialize = { optional = true, version = "0.3.0" }
serde = { optional = true }
serde = { optional = true, version = "0.5" }

[features]
default = ["rustc-serialize"]

[dev-dependencies]
rustc-serialize = "0.3"
serde_macros = "*"
21 changes: 21 additions & 0 deletions serde-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "serde-tests"
version = "0.1.0"
authors = ["Alex Crichton <alex@alexcrichton.com>"]
build = "build.rs"

[dependencies]
serde = "0.5"
toml = { path = "..", features = ["serde"] }

[build-dependencies]
syntex = "0.7"
serde_codegen = "0.5"

[lib]
name = "serde_tests"
path = "lib.rs"

[[test]]
name = "serde"
path = "test.rs"
17 changes: 17 additions & 0 deletions serde-tests/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
extern crate syntex;
extern crate serde_codegen;

use std::env;
use std::path::Path;

fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap();

let src = Path::new("test.rs.in");
let dst = Path::new(&out_dir).join("test.rs");

let mut registry = syntex::Registry::new();

serde_codegen::register(&mut registry);
registry.expand("", &src, &dst).unwrap();
}
1 change: 1 addition & 0 deletions serde-tests/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// intentionally blank
1 change: 1 addition & 0 deletions serde-tests/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include!(concat!(env!("OUT_DIR"), "/test.rs"));
9 changes: 2 additions & 7 deletions tests/serde.rs → serde-tests/test.rs.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
#![cfg(feature = "serde")]
#![feature(custom_derive, plugin)]
#![plugin(serde_macros)]


extern crate serde;
extern crate toml;

Expand Down Expand Up @@ -308,8 +303,8 @@ fn parse_enum() {
}

let v = Foo { a: E::Bar(10) };
// technically serde is correct here. a single element tuple still is a tuple and therefor
// a sequence
// technically serde is correct here. a single element tuple still is a
// tuple and therefor a sequence
assert_eq!(
encode!(v),
map! { a, Integer(10) }
Expand Down

0 comments on commit f011b01

Please sign in to comment.