Skip to content

Commit edfb546

Browse files
committed
auto merge of #11490 : wting/rust/wting_11362_update_extract_tests, r=alexcrichton
Refactored the file quite a bit, I can add unit tests if desired. There's a few changes from the previous version's behavior: - destination directory will be created if it doesn't exist - strings and file is written as unicode I have a few questions, but will ask them in #11362.
2 parents c6bd053 + 9f60e7c commit edfb546

18 files changed

+338
-213
lines changed

AUTHORS.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ Vincent Belliard <[email protected]>
351351
Vivek Galatage <[email protected]>
352352
Volker Mische <[email protected]>
353353
Wade Mealing <[email protected]>
354-
William Ting <william.h.ting@gmail.com>
354+
William Ting <io@williamting.com>
355355
Yasuhiro Fujii <[email protected]>
356356
Young-il Choi <[email protected]>
357357
Youngmin Yoo <[email protected]>

doc/complement-cheatsheet.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ let y: i64 = x.unwrap();
4848

4949
Use [`File::open`](http://static.rust-lang.org/doc/master/std/io/fs/struct.File.html#method.open) to create a [`File`](http://static.rust-lang.org/doc/master/std/io/fs/struct.File.html) struct, which implements the [`Reader`](http://static.rust-lang.org/doc/master/std/io/trait.Reader.html) trait.
5050

51-
~~~ {.xfail-test}
51+
~~~ {.ignore}
5252
use std::path::Path;
5353
use std::io::fs::File;
5454
@@ -168,7 +168,7 @@ let _ = close(Door::<Open>(~"front"));
168168

169169
Attempting to close a closed door is prevented statically:
170170

171-
~~~ {.xfail-test}
171+
~~~ {.ignore}
172172
let _ = close(Door::<Closed>(~"front")); // error: mismatched types: expected `main::Door<main::Open>` but found `main::Door<main::Closed>`
173173
~~~
174174

@@ -196,7 +196,7 @@ Window* createWindow(int width, int height);
196196

197197
You can use a zero-element `enum` ([phantom type](#how-do-i-express-phantom-types)) to represent the opaque object handle. The FFI would look like this:
198198

199-
~~~ {.xfail-test}
199+
~~~ {.ignore}
200200
enum Window {}
201201
extern "C" {
202202
fn createWindow(width: c_int, height: c_int) -> *Window;

doc/guide-conditions.md

+1-8
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ An example program that does this task reads like this:
4545

4646
~~~~
4747
# #[allow(unused_imports)];
48-
# extern mod extra;
4948
use std::io::{BufferedReader, File};
5049
# mod BufferedReader {
5150
# use std::io::File;
@@ -243,7 +242,6 @@ and trapping its exit status using `task::try`:
243242

244243
~~~~
245244
# #[allow(unused_imports)];
246-
# extern mod extra;
247245
use std::io::{BufferedReader, File};
248246
use std::task;
249247
# mod BufferedReader {
@@ -347,7 +345,6 @@ but similarly clear as the version that used `fail!` in the logic where the erro
347345

348346
~~~~
349347
# #[allow(unused_imports)];
350-
# extern mod extra;
351348
use std::io::{BufferedReader, File};
352349
# mod BufferedReader {
353350
# use std::io::File;
@@ -416,7 +413,6 @@ and replaces bad input lines with the pair `(-1,-1)`:
416413

417414
~~~~
418415
# #[allow(unused_imports)];
419-
# extern mod extra;
420416
use std::io::{BufferedReader, File};
421417
# mod BufferedReader {
422418
# use std::io::File;
@@ -491,7 +487,6 @@ Changing the condition's return type from `(int,int)` to `Option<(int,int)>` wil
491487

492488
~~~~
493489
# #[allow(unused_imports)];
494-
# extern mod extra;
495490
use std::io::{BufferedReader, File};
496491
# mod BufferedReader {
497492
# use std::io::File;
@@ -576,8 +571,7 @@ This can be encoded in the handler API by introducing a helper type: `enum Malfo
576571

577572
~~~~
578573
# #[allow(unused_imports)];
579-
# extern mod extra;
580-
use std::io::File;
574+
use std::io::{BufferedReader, File};
581575
# mod BufferedReader {
582576
# use std::io::File;
583577
# use std::io::MemReader;
@@ -700,7 +694,6 @@ a second condition and a helper function will suffice:
700694

701695
~~~~
702696
# #[allow(unused_imports)];
703-
# extern mod extra;
704697
use std::io::{BufferedReader, File};
705698
# mod BufferedReader {
706699
# use std::io::File;

doc/guide-container.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ Containers can provide conversion from iterators through `collect` by
270270
implementing the `FromIterator` trait. For example, the implementation for
271271
vectors is as follows:
272272
273-
~~~ {.xfail-test}
273+
~~~ {.ignore}
274274
impl<A> FromIterator<A> for ~[A] {
275275
pub fn from_iterator<T: Iterator<A>>(iterator: &mut T) -> ~[A] {
276276
let (lower, _) = iterator.size_hint();
@@ -288,7 +288,7 @@ impl<A> FromIterator<A> for ~[A] {
288288
The `Iterator` trait provides a `size_hint` default method, returning a lower
289289
bound and optionally on upper bound on the length of the iterator:
290290

291-
~~~ {.xfail-test}
291+
~~~ {.ignore}
292292
fn size_hint(&self) -> (uint, Option<uint>) { (0, None) }
293293
~~~
294294

doc/guide-ffi.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ snappy includes a C interface (documented in
1111
The following is a minimal example of calling a foreign function which will
1212
compile if snappy is installed:
1313

14-
~~~~ {.xfail-test}
14+
~~~~ {.ignore}
1515
use std::libc::size_t;
1616
1717
#[link(name = "snappy")]
@@ -43,7 +43,7 @@ keeping the binding correct at runtime.
4343

4444
The `extern` block can be extended to cover the entire snappy API:
4545

46-
~~~~ {.xfail-test}
46+
~~~~ {.ignore}
4747
use std::libc::{c_int, size_t};
4848
4949
#[link(name = "snappy")]
@@ -76,7 +76,7 @@ vectors as pointers to memory. Rust's vectors are guaranteed to be a contiguous
7676
length is number of elements currently contained, and the capacity is the total size in elements of
7777
the allocated memory. The length is less than or equal to the capacity.
7878

79-
~~~~ {.xfail-test}
79+
~~~~ {.ignore}
8080
pub fn validate_compressed_buffer(src: &[u8]) -> bool {
8181
unsafe {
8282
snappy_validate_compressed_buffer(src.as_ptr(), src.len() as size_t) == 0
@@ -96,7 +96,7 @@ required capacity to hold the compressed output. The vector can then be passed t
9696
`snappy_compress` function as an output parameter. An output parameter is also passed to retrieve
9797
the true length after compression for setting the length.
9898

99-
~~~~ {.xfail-test}
99+
~~~~ {.ignore}
100100
pub fn compress(src: &[u8]) -> ~[u8] {
101101
unsafe {
102102
let srclen = src.len() as size_t;
@@ -116,7 +116,7 @@ pub fn compress(src: &[u8]) -> ~[u8] {
116116
Decompression is similar, because snappy stores the uncompressed size as part of the compression
117117
format and `snappy_uncompressed_length` will retrieve the exact buffer size required.
118118

119-
~~~~ {.xfail-test}
119+
~~~~ {.ignore}
120120
pub fn uncompress(src: &[u8]) -> Option<~[u8]> {
121121
unsafe {
122122
let srclen = src.len() as size_t;
@@ -263,7 +263,7 @@ to the C library and afterwards be invoked from there.
263263
A basic example is:
264264

265265
Rust code:
266-
~~~~ {.xfail-test}
266+
~~~~ {.ignore}
267267
extern fn callback(a:i32) {
268268
println!("I'm called from C with value {0}", a);
269269
}
@@ -283,7 +283,7 @@ fn main() {
283283
~~~~
284284

285285
C code:
286-
~~~~ {.xfail-test}
286+
~~~~ {.ignore}
287287
typedef void (*rust_callback)(int32_t);
288288
rust_callback cb;
289289
@@ -314,7 +314,7 @@ the notification. This will allow the callback to unsafely access the
314314
referenced Rust object.
315315

316316
Rust code:
317-
~~~~ {.xfail-test}
317+
~~~~ {.ignore}
318318
319319
struct RustObject {
320320
a: i32,
@@ -346,7 +346,7 @@ fn main() {
346346
~~~~
347347

348348
C code:
349-
~~~~ {.xfail-test}
349+
~~~~ {.ignore}
350350
typedef void (*rust_callback)(int32_t);
351351
void* cb_target;
352352
rust_callback cb;
@@ -440,7 +440,7 @@ the `link_args` attribute. This attribute is applied to `extern` blocks and
440440
specifies raw flags which need to get passed to the linker when producing an
441441
artifact. An example usage would be:
442442

443-
~~~ {.xfail-test}
443+
~~~ {.ignore}
444444
#[link_args = "-foo -bar -baz"]
445445
extern {}
446446
~~~
@@ -476,7 +476,7 @@ Foreign APIs often export a global variable which could do something like track
476476
global state. In order to access these variables, you declare them in `extern`
477477
blocks with the `static` keyword:
478478

479-
~~~{.xfail-test}
479+
~~~{.ignore}
480480
use std::libc;
481481
482482
#[link(name = "readline")]
@@ -494,7 +494,7 @@ Alternatively, you may need to alter global state provided by a foreign
494494
interface. To do this, statics can be declared with `mut` so rust can mutate
495495
them.
496496

497-
~~~{.xfail-test}
497+
~~~{.ignore}
498498
use std::libc;
499499
use std::ptr;
500500

doc/guide-lifetimes.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ _as soon as its owning reference changes or goes out of
299299
scope_. Therefore, a program like this is illegal (and would be
300300
rejected by the compiler):
301301

302-
~~~ {.xfail-test}
302+
~~~ {.ignore}
303303
fn example3() -> int {
304304
let mut x = ~X {f: 3};
305305
let y = &x.f;
@@ -346,7 +346,7 @@ modify the previous example to introduce additional owned pointers
346346
and structs, and the compiler will still be able to detect possible
347347
mutations:
348348

349-
~~~ {.xfail-test}
349+
~~~ {.ignore}
350350
fn example3() -> int {
351351
struct R { g: int }
352352
struct S { f: ~R }
@@ -524,7 +524,7 @@ the compiler accepts the function `get_x()`.
524524
To emphasize this point, let’s look at a variation on the example, this
525525
time one that does not compile:
526526

527-
~~~ {.xfail-test}
527+
~~~ {.ignore}
528528
struct Point {x: f64, y: f64}
529529
fn get_x_sh(p: @Point) -> &f64 {
530530
&p.x // Error reported here

doc/guide-pointers.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn succ(x: &int) -> int { *x + 1 }
2121

2222
So I wrote this code to try it out:
2323

24-
~~~rust{.xfail-test}
24+
~~~rust{.ignore}
2525
fn main() {
2626
let number = 5;
2727
let succ_number = succ(number);
@@ -261,7 +261,7 @@ program is very large and complicated.
261261

262262
For example, let's say you're using an owned pointer, and you want to do this:
263263

264-
~~~rust{.xfail-test}
264+
~~~rust{.ignore}
265265
struct Point {
266266
x: int,
267267
y: int,
@@ -369,7 +369,7 @@ This theory is called 'region pointers,' and involve a concept called
369369
'lifetimes'. Here's the simple explanation: would you expect this code to
370370
compile?
371371

372-
~~~rust{.xfail-test}
372+
~~~rust{.ignore}
373373
fn main() {
374374
println!("{}", x);
375375
let x = 5;
@@ -398,7 +398,7 @@ Here, we're borrowing a pointer to `x` inside of the `if`. The compiler, however
398398
is able to determine that that pointer will go out of scope without `x` being
399399
mutated, and therefore, lets us pass. This wouldn't work:
400400

401-
~~~rust{.xfail-test}
401+
~~~rust{.ignore}
402402
fn main() {
403403
let mut x = ~5;
404404
if *x < 10 {

doc/guide-tasks.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ senders cannot use a single `Chan`, and multiple receivers cannot use a single
190190
`Port`. What if our example needed to compute multiple results across a number
191191
of tasks? The following program is ill-typed:
192192

193-
~~~ {.xfail-test}
193+
~~~ {.ignore}
194194
# use std::task::{spawn};
195195
# fn some_expensive_computation() -> int { 42 }
196196
let (port, chan) = Chan::new();
@@ -413,7 +413,7 @@ pattern-match on a result to check whether it's an `Ok` result with an `int`
413413
field (representing a successful result) or an `Err` result (representing
414414
termination with an error).
415415

416-
~~~{.xfail-test .linked-failure}
416+
~~~{.ignore .linked-failure}
417417
# use std::task;
418418
# fn some_condition() -> bool { false }
419419
# fn calculate_result() -> int { 0 }
@@ -463,7 +463,7 @@ that repeatedly receives a `uint` message, converts it to a string, and sends
463463
the string in response. The child terminates when it receives `0`.
464464
Here is the function that implements the child task:
465465

466-
~~~{.xfail-test .linked-failure}
466+
~~~{.ignore .linked-failure}
467467
# use extra::comm::DuplexStream;
468468
# use std::uint;
469469
fn stringifier(channel: &DuplexStream<~str, uint>) {
@@ -486,7 +486,7 @@ response itself is simply the stringified version of the received value,
486486
487487
Here is the code for the parent task:
488488
489-
~~~{.xfail-test .linked-failure}
489+
~~~{.ignore .linked-failure}
490490
# use std::task::spawn;
491491
# use std::uint;
492492
# use extra::comm::DuplexStream;

doc/po/ja/complement-cheatsheet.md.po

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ msgstr "## 演算子"
112112
#: doc/complement-cheatsheet.md:54
113113
#, fuzzy
114114
#| msgid "~~~~ use std::task::spawn;"
115-
msgid "~~~ {.xfail-test} use std::path::Path; use std::io::fs::File;"
115+
msgid "~~~ {.ignore} use std::path::Path; use std::io::fs::File;"
116116
msgstr ""
117117
"~~~~\n"
118118
"use std::task::spawn;"

doc/po/ja/guide-ffi.md.po

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ msgstr "[他言語間インターフェース (foreign function inferface)][ffi]
3434
#: doc/guide-ffi.md:16
3535
#, fuzzy
3636
#| msgid "~~~~ use std::task::spawn;"
37-
msgid "~~~~ {.xfail-test} use std::libc::size_t;"
37+
msgid "~~~~ {.ignore} use std::libc::size_t;"
3838
msgstr ""
3939
"~~~~\n"
4040
"use std::task::spawn;"
@@ -43,7 +43,7 @@ msgstr ""
4343
#: doc/guide-ffi.md:48
4444
#, fuzzy
4545
#| msgid "~~~~ use std::task::spawn;"
46-
msgid "~~~~ {.xfail-test} use std::libc::{c_int, size_t};"
46+
msgid "~~~~ {.ignore} use std::libc::{c_int, size_t};"
4747
msgstr ""
4848
"~~~~\n"
4949
"use std::task::spawn;"
@@ -67,7 +67,7 @@ msgstr ""
6767
#: doc/guide-ffi.md:344
6868
#, fuzzy
6969
#| msgid "~~~~ use std::task::spawn;"
70-
msgid "~~~{.xfail-test} use std::libc;"
70+
msgid "~~~{.ignore} use std::libc;"
7171
msgstr ""
7272
"~~~~\n"
7373
"use std::task::spawn;"
@@ -76,7 +76,7 @@ msgstr ""
7676
#: doc/guide-ffi.md:363
7777
#, fuzzy
7878
#| msgid "~~~~ use std::task::spawn;"
79-
msgid "~~~{.xfail-test} use std::libc; use std::ptr;"
79+
msgid "~~~{.ignore} use std::libc; use std::ptr;"
8080
msgstr ""
8181
"~~~~\n"
8282
"use std::task::spawn;"

doc/po/ja/guide-lifetimes.md.po

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ msgstr ""
6363
#. type: Plain text
6464
#: doc/guide-lifetimes.md:48
6565
#, fuzzy, no-wrap
66-
#| msgid "~~~~ {.xfail-test} # struct Point { x: f64, y: f64 } let mut mypoint = Point { x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };"
66+
#| msgid "~~~~ {.ignore} # struct Point { x: f64, y: f64 } let mut mypoint = Point { x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };"
6767
msgid ""
6868
"~~~\n"
6969
"# struct Point {x: f64, y: f64}\n"
@@ -72,7 +72,7 @@ msgid ""
7272
"let owned_box : ~Point = ~Point {x: 7.0, y: 9.0};\n"
7373
"~~~\n"
7474
msgstr ""
75-
"~~~~ {.xfail-test}\n"
75+
"~~~~ {.ignore}\n"
7676
"# struct Point { x: f64, y: f64 }\n"
7777
"let mut mypoint = Point { x: 1.0, y: 1.0 };\n"
7878
"let origin = Point { x: 0.0, y: 0.0 };"
@@ -123,7 +123,7 @@ msgstr ""
123123
#. type: Plain text
124124
#: doc/guide-lifetimes.md:82
125125
#, fuzzy, no-wrap
126-
#| msgid "~~~~ {.xfail-test} # struct Point { x: f64, y: f64 } let mut mypoint = Point { x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };"
126+
#| msgid "~~~~ {.ignore} # struct Point { x: f64, y: f64 } let mut mypoint = Point { x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };"
127127
msgid ""
128128
"~~~\n"
129129
"# struct Point {x: f64, y: f64}\n"
@@ -135,7 +135,7 @@ msgid ""
135135
"compute_distance(managed_box, owned_box);\n"
136136
"~~~\n"
137137
msgstr ""
138-
"~~~~ {.xfail-test}\n"
138+
"~~~~ {.ignore}\n"
139139
"# struct Point { x: f64, y: f64 }\n"
140140
"let mut mypoint = Point { x: 1.0, y: 1.0 };\n"
141141
"let origin = Point { x: 0.0, y: 0.0 };"

0 commit comments

Comments
 (0)