Skip to content

Commit 2bef260

Browse files
z0w0graydon
authored andcommitted
---
yaml --- r: 53151 b: refs/heads/dist-snap c: d4e71da h: refs/heads/master i: 53149: a56f28d 53147: 3511708 53143: 9f2c44f 53135: c3fe9df 53119: af0bb86 v: v3
1 parent d844999 commit 2bef260

File tree

2 files changed

+41
-20
lines changed

2 files changed

+41
-20
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: 44d4d6de762f3f9aae1fedcf454c66b79b3ad58d
10-
refs/heads/dist-snap: 15440f4236759cd4c65cb2ef7a7df3aac0c79ba7
10+
refs/heads/dist-snap: d4e71da6ca1cd6953f3a8698cca5e16a9aadf0eb
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustpkg/rustpkg.rc

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -222,20 +222,20 @@ impl PackageScript {
222222

223223
// Build the bootstrap and run a command
224224
// FIXME (#4432): Use workcache to only compile the script when changed
225-
fn run(cmd: ~str) -> int {
225+
fn run(cmd: ~str, test: bool) -> int {
226226
let work_dir = self.work_dir();
227227
let input = self.input;
228228
let sess = self.sess;
229229
let cfg = self.cfg;
230230
let crate = util::ready_crate(sess, self.crate);
231231
let outputs = driver::build_output_filenames(input, &Some(work_dir),
232232
&None, sess);
233-
let exe = work_dir.push(~"package" + util::exe_suffix());
233+
let exe = work_dir.push(~"pkg" + util::exe_suffix());
234234
let root = filesearch::get_rustpkg_sysroot().get().pop().pop();
235235

236236
driver::compile_rest(sess, cfg, driver::cu_parse,
237-
Some(outputs), Some(crate));
238-
run::run_program(exe.to_str(), ~[root.to_str(), cmd])
237+
Some(outputs), Some(crate));
238+
run::run_program(exe.to_str(), ~[root.to_str(), cmd, test.to_str()])
239239
}
240240

241241
fn hash() -> ~str {
@@ -338,10 +338,13 @@ impl Ctx {
338338
}
339339

340340
fn do_cmd(cmd: ~str) -> bool {
341-
if cmd == ~"build" {
342-
util::error(~"the build cmd is reserved");
341+
match cmd {
342+
~"build" | ~"test" => {
343+
util::error(~"that command cannot be manually called");
343344

344-
return false;
345+
return false;
346+
}
347+
_ => {}
345348
}
346349

347350
let cwd = &os::getcwd();
@@ -353,9 +356,9 @@ impl Ctx {
353356
return false;
354357
}
355358
};
356-
let status = script.run(cmd);
359+
let status = script.run(cmd, false);
357360

358-
if status == 1 {
361+
if status == 42 {
359362
util::error(~"no fns are listening for that cmd");
360363

361364
return false;
@@ -406,12 +409,16 @@ impl Ctx {
406409
// Build imperative crates
407410
os::change_dir(dir);
408411

409-
if script.custom && script.run(~"build") != 0 {
410-
util::error(
411-
fmt!("building %s v%s failed: custom build logic failed",
412-
script.name, script.vers.to_str()));
412+
if script.custom {
413+
let status = script.run(~"build", test);
413414

414-
return None;
415+
if status != 0 && status != 42 {
416+
util::error(
417+
fmt!("building %s v%s failed: custom logic failed (%d)",
418+
script.name, script.vers.to_str(), status));
419+
420+
return None;
421+
}
415422
}
416423

417424
os::change_dir(cwd);
@@ -748,6 +755,19 @@ impl Ctx {
748755
}
749756
}
750757

758+
// Run custom test listener
759+
if script.custom {
760+
let status = script.run(~"test", false);
761+
762+
if status != 0 && status != 42 {
763+
util::error(
764+
fmt!("testing %s v%s failed: custom logic failed (%d)",
765+
script.name, script.vers.to_str(), status));
766+
767+
os::set_exit_status(status);
768+
}
769+
}
770+
751771
util::note(fmt!("tested %s v%s", script.name, script.vers.to_str()));
752772

753773
true
@@ -888,7 +908,6 @@ pub fn main() {
888908
}.run(cmd, args);
889909
}
890910

891-
892911
/// A crate is a unit of Rust code to be compiled into a binary or library
893912
pub struct Crate {
894913
file: ~str,
@@ -918,7 +937,7 @@ pub fn run(listeners: ~[Listener]) {
918937
}
919938

920939
if !found {
921-
os::set_exit_status(1);
940+
os::set_exit_status(42);
922941
}
923942
}
924943

@@ -982,10 +1001,12 @@ pub fn src_dir() -> Path {
9821001

9831002
/// Build a set of crates, should be called once
9841003
pub fn build(crates: ~[Crate]) -> bool {
1004+
let args = os::args();
9851005
let dir = src_dir();
9861006
let work_dir = work_dir();
9871007
let mut success = true;
988-
let sysroot = Path(os::args()[1]);
1008+
let sysroot = Path(args[1]);
1009+
let test = args[3] == ~"true";
9891010

9901011
for crates.each |&crate| {
9911012
let path = &dir.push_rel(&Path(crate.file)).normalize();
@@ -994,13 +1015,13 @@ pub fn build(crates: ~[Crate]) -> bool {
9941015

9951016
success = util::compile_crate(Some(sysroot), path, &work_dir,
9961017
crate.flags, crate.cfgs,
997-
false, false);
1018+
false, test);
9981019

9991020
if !success { break; }
10001021
}
10011022

10021023
if !success {
1003-
os::set_exit_status(2);
1024+
os::set_exit_status(101);
10041025
}
10051026

10061027
success

0 commit comments

Comments
 (0)