Skip to content

Commit 47cbda7

Browse files
committed
Make tests work without libstd
1 parent 498d0f1 commit 47cbda7

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ script: |
88
cargo build --features=heapsizeof --verbose &&
99
cargo test --verbose &&
1010
cargo test --features=heapsizeof --verbose &&
11+
([ $TRAVIS_RUST_VERSION != nightly ] || cargo test --verbose --no-default-features) &&
1112
([ $TRAVIS_RUST_VERSION != nightly ] || cargo bench --verbose bench)
1213
notifications:
1314
webhooks: http://build.servo.org:54856/travis

lib.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212

1313
#[cfg(not(feature = "std"))]
14+
#[cfg_attr(test, macro_use)]
1415
extern crate alloc;
1516

1617
#[cfg(not(feature = "std"))]
@@ -967,9 +968,18 @@ impl_array!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 24, 32, 3
967968
#[cfg(test)]
968969
pub mod tests {
969970
use SmallVec;
970-
use std::borrow::ToOwned;
971+
971972
use std::iter::FromIterator;
972973

974+
#[cfg(feature = "std")]
975+
use std::borrow::ToOwned;
976+
#[cfg(not(feature = "std"))]
977+
use alloc::borrow::ToOwned;
978+
#[cfg(not(feature = "std"))]
979+
use alloc::boxed::Box;
980+
#[cfg(not(feature = "std"))]
981+
use alloc::vec::Vec;
982+
973983
#[cfg(feature="heapsizeof")]
974984
use heapsize::HeapSizeOf;
975985
#[cfg(feature="heapsizeof")]
@@ -1311,6 +1321,7 @@ pub mod tests {
13111321
assert!(c > b);
13121322
}
13131323

1324+
#[cfg(feature = "std")]
13141325
#[test]
13151326
fn test_hash() {
13161327
use std::hash::Hash;

0 commit comments

Comments
 (0)