Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Commit 1176eaf

Browse files
palfreyAndyGauge
authored andcommitted
Check formatting on code at build time (#282)
* Check formatting on code * Fix formatting
1 parent ea81711 commit 1176eaf

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

.travis.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ before_script:
2323
- |
2424
pip install 'travis-cargo<0.2' --user &&
2525
export PATH=$HOME/.local/bin:$PATH
26+
if [ "$CHECK" = "true" ]; then rustup component add rustfmt ; fi
2627
2728
script:
28-
- travis-cargo build -- $FEATURES
29-
- travis-cargo --skip 1.13.0 test -- $FEATURES
29+
- if [ "$CHECK" = "true" ]; then travis-cargo fmt -- -- --check ; fi
30+
- if [ "$CHECK" = "" ]; then travis-cargo build -- $FEATURES ; fi
31+
- if [ "$CHECK" = "" ]; then travis-cargo --skip 1.13.0 test -- $FEATURES ; fi
3032

3133
after_success:
3234
- travis-cargo --only stable doc
@@ -42,6 +44,9 @@ env:
4244
- FEATURES=--no-default-features
4345

4446
matrix:
47+
include:
48+
- env: CHECK=true
49+
rust: stable
4550
exclude:
4651
- env: FEATURES=--features=backtrace
4752
rust: 1.13.0

tests/tests.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,19 @@ fn has_backtrace_depending_on_env() {
202202
use std::path::PathBuf;
203203
use std::process::Command;
204204

205-
let cmd_folder = if cfg!(build="debug") {
205+
let cmd_folder = if cfg!(build = "debug") {
206206
"debug"
207-
} else if cfg!(build="release") {
207+
} else if cfg!(build = "release") {
208208
"release"
209209
} else {
210210
panic!("Unknown build config");
211211
};
212212

213213
let cmd_path = if cfg!(windows) {
214-
PathBuf::from(format!("./target/{}/examples/has_backtrace.exe", cmd_folder))
214+
PathBuf::from(format!(
215+
"./target/{}/examples/has_backtrace.exe",
216+
cmd_folder
217+
))
215218
} else {
216219
PathBuf::from(format!("./target/{}/examples/has_backtrace", cmd_folder))
217220
};

0 commit comments

Comments
 (0)