Skip to content

Commit f1912b5

Browse files
committed
---
yaml --- r: 83635 b: refs/heads/try c: bbbafc4 h: refs/heads/master i: 83633: 3ddcf68 83631: 955fc06 v: v3
1 parent c9404b3 commit f1912b5

File tree

4 files changed

+143
-232
lines changed

4 files changed

+143
-232
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 0e4d1fc8cae42e15e00f71d9f439b01bb25a86ae
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6c08cc2db4f98e9f07ae7d50338396c4123c2f0a
5-
refs/heads/try: 88b0b511beed1599c5bddaf05b9cd0f98bd714ca
5+
refs/heads/try: bbbafc4e466e8026d30b9c47d1f104fd44815bef
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libstd/rt/io/process.rs

Lines changed: 142 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,145 @@ impl Drop for Process {
140140
}
141141
}
142142

143-
// Tests for this module can be found in the rtio-processes run-pass test, along
144-
// with the justification for why it's not located here.
143+
#[cfg(test)]
144+
mod tests {
145+
use prelude::*;
146+
use super::*;
147+
148+
use rt::io::{Reader, Writer};
149+
use rt::io::pipe::*;
150+
use str;
151+
152+
#[test]
153+
#[cfg(unix, not(android))]
154+
#[ignore] // FIXME(#9341)
155+
fn smoke() {
156+
let io = ~[];
157+
let args = ProcessConfig {
158+
program: "/bin/sh",
159+
args: [~"-c", ~"true"],
160+
env: None,
161+
cwd: None,
162+
io: io,
163+
};
164+
let p = Process::new(args);
165+
assert!(p.is_some());
166+
let mut p = p.unwrap();
167+
assert_eq!(p.wait(), 0);
168+
}
169+
170+
#[test]
171+
#[cfg(unix, not(android))]
172+
#[ignore] // FIXME(#9341)
173+
fn smoke_failure() {
174+
let io = ~[];
175+
let args = ProcessConfig {
176+
program: "if-this-is-a-binary-then-the-world-has-ended",
177+
args: [],
178+
env: None,
179+
cwd: None,
180+
io: io,
181+
};
182+
let p = Process::new(args);
183+
assert!(p.is_some());
184+
let mut p = p.unwrap();
185+
assert!(p.wait() != 0);
186+
}
187+
188+
#[test]
189+
#[cfg(unix, not(android))]
190+
#[ignore] // FIXME(#9341)
191+
fn exit_reported_right() {
192+
let io = ~[];
193+
let args = ProcessConfig {
194+
program: "/bin/sh",
195+
args: [~"-c", ~"exit 1"],
196+
env: None,
197+
cwd: None,
198+
io: io,
199+
};
200+
let p = Process::new(args);
201+
assert!(p.is_some());
202+
let mut p = p.unwrap();
203+
assert_eq!(p.wait(), 1);
204+
}
205+
206+
fn read_all(input: &mut Reader) -> ~str {
207+
let mut ret = ~"";
208+
let mut buf = [0, ..1024];
209+
loop {
210+
match input.read(buf) {
211+
None | Some(0) => { break }
212+
Some(n) => { ret = ret + str::from_utf8(buf.slice_to(n)); }
213+
}
214+
}
215+
return ret;
216+
}
217+
218+
fn run_output(args: ProcessConfig) -> ~str {
219+
let p = Process::new(args);
220+
assert!(p.is_some());
221+
let mut p = p.unwrap();
222+
assert!(p.io[0].is_none());
223+
assert!(p.io[1].is_some());
224+
let ret = read_all(p.io[1].get_mut_ref() as &mut Reader);
225+
assert_eq!(p.wait(), 0);
226+
return ret;
227+
}
228+
229+
#[test]
230+
#[cfg(unix, not(android))]
231+
#[ignore] // FIXME(#9341)
232+
fn stdout_works() {
233+
let pipe = PipeStream::new().unwrap();
234+
let io = ~[Ignored, CreatePipe(pipe, false, true)];
235+
let args = ProcessConfig {
236+
program: "/bin/sh",
237+
args: [~"-c", ~"echo foobar"],
238+
env: None,
239+
cwd: None,
240+
io: io,
241+
};
242+
assert_eq!(run_output(args), ~"foobar\n");
243+
}
244+
245+
#[test]
246+
#[cfg(unix, not(android))]
247+
#[ignore] // FIXME(#9341)
248+
fn set_cwd_works() {
249+
let pipe = PipeStream::new().unwrap();
250+
let io = ~[Ignored, CreatePipe(pipe, false, true)];
251+
let cwd = Some("/");
252+
let args = ProcessConfig {
253+
program: "/bin/sh",
254+
args: [~"-c", ~"pwd"],
255+
env: None,
256+
cwd: cwd,
257+
io: io,
258+
};
259+
assert_eq!(run_output(args), ~"/\n");
260+
}
261+
262+
#[test]
263+
#[cfg(unix, not(android))]
264+
#[ignore] // FIXME(#9341)
265+
fn stdin_works() {
266+
let input = PipeStream::new().unwrap();
267+
let output = PipeStream::new().unwrap();
268+
let io = ~[CreatePipe(input, true, false),
269+
CreatePipe(output, false, true)];
270+
let args = ProcessConfig {
271+
program: "/bin/sh",
272+
args: [~"-c", ~"read line; echo $line"],
273+
env: None,
274+
cwd: None,
275+
io: io,
276+
};
277+
let mut p = Process::new(args).expect("didn't create a proces?!");
278+
p.io[0].get_mut_ref().write("foobar".as_bytes());
279+
p.io[0] = None; // close stdin;
280+
let out = read_all(p.io[1].get_mut_ref() as &mut Reader);
281+
assert_eq!(p.wait(), 0);
282+
assert_eq!(out, ~"foobar\n");
283+
}
284+
}

