Skip to content

Commit 043ef01

Browse files
committed
---
yaml --- r: 100859 b: refs/heads/snap-stage3 c: 615536a h: refs/heads/master i: 100857: 0b02b05 100855: 7c568d5 v: v3
1 parent 5c4fc5d commit 043ef01

File tree

24 files changed

+106
-159
lines changed

24 files changed

+106
-159
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: e3b1f3c443c048913e2d573fcc5a9c2be3484a78
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 49ba513c78e6430e55e5478f478a157e085a639a
4+
refs/heads/snap-stage3: 615536a265124550cc94b6c66c64bdb6752391f1
55
refs/heads/try: a97642026c18a624ff6ea01075dd9550f8ed07ff
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/mk/platform.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ CFG_GCCISH_DEF_FLAG_arm-unknown-linux-gnueabi := -Wl,--export-dynamic,--dynamic-
350350
CFG_GCCISH_PRE_LIB_FLAGS_arm-unknown-linux-gnueabi := -Wl,-whole-archive
351351
CFG_GCCISH_POST_LIB_FLAGS_arm-unknown-linux-gnueabi := -Wl,-no-whole-archive
352352
CFG_DEF_SUFFIX_arm-unknown-linux-gnueabi := .linux.def
353-
CFG_LLC_FLAGS_arm-unknown-linux-gnueabi := -arm-enable-ehabi -arm-enable-ehabi-descriptors
353+
CFG_LLC_FLAGS_arm-unknown-linux-gnueabi :=
354354
CFG_INSTALL_NAME_arm-unknown-linux-gnueabi =
355355
CFG_LIBUV_LINK_FLAGS_arm-unknown-linux-gnueabi =
356356
CFG_EXE_SUFFIX_arm-unknown-linux-gnueabi :=

branches/snap-stage3/src/doc/rustdoc.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,29 +100,34 @@ rustdoc --test crate.rs
100100

101101
## Defining tests
102102

103-
Rust documentation currently uses the markdown format, and rustdoc treats all
104-
code blocks as testable-by-default. In order to not run a test over a block of
105-
code, the `ignore` string can be added to the three-backtick form of markdown
106-
code block.
103+
Rust documentation currently uses the markdown format, and code blocks can refer
104+
to any piece of code-related documentation, which isn't always rust. Because of
105+
this, only code blocks with the language of "rust" will be considered for
106+
testing.
107107

108108
~~~
109-
```
109+
```rust
110110
// This is a testable code block
111111
```
112112
113-
```ignore
113+
```
114114
// This is not a testable code block
115115
```
116116
117-
// This is a testable code block (4-space indent)
117+
// This is not a testable code block (4-space indent)
118118
~~~
119119

120-
In addition to the `ignore` directive, you can specify that the test's execution
121-
should fail with the `should_fail` directive.
120+
In addition to only testing "rust"-language code blocks, there are additional
121+
specifiers that can be used to dictate how a code block is tested:
122122

123123
~~~
124-
```should_fail
125-
// This code block is expected to generate a failure when run
124+
```rust,ignore
125+
// This code block is ignored by rustdoc, but is passed through to the test
126+
// harness
127+
```
128+
129+
```rust,should_fail
130+
// This code block is expected to generate a failure
126131
```
127132
~~~
128133

@@ -138,7 +143,7 @@ that one can still write things like `#[deriving(Eq)]`).
138143
# the doc-generating tool. In order to display them anyway in this particular
139144
# case, the character following the leading '#' is not a usual space like in
140145
# these first five lines but a non breakable one.
141-
#
146+
#
142147
# // showing 'fib' in this documentation would just be tedious and detracts from
143148
# // what's actualy being documented.
144149
# fn fib(n: int) { n + 2 }
@@ -164,6 +169,9 @@ rustdoc --test lib.rs --test-args 'foo'
164169
165170
// See what's possible when running tests
166171
rustdoc --test lib.rs --test-args '--help'
172+
173+
// Run all ignored tests
174+
rustdoc --test lib.rs --test-args '--ignored'
167175
~~~
168176

169177
When testing a library, code examples will often show how functions are used,

