Skip to content

Commit 7d2130a

Browse files
committed
---
yaml --- r: 8124 b: refs/heads/snap-stage3 c: 93450ab h: refs/heads/master v: v3
1 parent 7772db7 commit 7d2130a

File tree

19 files changed

+329
-287
lines changed

19 files changed

+329
-287
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 2898dcc5d97da9427ac367542382b6239d9c0bbf
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 5131216fa6826509bb31672e5fde15b18eeff5d7
4+
refs/heads/snap-stage3: 93450abb4bf6a755b343ca459bbeff92540a7822
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/snap-stage3/src/compiletest/common.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,3 @@ type config =
2828
runtool: option<str>,
2929
rustcflags: option<str>,
3030
verbose: bool};
31-
32-
type cx = {config: config, procsrv: procsrv::handle};

branches/snap-stage3/src/compiletest/compiletest.rs

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import comm::chan;
1717
import comm::send;
1818
import comm::recv;
1919

20-
import common::cx;
2120
import common::config;
2221
import common::mode_run_pass;
2322
import common::mode_run_fail;
@@ -113,10 +112,8 @@ fn mode_str(mode: mode) -> str {
113112

114113
fn run_tests(config: config) {
115114
let opts = test_opts(config);
116-
let cx = {config: config, procsrv: procsrv::mk()};
117-
let tests = make_tests(cx);
115+
let tests = make_tests(config);
118116
let res = test::run_tests_console(opts, tests);
119-
procsrv::close(cx.procsrv);
120117
if !res { fail "Some tests failed"; }
121118
}
122119

@@ -129,14 +126,14 @@ fn test_opts(config: config) -> test::test_opts {
129126
run_ignored: config.run_ignored}
130127
}
131128

