Skip to content

Commit 99e91a6

Browse files
committed
---
yaml --- r: 82175 b: refs/heads/master c: 8ba148b h: refs/heads/master i: 82173: 57b7ec1 82171: 8c84e7e 82167: df211f6 82159: b17a15a 82143: f3279c9 82111: c5911d8 82047: 7f01f0b 81919: 274cca6 v: v3
1 parent 924e95b commit 99e91a6

File tree

4 files changed

+56
-4
lines changed

4 files changed

+56
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 0114ab631dadaa05f04b5bad89cfc08e673b8c4f
2+
refs/heads/master: 8ba148b295bfaf6198ce4ce34c9eb6b93346c092
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6c08cc2db4f98e9f07ae7d50338396c4123c2f0a
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729

trunk/doc/tutorial-rustpkg.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,54 @@ note: Installed package github.com/YOUR_USERNAME/hello-0.1 to /home/yourusername
206206

207207
That's it!
208208

209+
# Testing your Package
210+
211+
Testing your package is simple as well. First, let's change `src/hello/lib.rs` to contain
212+
a function that can be sensibly tested:
213+
214+
~~~
215+
#[desc = "A Rust package for determining whether unsigned integers are even."];
216+
#[license = "MIT"];
217+
218+
pub fn is_even(i: uint) -> bool {
219+
i % 2 == 0
220+
}
221+
~~~
222+
223+
Once you've edited `lib.rs`, you can create a second crate file, `src/hello/test.rs`,
224+
to put tests in:
225+
226+
~~~
227+
#[license = "MIT"];
228+
extern mod hello;
229+
use hello::is_even;
230+
231+
#[test]
232+
fn test_is_even() {
233+
assert!(is_even(0));
234+
assert!(!is_even(1));
235+
assert!(is_even(2));
236+
}
237+
~~~
238+
239+
Note that you have to import the crate you just created in `lib.rs` with the
240+
`extern mod hello` directive. That's because you're putting the tests in a different
241+
crate from the main library that you created.
242+
243+
Now, you can use the `rustpkg test` command to build this test crate (and anything else
244+
it depends on) and run the tests, all in one step:
245+
246+
~~~ {.notrust}
247+
$ rustpkg test hello
248+
WARNING: The Rust package manager is experimental and may be unstable
249+
note: Installed package hello-0.1 to /Users/tjc/.rust
250+
251+
running 1 test
252+
test test_is_even ... ok
253+
254+
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
255+
~~~
256+
209257
# More resources
210258

211259
There's a lot more going on with `rustpkg`, this is just to get you started.

trunk/src/librustc/middle/typeck/check/regionmanip.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ pub fn replace_bound_regions_in_fn_sig(
3232
{
3333
let mut all_tys = ty::tys_in_fn_sig(fn_sig);
3434

35+
for &self_ty in opt_self_ty.iter() {
36+
all_tys.push(self_ty);
37+
}
38+
3539
for &t in opt_self_ty.iter() { all_tys.push(t) }
3640

3741
debug2!("replace_bound_regions_in_fn_sig(self_ty={:?}, fn_sig={}, \

trunk/src/librustpkg/usage.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ information.");
141141
pub fn test() {
142142
io::println("rustpkg [options..] test
143143
144-
Build all targets described in the package script in the current directory
145-
with the test flag. The test bootstraps will be run afterwards and the output
146-
and exit code will be redirected.
144+
Build all test crates in the current directory with the test flag.
145+
Then, run all the resulting test executables, redirecting the output
146+
and exit code.
147147
148148
Options:
149149
-c, --cfg Pass a cfg flag to the package script");

0 commit comments

Comments
 (0)