branches/try/src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -185,79 +185,6 @@ pub fn add_new_extension(cx: @ExtCtxt,
185185
_ => cx.span_bug(sp, "wrong-structured rhs")
186186
};
187187

188-
// Given `lhses` and `rhses`, this is the new macro we create
189-
fn generic_extension(cx: @ExtCtxt,
190-
sp: Span,
191-
name: Ident,
192-
arg: &[ast::token_tree],
193-
lhses: &[@named_match],
194-
rhses: &[@named_match])
195-
-> MacResult {
196-
if cx.trace_macros() {
197-
println!("{}! \\{ {} \\}",
198-
cx.str_of(name),
199-
print::pprust::tt_to_str(
200-
&ast::tt_delim(@mut arg.to_owned()),
201-
get_ident_interner()));
202-
}
203-
204-
// Which arm's failure should we report? (the one furthest along)
205-
let mut best_fail_spot = dummy_sp();
206-
let mut best_fail_msg = ~"internal error: ran no matchers";
207-
208-
let s_d = cx.parse_sess().span_diagnostic;
209-
210-
for (i, lhs) in lhses.iter().enumerate() { // try each arm's matchers
211-
match *lhs {
212-
@matched_nonterminal(nt_matchers(ref mtcs)) => {
213-
// `none` is because we're not interpolating
214-
let arg_rdr = new_tt_reader(
215-
s_d,
216-
None,
217-
arg.to_owned()
218-
) as @mut reader;
219-
match parse(cx.parse_sess(), cx.cfg(), arg_rdr, *mtcs) {
220-
success(named_matches) => {
221-
let rhs = match rhses[i] {
222-
// okay, what's your transcriber?
223-
@matched_nonterminal(nt_tt(@ref tt)) => {
224-
match (*tt) {
225-
// cut off delimiters; don't parse 'em
226-
tt_delim(ref tts) => {
227-
(*tts).slice(1u,(*tts).len()-1u).to_owned()
228-
}
229-
_ => cx.span_fatal(
230-
sp, "macro rhs must be delimited")
231-
}
232-
},
233-
_ => cx.span_bug(sp, "bad thing in rhs")
234-
};
235-
// rhs has holes ( `$id` and `$(...)` that need filled)
236-
let trncbr = new_tt_reader(s_d, Some(named_matches),
237-
rhs);
238-
let p = @Parser(cx.parse_sess(),
239-
cx.cfg(),
240-
trncbr as @mut reader);
241-
242-
// Let the context choose how to interpret the result.
243-
// Weird, but useful for X-macros.
244-
return MRAny(@ParserAnyMacro {
245-
parser: p
246-
} as @AnyMacro);
247-
}
248-
failure(sp, ref msg) => if sp.lo >= best_fail_spot.lo {
249-
best_fail_spot = sp;
250-
best_fail_msg = (*msg).clone();
251-
},
252-
error(sp, ref msg) => cx.span_fatal(sp, (*msg))
253-
}
254-
}
255-
_ => cx.bug("non-matcher found in parsed lhses")
256-
}
257-
}
258-
cx.span_fatal(best_fail_spot, best_fail_msg);
259-
}
260-
261188
let exp = @MacroRulesSyntaxExpanderTTFun {
262189
name: name,
263190
lhses: lhses,

branches/try/src/test/run-pass/rtio-processes.rs

Lines changed: 0 additions & 156 deletions
This file was deleted.

0 commit comments

Comments
 (0)