132-
fn make_tests(cx: cx) -> [test::test_desc] {
133-
#debug("making tests from %s", cx.config.src_base);
129+
fn make_tests(config: config) -> [test::test_desc] {
130+
#debug("making tests from %s", config.src_base);
134131
let tests = [];
135-
for file: str in fs::list_dir(cx.config.src_base) {
132+
for file: str in fs::list_dir(config.src_base) {
136133
let file = file;
137134
#debug("inspecting file %s", file);
138-
if is_test(cx.config, file) {
139-
tests += [make_test(cx, file)]
135+
if is_test(config, file) {
136+
tests += [make_test(config, file)]
140137
}
141138
}
142139
ret tests;
@@ -162,12 +159,12 @@ fn is_test(config: config, testfile: str) -> bool {
162159
ret valid;
163160
}
164161

165-
fn make_test(cx: cx, testfile: str) ->
162+
fn make_test(config: config, testfile: str) ->
166163
test::test_desc {
167164
{
168-
name: make_test_name(cx.config, testfile),
169-
fn: make_test_closure(cx, testfile),
170-
ignore: header::is_test_ignored(cx.config, testfile),
165+
name: make_test_name(config, testfile),
166+
fn: make_test_closure(config, testfile),
167+
ignore: header::is_test_ignored(config, testfile),
171168
should_fail: false
172169
}
173170
}
@@ -176,24 +173,12 @@ fn make_test_name(config: config, testfile: str) -> str {
176173
#fmt["[%s] %s", mode_str(config.mode), testfile]
177174
}
178175

179-
fn make_test_closure(cx: cx, testfile: str) -> test::test_fn {
180-
let config = cx.config;
181-
let chan = cx.procsrv.chan;
176+
fn make_test_closure(config: config, testfile: str) -> test::test_fn {
182177
ret {||
183-
run_test_task(config, chan, testfile);
178+
runtest::run(config, copy testfile);
184179
};
185180
}
186181

187-
fn run_test_task(config: common::config,
188-
procsrv_chan: procsrv::reqchan,
189-
testfile: str) {
190-
191-
let procsrv = procsrv::from_chan(procsrv_chan);
192-
let cx = {config: config, procsrv: procsrv};
193-
194-
runtest::run(cx, copy testfile);
195-
}
196-
197182
// Local Variables:
198183
// fill-column: 78;
199184
// indent-tabs-mode: nil
Lines changed: 41 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,60 @@
1-
// So when running tests in parallel there's a potential race on environment
2-
// variables if we let each task spawn its own children - between the time the
3-
// environment is set and the process is spawned another task could spawn its
4-
// child process. Because of that we have to use a complicated scheme with a
5-
// dedicated server for spawning processes.
6-
7-
import std::generic_os::setenv;
8-
import std::generic_os::getenv;
9-
import std::os;
101
import std::run;
2+
import std::run::spawn_process;
113
import std::io;
4+
import std::os;
125
import io::writer_util;
13-
import comm::chan;
14-
import comm::port;
15-
import comm::send;
16-
import comm::recv;
176
import ctypes::{pid_t, fd_t};
187

19-
export handle;
20-
export mk;
21-
export from_chan;
228
export run;
23-
export close;
24-
export reqchan;
259

26-
type reqchan = chan<request>;
27-
28-
type handle =
29-
{task: option<(task::task, port<task::task_notification>)>,
30-
chan: reqchan};
31-
32-
enum request { exec([u8], [u8], [[u8]], chan<response>), stop, }
10+
#[cfg(target_os = "win32")]
11+
fn target_env(lib_path: str, prog: str) -> option<[(str,str)]> {
3312

34-
type response = {pid: pid_t, infd: fd_t,
35-
outfd: fd_t, errfd: fd_t};
13+
let env = std::generic_os::env();
3614

37-
fn mk() -> handle {
38-
let setupport = port();
39-
let setupchan = chan(setupport);
40-
let task = task::spawn_joinable {||
41-
let reqport = port();
42-
let reqchan = chan(reqport);
43-
send(setupchan, reqchan);
44-
worker(reqport);
15+
env = vec::map(env) {|pair|
16+
let (k,v) = pair;
17+
if k == "PATH" { ("PATH", v + ";" + lib_path) }
18+
else { (k,v) }
4519
};
46-
ret {task: option::some(task), chan: recv(setupport)};
20+
if str::ends_with(prog, "rustc.exe") {
21+
env += [("RUST_THREADS", "1")]
22+
}
23+
ret some(env);
4724
}
4825

49-
fn from_chan(ch: reqchan) -> handle { {task: option::none, chan: ch} }
50-
51-
fn close(handle: handle) {
52-
send(handle.chan, stop);
53-
task::join(option::get(handle.task));
26+
#[cfg(target_os = "linux")]
27+
#[cfg(target_os = "macos")]
28+
#[cfg(target_os = "freebsd")]
29+
fn target_env(lib_path: str, prog: str) -> option<[(str,str)]> {
30+
none
5431
}
5532

56-
fn run(handle: handle, lib_path: str, prog: str, args: [str],
33+
34+
fn run(lib_path: str, prog: str, args: [str],
5735
input: option<str>) -> {status: int, out: str, err: str} {
58-
let p = port();
59-
let ch = chan(p);
60-
send(handle.chan,
61-
exec(str::bytes(lib_path), str::bytes(prog), clone_vecstr(args),
62-
ch));
63-
let resp = recv(p);
6436

65-
writeclose(resp.infd, input);
66-
let output = readclose(resp.outfd);
67-
let errput = readclose(resp.errfd);
68-
let status = run::waitpid(resp.pid);
37+
let pipe_in = os::pipe();
38+
let pipe_out = os::pipe();
39+
let pipe_err = os::pipe();
40+
let pid = spawn_process(prog, args, target_env(lib_path, prog), none,
41+
pipe_in.in, pipe_out.out, pipe_err.out);
42+
43+
os::close(pipe_in.in);
44+
os::close(pipe_out.out);
45+
os::close(pipe_err.out);
46+
if pid == -1i32 {
47+
os::close(pipe_in.out);
48+
os::close(pipe_out.in);
49+
os::close(pipe_err.in);
50+
fail;
51+
}
52+
53+
54+
writeclose(pipe_in.out, input);
55+
let output = readclose(pipe_out.in);
56+
let errput = readclose(pipe_err.in);
57+
let status = run::waitpid(pid);
6958
ret {status: status, out: output, err: errput};
7059
}
7160

@@ -90,106 +79,3 @@ fn readclose(fd: fd_t) -> str {
9079
os::fclose(file);
9180
ret buf;
9281
}
93-
94-
fn worker(p: port<request>) {
95-
96-
// FIXME (787): If we declare this inside of the while loop and then
97-
// break out of it before it's ever initialized (i.e. we don't run
98-
// any tests), then the cleanups will puke.
99-
let execparms;
100-
101-
while true {
102-
// FIXME: Sending strings across channels seems to still
103-
// leave them refed on the sender's end, which causes problems if
104-
// the receiver's poniters outlive the sender's. Here we clone
105-
// everything and let the originals go out of scope before sending
106-
// a response.
107-
execparms =
108-
{
109-
110-
// FIXME (785): The 'discriminant' of an alt expression has
111-
// the same scope as the alt expression itself, so we have to
112-
// put the entire alt in another block to make sure the exec
113-
// message goes out of scope. Seems like the scoping rules for
114-
// the alt discriminant are wrong.
115-
alt recv(p) {
116-
exec(lib_path, prog, args, respchan) {
117-
{lib_path: str::from_bytes(lib_path),
118-
prog: str::from_bytes(prog),
119-
args: clone_vecu8str(args),
120-
respchan: respchan}
121-
}
122-
stop { ret }
123-
}
124-
};
125-
126-
// This is copied from run::start_program
127-
let pipe_in = os::pipe();
128-
let pipe_out = os::pipe();
129-
let pipe_err = os::pipe();
130-
let spawnproc =
131-
bind run::spawn_process(execparms.prog, execparms.args,
132-
pipe_in.in, pipe_out.out, pipe_err.out);
133-
let pid = maybe_with_lib_path(execparms.lib_path, spawnproc);
134-
135-
os::close(pipe_in.in);
136-
os::close(pipe_out.out);
137-
os::close(pipe_err.out);
138-
if pid == -1i32 {
139-
os::close(pipe_in.out);
140-
os::close(pipe_out.in);
141-
os::close(pipe_err.in);
142-
fail;
143-
}
144-
145-
send(execparms.respchan,
146-
{pid: pid,
147-
infd: pipe_in.out,
148-
outfd: pipe_out.in,
149-
errfd: pipe_err.in});
150-
}
151-
}
152-
153-
// Only windows needs to set the library path
154-
#[cfg(target_os = "win32")]
155-
fn maybe_with_lib_path<T>(path: str, f: fn@() -> T) -> T {
156-
with_lib_path(path, f)
157-
}
158-
159-
#[cfg(target_os = "linux")]
160-
#[cfg(target_os = "macos")]
161-
#[cfg(target_os = "freebsd")]
162-
fn maybe_with_lib_path<T>(_path: str, f: fn@() -> T) -> T {
163-
f()
164-
}
165-
166-
fn with_lib_path<T>(path: str, f: fn@() -> T) -> T {
167-
let maybe_oldpath = getenv(util::lib_path_env_var());
168-
append_lib_path(path);
169-
let res = f();
170-
if option::is_some(maybe_oldpath) {
171-
export_lib_path(option::get(maybe_oldpath));
172-
} else {
173-
// FIXME: This should really be unset but we don't have that yet
174-
export_lib_path("");
175-
}
176-
ret res;
177-
}
178-
179-
fn append_lib_path(path: str) { export_lib_path(util::make_new_path(path)); }
180-
181-
fn export_lib_path(path: str) { setenv(util::lib_path_env_var(), path); }
182-
183-
fn clone_vecstr(v: [str]) -> [[u8]] {
184-
let r = [];
185-
for t: str in vec::slice(v, 0u, vec::len(v)) { r += [str::bytes(t)]; }
186-
ret r;
187-
}
188-
189-
fn clone_vecu8str(v: [[u8]]) -> [str] {
190-
let r = [];
191-
for t in vec::slice(v, 0u, vec::len(v)) {
192-
r += [str::from_bytes(t)];
193-
}
194-
ret r;
195-
}

0 commit comments

Comments
 (0)