Skip to content

Commit

Permalink
replace build script with rustfmt and meta tests
Browse files Browse the repository at this point in the history
  • Loading branch information
euclio committed Apr 13, 2018
1 parent c9f1a52 commit 38128ed
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 126 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ env:
- RUST_BACKTRACE=1
- secure: E33II/ctVUNigc5wuh153OX/7RUje43G3I9i5+PibEiFPCpKIJpHZA9LfKHABqOBVPgBLdWkretWgKn4Whfb9e2NMC8Nzn8Pch68b7yPZ2Ee0zLWr2M2gJ95PwTn3ZyFaMuZOAa+TgEU9buVIXTdgM+FHK+jXwU0qqNL2XCF5YM=

before_script:
- rustup component add rustfmt-preview

script:
- cargo fmt --all -- --write-mode=diff
- cargo build
- cargo test --all

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ Not sure how to help?
* Your code should build without warnings on latest nightly provided by [`rustup.rs`](https://rustup.rs).
* Please, use [`rustfmt`](https://github.com/rust-lang-nursery/rustfmt) on your code.
* Use [`rustfmt`](https://github.com/rust-lang-nursery/rustfmt) on your code. If your formatting does not match `rustfmt`, the build will fail.
You can install the tool with `cargo install rustfmt`. See `rustfmt --help` for more information. If you're having trouble getting `rustfmt` to work, try to keep your contributions adherent to the official style guide which you can see at [this location](http://doc.rust-lang.org/nightly/style/). Note the style guide is still a work-in-progress.
You can install the tool with `rustup component add rustfmt-preview`. See `cargo fmt --help` for more information.
* Stage your changes for commit, adding new and modified files to it:
Expand Down
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "rust-rosetta"
version = "0.0.1"
build = "build.rs"
authors = [
"Andrew Hobden, https://github.com/Hoverbear",
"Adolfo Ochagavía, https://github.com/aochagavia",
Expand Down Expand Up @@ -84,11 +83,9 @@ serde = "1"
serde_json = "1"
term = "0.4"

[build-dependencies]
failure = "0.1"
meta = { path = "meta" }
[dev-dependencies]
lazy_static = "1"
toml = "0.4"
unicode-segmentation = "1"

[workspace]
members = [
Expand Down
117 changes: 0 additions & 117 deletions build.rs

This file was deleted.

45 changes: 45 additions & 0 deletions tests/meta.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#![feature(fs_read_write)]

#[macro_use]
extern crate lazy_static;
extern crate meta;
extern crate toml;

use std::fs;
use std::path::{Path, PathBuf};

use meta::local;
use toml::Value;

lazy_static! {
static ref MANIFEST_PATH: PathBuf = Path::new(env!("CARGO_MANIFEST_DIR")).join("Cargo.toml");
}

#[test]
fn tasks_are_sorted() {
let toml: Value = fs::read_to_string(&*MANIFEST_PATH)
.unwrap()
.parse()
.unwrap();
let members = toml.get("workspace")
.and_then(|w| w.get("members"))
.and_then(|m| m.as_array())
.unwrap()
.iter()
.flat_map(|m| m.as_str())
.collect::<Vec<_>>();

let mut sorted_members = members.clone();
sorted_members.sort_unstable();

for (member, sorted_member) in members.iter().zip(sorted_members) {
if *member != sorted_member {
panic!("{} is not in the correct order in `Cargo.toml`!", member);
}
}
}

#[test]
fn parse_local_tasks() {
local::parse_tasks(&*MANIFEST_PATH).unwrap();
}

0 comments on commit 38128ed

Please sign in to comment.