test(readme): test readme code fences

This commit is contained in:
Sean McArthur
2016-04-19 15:54:09 -07:00
parent caa796f98d
commit b98662ab6d
3 changed files with 12 additions and 1 deletions

View File

@@ -18,6 +18,7 @@ cache:
- target/debug/build - target/debug/build
script: script:
- ./.travis/readme.py
- cargo build --verbose $FEATURES - cargo build --verbose $FEATURES
- cargo test --verbose $FEATURES - cargo test --verbose $FEATURES
- 'if [ $TRAVIS_RUST_VERSION = nightly ]; then cargo bench --no-run; fi' - 'if [ $TRAVIS_RUST_VERSION = nightly ]; then cargo bench --no-run; fi'

10
.travis/readme.py Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env python
import re
f = open('README.md', 'r')
raw = f.read()
for (i, code) in enumerate(re.findall(r'```rust([^`]*)```', raw, re.M)):
with open('examples/readme_%s.rs' % i, 'w') as f:
f.write('#![deny(warnings)]%s' % code)

View File

@@ -54,7 +54,7 @@ use hyper::header::Connection;
fn main() { fn main() {
// Create a client. // Create a client.
let mut client = Client::new(); let client = Client::new();
// Creating an outgoing request. // Creating an outgoing request.
let mut res = client.get("http://rust-lang.org/") let mut res = client.get("http://rust-lang.org/")