branches/snap-stage3/src/libextra/json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ An object is a series of string keys mapping to values, in `"key": value` format
3030
Arrays are enclosed in square brackets ([ ... ]) and objects in curly brackets ({ ... }).
3131
A simple JSON document encoding a person, his/her age, address and phone numbers could look like:
3232
33-
```ignore
33+
```
3434
{
3535
"FirstName": "John",
3636
"LastName": "Doe",

branches/snap-stage3/src/libextra/stats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ pub fn write_5_number_summary(w: &mut io::Writer,
341341
/// As an example, the summary with 5-number-summary `(min=15, q1=17, med=20, q3=24, max=31)` might
342342
/// display as:
343343
///
344-
/// ~~~~ignore
344+
/// ~~~~
345345
/// 10 | [--****#******----------] | 40
346346
/// ~~~~
347347

branches/snap-stage3/src/libglob/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub struct Paths {
6767
///
6868
/// The above code will print:
6969
///
70-
/// ```ignore
70+
/// ```
7171
/// /media/pictures/kittens.jpg
7272
/// /media/pictures/puppies.jpg
7373
/// ```

branches/snap-stage3/src/librustdoc/html/markdown.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,23 +172,21 @@ pub fn render(w: &mut io::Writer, s: &str) -> fmt::Result {
172172
pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
173173
extern fn block(_ob: *buf, text: *buf, lang: *buf, opaque: *libc::c_void) {
174174
unsafe {
175-
if text.is_null() { return }
176-
let (shouldfail, ignore) = if lang.is_null() {
177-
(false, false)
178-
} else {
175+
if text.is_null() || lang.is_null() { return }
176+
let (test, shouldfail, ignore) =
179177
vec::raw::buf_as_slice((*lang).data,
180178
(*lang).size as uint, |lang| {
181179
let s = str::from_utf8(lang).unwrap();
182-
(s.contains("should_fail"), s.contains("ignore"))
183-
})
184-
};
185-
if ignore { return }
180+
(s.contains("rust"), s.contains("should_fail"),
181+
s.contains("ignore"))
182+
});
183+
if !test { return }
186184
vec::raw::buf_as_slice((*text).data, (*text).size as uint, |text| {
187185
let tests: &mut ::test::Collector = intrinsics::transmute(opaque);
188186
let text = str::from_utf8(text).unwrap();
189187
let mut lines = text.lines().map(|l| stripped_filtered_line(l).unwrap_or(l));
190188
let text = lines.to_owned_vec().connect("\n");
191-
tests.add_test(text, shouldfail);
189+
tests.add_test(text, ignore, shouldfail);
192190
})
193191
}
194192
}

branches/snap-stage3/src/librustdoc/test.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub fn run(input: &str, matches: &getopts::Matches) -> int {
9494
0
9595
}
9696

97-
fn runtest(test: &str, cratename: &str, libs: HashSet<Path>, should_fail: bool) {
97+
fn runtest(test: &str, cratename: &str, libs: HashSet<Path>) {
9898
let test = maketest(test, cratename);
9999
let parsesess = parse::new_parse_sess();
100100
let input = driver::StrInput(test);
@@ -130,10 +130,9 @@ fn runtest(test: &str, cratename: &str, libs: HashSet<Path>, should_fail: bool)
130130
match out {
131131
Err(e) => fail!("couldn't run the test: {}", e),
132132
Ok(out) => {
133-
if should_fail && out.status.success() {
134-
fail!("test executable succeeded when it should have failed");
135-
} else if !should_fail && !out.status.success() {
136-
fail!("test executable failed:\n{}", str::from_utf8(out.error));
133+
if !out.status.success() {
134+
fail!("test executable failed:\n{}",
135+
str::from_utf8(out.error));
137136
}
138137
}
139138
}
@@ -170,7 +169,7 @@ pub struct Collector {
170169
}
171170

172171
impl Collector {
173-
pub fn add_test(&mut self, test: &str, should_fail: bool) {
172+
pub fn add_test(&mut self, test: &str, ignore: bool, should_fail: bool) {
174173
let test = test.to_owned();
175174
let name = format!("{}_{}", self.names.connect("::"), self.cnt);
176175
self.cnt += 1;
@@ -181,11 +180,11 @@ impl Collector {
181180
self.tests.push(test::TestDescAndFn {
182181
desc: test::TestDesc {
183182
name: test::DynTestName(name),
184-
ignore: false,
185-
should_fail: false, // compiler failures are test failures
183+
ignore: ignore,
184+
should_fail: should_fail,
186185
},
187186
testfn: test::DynTestFn(proc() {
188-
runtest(test, cratename, libs, should_fail);
187+
runtest(test, cratename, libs);
189188
}),
190189
});
191190
}

branches/snap-stage3/src/libstd/comm/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
//! let (port, chan) = Chan::new();
6262
//! spawn(proc() {
6363
//! chan.send(10);
64-
//! });
64+
//! })
6565
//! assert_eq!(port.recv(), 10);
6666
//!
6767
//! // Create a shared channel which can be sent along from many tasks

branches/snap-stage3/src/libstd/fmt/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function, but the `format!` macro is a syntax extension which allows it to
8282
leverage named parameters. Named parameters are listed at the end of the
8383
argument list and have the syntax:
8484
85-
```ignore
85+
```
8686
identifier '=' expression
8787
```
8888
@@ -107,7 +107,7 @@ and if all references to one argument do not provide a type, then the format `?`
107107
is used (the type's rust-representation is printed). For example, this is an
108108
invalid format string:
109109
110-
```ignore
110+
```
111111
{0:d} {0:s}
112112
```
113113
@@ -123,7 +123,7 @@ must have the type `uint`. Although a `uint` can be printed with `{:u}`, it is
123123
illegal to reference an argument as such. For example, this is another invalid
124124
format string:
125125
126-
```ignore
126+
```
127127
{:.*s} {0:u}
128128
```
129129
@@ -334,7 +334,7 @@ This example is the equivalent of `{0:s}` essentially.
334334
The select method is a switch over a `&str` parameter, and the parameter *must*
335335
be of the type `&str`. An example of the syntax is:
336336
337-
```ignore
337+
```
338338
{0, select, male{...} female{...} other{...}}
339339
```
340340
@@ -353,7 +353,7 @@ The plural method is a switch statement over a `uint` parameter, and the
353353
parameter *must* be a `uint`. A plural method in its full glory can be specified
354354
as:
355355
356-
```ignore
356+
```
357357
{0, plural, offset=1 =1{...} two{...} many{...} other{...}}
358358
```
359359
@@ -381,7 +381,7 @@ should not be too alien. Arguments are formatted with python-like syntax,
381381
meaning that arguments are surrounded by `{}` instead of the C-like `%`. The
382382
actual grammar for the formatting syntax is:
383383
384-
```ignore
384+
```
385385
format_string := <text> [ format <text> ] *
386386
format := '{' [ argument ] [ ':' format_spec ] [ ',' function_spec ] '}'
387387
argument := integer | identifier

branches/snap-stage3/src/libstd/io/comm_adapters.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,12 @@ use vec::{bytes, CloneableVector, MutableVector, ImmutableVector};
2222
/// # Example
2323
///
2424
/// ```
25-
/// use std::io::PortReader;
26-
///
27-
/// let (port, chan) = Chan::new();
28-
/// # drop(chan);
29-
/// let mut reader = PortReader::new(port);
25+
/// let reader = PortReader::new(port);
3026
///
3127
/// let mut buf = ~[0u8, ..100];
3228
/// match reader.read(buf) {
33-
/// Ok(nread) => println!("Read {} bytes", nread),
34-
/// Err(e) => println!("read error: {}", e),
29+
/// Some(nread) => println!("Read {} bytes", nread),
30+
/// None => println!("At the end of the stream!")
3531
/// }
3632
/// ```
3733
pub struct PortReader {
@@ -87,12 +83,7 @@ impl Reader for PortReader {
8783
/// # Example
8884
///
8985
/// ```
90-
/// # #[allow(unused_must_use)];
91-
/// use std::io::ChanWriter;
92-
///
93-
/// let (port, chan) = Chan::new();
94-
/// # drop(port);
95-
/// let mut writer = ChanWriter::new(chan);
86+
/// let writer = ChanWriter::new(chan);
9687
/// writer.write("hello, world".as_bytes());
9788
/// ```
9889
pub struct ChanWriter {

branches/snap-stage3/src/libstd/io/net/unix.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,15 @@ impl UnixListener {
9191
/// # Example
9292
///
9393
/// ```
94-
/// # fn main() {}
95-
/// # fn foo() {
96-
/// # #[allow(unused_must_use)];
9794
/// use std::io::net::unix::UnixListener;
98-
/// use std::io::{Listener, Acceptor};
95+
/// use std::io::Listener;
9996
///
100-
/// let server = Path::new("/path/to/my/socket");
101-
/// let stream = UnixListener::bind(&server);
102-
/// for mut client in stream.listen().incoming() {
97+
/// let server = Path::new("path/to/my/socket");
98+
/// let mut stream = UnixListener::bind(&server);
99+
/// for client in stream.incoming() {
100+
/// let mut client = client;
103101
/// client.write([1, 2, 3, 4]);
104102
/// }
105-
/// # }
106103
/// ```
107104
pub fn bind<P: ToCStr>(path: &P) -> IoResult<UnixListener> {
108105
LocalIo::maybe_raise(|io| {

branches/snap-stage3/src/libstd/io/util.rs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,7 @@ impl<R: Reader> LimitReader<R> {
2424
pub fn new(r: R, limit: uint) -> LimitReader<R> {
2525
LimitReader { limit: limit, inner: r }
2626
}
27-
28-
/// Consumes the `LimitReader`, returning the underlying `Reader`.
2927
pub fn unwrap(self) -> R { self.inner }
30-
31-
/// Returns the number of bytes that can be read before the `LimitReader`
32-
/// will return EOF.
33-
///
34-
/// # Note
35-
///
36-
/// The reader may reach EOF after reading fewer bytes than indicated by
37-
/// this method if the underlying reader reaches EOF.
38-
pub fn limit(&self) -> uint { self.limit }
3928
}
4029

4130
impl<R: Reader> Reader for LimitReader<R> {
@@ -201,7 +190,7 @@ mod test {
201190
use prelude::*;
202191

203192
#[test]
204-
fn test_limit_reader_unlimited() {
193+
fn test_bounded_reader_unlimited() {
205194
let mut r = MemReader::new(~[0, 1, 2]);
206195
{
207196
let mut r = LimitReader::new(r.by_ref(), 4);
@@ -210,7 +199,7 @@ mod test {
210199
}
211200

212201
#[test]
213-
fn test_limit_reader_limited() {
202+
fn test_bound_reader_limited() {
214203
let mut r = MemReader::new(~[0, 1, 2]);
215204
{
216205
let mut r = LimitReader::new(r.by_ref(), 2);
@@ -219,17 +208,6 @@ mod test {
219208
assert_eq!(~[2], r.read_to_end().unwrap());
220209
}
221210

222-
#[test]
223-
fn test_limit_reader_limit() {
224-
let r = MemReader::new(~[0, 1, 2]);
225-
let mut r = LimitReader::new(r, 3);
226-
assert_eq!(3, r.limit());
227-
assert_eq!(0, r.read_byte().unwrap());
228-
assert_eq!(2, r.limit());
229-
assert_eq!(~[1, 2], r.read_to_end().unwrap());
230-
assert_eq!(0, r.limit());
231-
}
232-
233211
#[test]
234212
fn test_null_writer() {
235213
let mut s = NullWriter;

branches/snap-stage3/src/libstd/kinds.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ pub mod marker {
6969
/// Given a struct `S` that includes a type parameter `T`
7070
/// but does not actually *reference* that type parameter:
7171
///
72-
/// ```ignore
73-
/// use std::cast;
74-
///
72+
/// ```
7573
/// struct S<T> { x: *() }
7674
/// fn get<T>(s: &S<T>) -> T {
7775
/// unsafe {
@@ -111,8 +109,6 @@ pub mod marker {
111109
/// but does not actually *reference* that type parameter:
112110
///
113111
/// ```
114-
/// use std::cast;
115-
///
116112
/// struct S<T> { x: *() }
117113
/// fn get<T>(s: &S<T>, v: T) {
118114
/// unsafe {
@@ -151,8 +147,7 @@ pub mod marker {
151147
/// "interior" mutability:
152148
///
153149
/// ```
154-
/// pub struct Cell<T> { priv value: T }
155-
/// # fn main() {}
150+
/// struct Cell<T> { priv value: T }
156151
/// ```
157152
///
158153
/// The type system would infer that `value` is only read here and

0 commit comments

Comments
 (0)