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

Commit d5f292d

Browse files
committed
Auto merge of #14 - Hoverbear:tests, r=Hoverbear
Cache target dir
2 parents c5fb9da + 806ccfe commit d5f292d

File tree

2 files changed

+44
-18
lines changed

2 files changed

+44
-18
lines changed

bin/compile

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ if [[ ! -d "$CACHE_DIR/multirust" ]]; then
4040
./build.sh
4141
./install.sh --destdir="$CACHE_DIR/multirust" --prefix=""
4242
else
43-
log "Pre-existing multirust."
43+
log "Pre-existing multirust"
4444
fi
4545
export PATH="$PATH:$CACHE_DIR/multirust/bin"
4646

@@ -50,16 +50,26 @@ export HOME="$CACHE_DIR"
5050
# Use Multirust
5151
MULTIRUST_VERION="$(cat $BUILD_DIR/Cargo.toml | grep -ohzP "(?<=\[target.heroku\])[^\[]*" | grep -ohzP "(?<=version = \")[^\"]*")" || true
5252
if [[ -z "$MULTIRUST_VERION" ]]; then
53-
log "Setting version to \"nightly\" (default)."
53+
log "Setting version to \"nightly\" (default)"
5454
multirust default "nightly"
5555
else
56-
log "Setting version to \"$MULTIRUST_VERION\"."
56+
log "Setting version to \"$MULTIRUST_VERION\""
5757
multirust default "$MULTIRUST_VERION"
5858
fi
5959

6060
# Change into correct directory.
6161
cd "$BUILD_DIR"
6262

63+
if [[ ! -d "$CACHE_DIR/target" ]]; then
64+
log "No cached crates detected"
65+
else
66+
log "Detected cached crates... Restoring..."
67+
mv "$CACHE_DIR/target" "$BUILD_DIR/target"
68+
fi
69+
6370
# Build the Rust app
64-
log "Compiling Application..."
71+
log "Compiling application..."
6572
CARGO_HOME="$CACHE_DIR/cargo" cargo build --release
73+
74+
log "Caching build artifacts"
75+
cp -r "$BUILD_DIR/target" "$CACHE_DIR/target"

test/compile_test.sh

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ setup()
1212
name = "$PROJECT"
1313
version = "0.1.0"
1414
authors = ["Andrew Hobden <[email protected]>"]
15+
16+
[dependencies]
17+
rand = "*"
1518
EOF
1619
cat > $BUILD_DIR/src/main.rs <<EOF
20+
extern crate rand;
21+
1722
fn main() {
18-
println!("Hello world!");
23+
let number = rand::random::<u64>();
24+
println!("Hello world! Some random number is {}", number);
1925
}
2026
2127
#[test]
@@ -38,13 +44,17 @@ testDefault()
3844

3945
compile
4046

41-
assertCaptured "-----> Fetching multirust."
42-
assertCaptured "-----> Setting version to \"nightly\" (default)."
43-
assertCaptured "-----> Compiling Application."
47+
assertCaptured "-----> Fetching multirust"
48+
assertCaptured "-----> Setting version to \"nightly\" (default)"
49+
assertCaptured "-----> No cached crates detected"
50+
assertCaptured "-----> Compiling application"
51+
assertCaptured "-----> Caching build artifacts"
4452

4553
compile
4654

47-
assertCaptured "-----> Pre-existing multirust."
55+
assertCaptured "-----> Pre-existing multirust"
56+
assertCaptured "multirust: using existing install for"
57+
assertCaptured "-----> Detected cached crates... Restoring..."
4858

4959
cleanup
5060
}
@@ -59,9 +69,11 @@ EOF
5969

6070
compile
6171

62-
assertCaptured "-----> Fetching multirust."
63-
assertCaptured "-----> Setting version to \"nightly\"."
64-
assertCaptured "-----> Compiling Application."
72+
assertCaptured "-----> Fetching multirust"
73+
assertCaptured "-----> Setting version to \"nightly\""
74+
assertCaptured "-----> No cached crates detected"
75+
assertCaptured "-----> Compiling application"
76+
assertCaptured "-----> Caching build artifacts"
6577

6678
cleanup
6779
}
@@ -76,9 +88,11 @@ EOF
7688

7789
compile
7890

79-
assertCaptured "-----> Fetching multirust."
80-
assertCaptured "-----> Setting version to \"beta\"."
81-
assertCaptured "-----> Compiling Application."
91+
assertCaptured "-----> Fetching multirust"
92+
assertCaptured "-----> Setting version to \"beta\""
93+
assertCaptured "-----> No cached crates detected"
94+
assertCaptured "-----> Compiling application"
95+
assertCaptured "-----> Caching build artifacts"
8296

8397
cleanup
8498
}
@@ -93,9 +107,11 @@ EOF
93107

94108
compile
95109

96-
assertCaptured "-----> Fetching multirust."
97-
assertCaptured "-----> Setting version to \"stable\"."
98-
assertCaptured "-----> Compiling Application."
110+
assertCaptured "-----> Fetching multirust"
111+
assertCaptured "-----> Setting version to \"stable\""
112+
assertCaptured "-----> No cached crates detected"
113+
assertCaptured "-----> Compiling application"
114+
assertCaptured "-----> Caching build artifacts"
99115

100116
cleanup
101117
}

0 commit comments

Comments
 (0)