Skip to content

Commit 4eaad54

Browse files
committed
Make tests work without libstd
1 parent a331b94 commit 4eaad54

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
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

Lines changed: 12 additions & 1 deletion
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"))]
@@ -910,9 +911,18 @@ impl_array!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 24, 32, 3
910911
#[cfg(test)]
911912
pub mod tests {
912913
use SmallVec;
913-
use std::borrow::ToOwned;
914+
914915
use std::iter::FromIterator;
915916

917+
#[cfg(feature = "std")]
918+
use std::borrow::ToOwned;
919+
#[cfg(not(feature = "std"))]
920+
use alloc::borrow::ToOwned;
921+
#[cfg(not(feature = "std"))]
922+
use alloc::boxed::Box;
923+
#[cfg(not(feature = "std"))]
924+
use alloc::vec::Vec;
925+
916926
#[cfg(feature="heapsizeof")]
917927
use heapsize::HeapSizeOf;
918928
#[cfg(feature="heapsizeof")]
@@ -1254,6 +1264,7 @@ pub mod tests {
12541264
assert!(c > b);
12551265
}
12561266

1267+
#[cfg(feature = "std")]
12571268
#[test]
12581269
fn test_hash() {
12591270
use std::hash::Hash;

0 commit comments

Comments
 (0)