Skip to content

Commit 4f2ef05

Browse files
committed
Run test (just not benchmarks) on stable Rust.
1 parent 566793e commit 4f2ef05

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ rust:
66
script:
77
- cargo build
88
- cargo doc
9-
- "if [ $TRAVIS_RUST_VERSION = nightly ]; then cargo test; fi"
10-
- "if [ $TRAVIS_RUST_VERSION = nightly ]; then (cd capi/ctest; ./build-and-test.sh); fi"
9+
- cargo test
10+
- "(cd capi/ctest; ./build-and-test.sh)"
1111
after_success: curl https://raw.githubusercontent.com/kmcallister/travis-doc-upload/master/travis-doc-upload.sh | sh
1212
notifications:
1313
webhooks: http://build.servo.org:54856/travis

examples/fuzz.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
//! A simple fuzz tester for the library.
88
9-
#![feature(unsafe_no_drop_flag, str_char)]
109
#![deny(warnings)]
1110

1211
extern crate rand;
@@ -106,7 +105,7 @@ fn fuzz() {
106105
fn random_boundary<R: Rng>(rng: &mut R, text: &str) -> usize {
107106
loop {
108107
let i = Range::new(0, text.len()+1).ind_sample(rng);
109-
if text.is_char_boundary(i) {
108+
if is_char_boundary(text, i) {
110109
return i;
111110
}
112111
}
@@ -116,16 +115,25 @@ fn random_slice<R: Rng>(rng: &mut R, text: &str) -> (usize, usize) {
116115
loop {
117116
let start = Range::new(0, text.len()+1).ind_sample(rng);
118117
let end = Range::new(start, text.len()+1).ind_sample(rng);
119-
if !text.is_char_boundary(start) {
118+
if !is_char_boundary(text, start) {
120119
continue;
121120
}
122-
if end < text.len() && !text.is_char_boundary(end) {
121+
if end < text.len() && !is_char_boundary(text, end) {
123122
continue;
124123
}
125124
return (start, end);
126125
}
127126
}
128127

128+
// Copy of the str::is_char_boundary method, which is unstable.
129+
fn is_char_boundary(s: &str, index: usize) -> bool {
130+
if index == s.len() { return true; }
131+
match s.as_bytes().get(index) {
132+
None => false,
133+
Some(&b) => b < 128 || b >= 192,
134+
}
135+
}
136+
129137
static TEXT: &'static str =
130138
"It was from the artists and poets that the pertinent answers came, and I \
131139
know that panic would have broken loose had they been able to compare notes. \

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
// except according to those terms.
66

77
#![cfg_attr(feature = "unstable", feature(core, nonzero, unsafe_no_drop_flag, filling_drop))]
8-
#![cfg_attr(test, feature(test, str_char))]
8+
#![cfg_attr(all(test, feature = "unstable"), feature(test, str_char))]
99
#![cfg_attr(test, deny(warnings))]
1010

1111
#[cfg(feature = "unstable")] extern crate core;
1212
#[macro_use] extern crate mac;
1313
extern crate futf;
1414
extern crate encoding;
1515

16-
#[cfg(test)]
16+
#[cfg(all(test, feature = "unstable"))]
1717
extern crate test;
1818

1919
pub use tendril::{Tendril, ByteTendril, StrTendril, SliceExt, ReadExt, SubtendrilError};

src/tendril.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ impl<'a> From<&'a Tendril<fmt::UTF8>> for String {
11551155
}
11561156

11571157

1158-
#[cfg(test)]
1158+
#[cfg(all(test, feature = "unstable"))]
11591159
#[path="bench.rs"]
11601160
mod bench;
11611161

0 commit comments

Comments
 (0)