Skip to content

Commit db01d1a

Browse files
committed
---
yaml --- r: 44362 b: refs/heads/master c: 85d7b3c h: refs/heads/master v: v3
1 parent 515d120 commit db01d1a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1020
-881
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 99ff74c1bd4d982cfc49f8ed962cd31f3c8d9ae7
2+
refs/heads/master: 85d7b3c154b0fa08c54c1edeefc8f36654764d99
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
55
refs/heads/try: ef355f6332f83371e4acf04fc4eb940ab41d78d3

trunk/configure

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ do
619619
make_dir $h/test/bench
620620
make_dir $h/test/perf
621621
make_dir $h/test/pretty
622+
make_dir $h/test/debug-info
622623
make_dir $h/test/doc-tutorial
623624
make_dir $h/test/doc-tutorial-ffi
624625
make_dir $h/test/doc-tutorial-macros

trunk/mk/tests.mk

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ cleantestlibs:
103103
-name '*.dSYM' -o \
104104
-name '*.libaux' -o \
105105
-name '*.out' -o \
106-
-name '*.err' \
106+
-name '*.err' -o \
107+
-name '*.debugger.script' \
107108
| xargs rm -rf
108109

109110

@@ -284,6 +285,7 @@ CFAIL_RC := $(wildcard $(S)src/test/compile-fail/*.rc)
284285
CFAIL_RS := $(wildcard $(S)src/test/compile-fail/*.rs)
285286
BENCH_RS := $(wildcard $(S)src/test/bench/*.rs)
286287
PRETTY_RS := $(wildcard $(S)src/test/pretty/*.rs)
288+
DEBUGINFO_RS := $(wildcard $(S)src/test/debug-info/*.rs)
287289

288290
# perf tests are the same as bench tests only they run under
289291
# a performance monitor.
@@ -296,6 +298,7 @@ CFAIL_TESTS := $(CFAIL_RC) $(CFAIL_RS)
296298
BENCH_TESTS := $(BENCH_RS)
297299
PERF_TESTS := $(PERF_RS)
298300
PRETTY_TESTS := $(PRETTY_RS)
301+
DEBUGINFO_TESTS := $(DEBUGINFO_RS)
299302

300303
CTEST_SRC_BASE_rpass = run-pass
301304
CTEST_BUILD_BASE_rpass = run-pass
@@ -327,6 +330,11 @@ CTEST_BUILD_BASE_perf = perf
327330
CTEST_MODE_perf = run-pass
328331
CTEST_RUNTOOL_perf = $(CTEST_PERF_RUNTOOL)
329332

333+
CTEST_SRC_BASE_debuginfo = debug-info
334+
CTEST_BUILD_BASE_debuginfo = debug-info
335+
CTEST_MODE_debuginfo = debug-info
336+
CTEST_RUNTOOL_debuginfo = $(CTEST_RUNTOOL)
337+
330338
define DEF_CTEST_VARS
331339

332340
# All the per-stage build rules you might want to call from the
@@ -358,6 +366,7 @@ CTEST_DEPS_rfail_$(1)-T-$(2)-H-$(3) = $$(RFAIL_TESTS)
358366
CTEST_DEPS_cfail_$(1)-T-$(2)-H-$(3) = $$(CFAIL_TESTS)
359367
CTEST_DEPS_bench_$(1)-T-$(2)-H-$(3) = $$(BENCH_TESTS)
360368
CTEST_DEPS_perf_$(1)-T-$(2)-H-$(3) = $$(PERF_TESTS)
369+
CTEST_DEPS_debuginfo_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_TESTS)
361370

362371
endef
363372

@@ -388,7 +397,7 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
388397

389398
endef
390399

391-
CTEST_NAMES = rpass rpass-full rfail cfail bench perf
400+
CTEST_NAMES = rpass rpass-full rfail cfail bench perf debuginfo
392401

393402
$(foreach host,$(CFG_TARGET_TRIPLES), \
394403
$(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
@@ -496,6 +505,7 @@ TEST_GROUPS = \
496505
cfail \
497506
bench \
498507
perf \
508+
debuginfo \
499509
doc \
500510
$(foreach docname,$(DOC_TEST_NAMES),$(docname)) \
501511
pretty \

trunk/src/compiletest/common.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2-
// file at the top-level directory of this distribution and at
1+
// Copyright 2012-2013 The Rust Project Developers. See the
2+
// COPYRIGHT file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
55
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
@@ -18,6 +18,7 @@ pub enum mode {
1818
mode_run_fail,
1919
mode_run_pass,
2020
mode_pretty,
21+
mode_debug_info,
2122
}
2223

2324
pub type config = {

trunk/src/compiletest/compiletest.rc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ use common::mode_run_pass;
4141
use common::mode_run_fail;
4242
use common::mode_compile_fail;
4343
use common::mode_pretty;
44+
use common::mode_debug_info;
4445
use common::mode;
4546
use util::logv;
4647

@@ -131,6 +132,7 @@ pub fn str_mode(s: ~str) -> mode {
131132
~"run-fail" => mode_run_fail,
132133
~"run-pass" => mode_run_pass,
133134
~"pretty" => mode_pretty,
135+
~"debug-info" => mode_debug_info,
134136
_ => die!(~"invalid mode")
135137
}
136138
}
@@ -140,7 +142,8 @@ pub fn mode_str(mode: mode) -> ~str {
140142
mode_compile_fail => ~"compile-fail",
141143
mode_run_fail => ~"run-fail",
142144
mode_run_pass => ~"run-pass",
143-
mode_pretty => ~"pretty"
145+
mode_pretty => ~"pretty",
146+
mode_debug_info => ~"debug-info",
144147
}
145148
}
146149

trunk/src/compiletest/header.rs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2-
// file at the top-level directory of this distribution and at
1+
// Copyright 2012-2013 The Rust Project Developers. See the
2+
// COPYRIGHT file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
55
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
@@ -28,7 +28,11 @@ pub struct TestProps {
2828
// Modules from aux directory that should be compiled
2929
aux_builds: ~[~str],
3030
// Environment settings to use during execution
31-
exec_env: ~[(~str,~str)]
31+
exec_env: ~[(~str,~str)],
32+
// Commands to be given to the debugger, when testing debug info
33+
debugger_cmds: ~[~str],
34+
// Lines to check if they appear in the expected debugger output
35+
check_lines: ~[~str],
3236
}
3337

3438
// Load any test directives embedded in the file
@@ -38,6 +42,8 @@ pub fn load_props(testfile: &Path) -> TestProps {
3842
let mut exec_env = ~[];
3943
let mut compile_flags = None;
4044
let mut pp_exact = None;
45+
let mut debugger_cmds = ~[];
46+
let mut check_lines = ~[];
4147
for iter_header(testfile) |ln| {
4248
match parse_error_pattern(ln) {
4349
Some(ep) => error_patterns.push(ep),
@@ -59,13 +65,25 @@ pub fn load_props(testfile: &Path) -> TestProps {
5965
do parse_exec_env(ln).iter |ee| {
6066
exec_env.push(*ee);
6167
}
68+
69+
match parse_debugger_cmd(ln) {
70+
Some(dc) => debugger_cmds.push(dc),
71+
None => ()
72+
};
73+
74+
match parse_check_line(ln) {
75+
Some(cl) => check_lines.push(cl),
76+
None => ()
77+
};
6278
};
6379
return TestProps {
6480
error_patterns: error_patterns,
6581
compile_flags: compile_flags,
6682
pp_exact: pp_exact,
6783
aux_builds: aux_builds,
68-
exec_env: exec_env
84+
exec_env: exec_env,
85+
debugger_cmds: debugger_cmds,
86+
check_lines: check_lines
6987
};
7088
}
7189

@@ -112,6 +130,14 @@ fn parse_compile_flags(line: ~str) -> Option<~str> {
112130
parse_name_value_directive(line, ~"compile-flags")
113131
}
114132

133+
fn parse_debugger_cmd(line: ~str) -> Option<~str> {
134+
parse_name_value_directive(line, ~"debugger")
135+
}
136+
137+
fn parse_check_line(line: ~str) -> Option<~str> {
138+
parse_name_value_directive(line, ~"check")
139+
}
140+
115141
fn parse_exec_env(line: ~str) -> Option<(~str, ~str)> {
116142
do parse_name_value_directive(line, ~"exec-env").map |nv| {
117143
// nv is either FOO or FOO=BAR

trunk/src/compiletest/runtest.rs

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2-
// file at the top-level directory of this distribution and at
1+
// Copyright 2012-2013 The Rust Project Developers. See the
2+
// COPYRIGHT file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
55
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
@@ -39,11 +39,13 @@ pub fn run(config: config, testfile: ~str) {
3939
let testfile = Path(testfile);
4040
debug!("running %s", testfile.to_str());
4141
let props = load_props(&testfile);
42+
debug!("loaded props");
4243
match config.mode {
4344
mode_compile_fail => run_cfail_test(config, props, &testfile),
4445
mode_run_fail => run_rfail_test(config, props, &testfile),
4546
mode_run_pass => run_rpass_test(config, props, &testfile),
46-
mode_pretty => run_pretty_test(config, props, &testfile)
47+
mode_pretty => run_pretty_test(config, props, &testfile),
48+
mode_debug_info => run_debuginfo_test(config, props, &testfile)
4749
}
4850
}
4951

@@ -224,6 +226,55 @@ actual:\n\
224226
}
225227
}
226228

229+
fn run_debuginfo_test(config: config, props: TestProps, testfile: &Path) {
230+
// compile test file (it shoud have 'compile-flags:-g' in the header)
231+
let mut ProcRes = compile_test(config, props, testfile);
232+
if ProcRes.status != 0 {
233+
fatal_ProcRes(~"compilation failed!", ProcRes);
234+
}
235+
236+
// write debugger script
237+
let script_str = str::append(str::connect(props.debugger_cmds, "\n"),
238+
~"\nquit\n");
239+
debug!("script_str = %s", script_str);
240+
dump_output_file(config, testfile, script_str, ~"debugger.script");
241+
242+
// run debugger script with gdb
243+
#[cfg(windows)]
244+
fn debugger() -> ~str { ~"gdb.exe" }
245+
#[cfg(unix)]
246+
fn debugger() -> ~str { ~"gdb" }
247+
let debugger_script = make_out_name(config, testfile, ~"debugger.script");
248+
let debugger_opts = ~[~"-quiet", ~"-batch", ~"-nx",
249+
~"-command=" + debugger_script.to_str(),
250+
make_exe_name(config, testfile).to_str()];
251+
let ProcArgs = ProcArgs {prog: debugger(), args: debugger_opts};
252+
ProcRes = compose_and_run(config, testfile, ProcArgs, ~[], ~"", None);
253+
if ProcRes.status != 0 {
254+
fatal(~"gdb failed to execute");
255+
}
256+
257+
let num_check_lines = vec::len(props.check_lines);
258+
if num_check_lines > 0 {
259+
// check if each line in props.check_lines appears in the
260+
// output (in order)
261+
let mut i = 0u;
262+
for str::lines(ProcRes.stdout).each |line| {
263+
if props.check_lines[i].trim() == line.trim() {
264+
i += 1u;
265+
}
266+
if i == num_check_lines {
267+
// all lines checked
268+
break;
269+
}
270+
}
271+
if i != num_check_lines {
272+
fatal(fmt!("line not found in debugger output: %s",
273+
props.check_lines[i]));
274+
}
275+
}
276+
}
277+
227278
fn check_error_patterns(props: TestProps,
228279
testfile: &Path,
229280
ProcRes: ProcRes) {

trunk/src/libcargo/cargo.rc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ pub fn parse_source(name: ~str, j: &json::Json) -> @Source {
457457
}
458458

459459
match *j {
460-
json::Object(ref j) => {
460+
json::Object(j) => {
461461
let mut url = match j.find(&~"url") {
462462
Some(&json::String(u)) => copy u,
463463
_ => die!(~"needed 'url' field in source")
@@ -563,7 +563,7 @@ pub fn load_one_source_package(src: @Source, p: &json::Object) {
563563

564564
let mut tags = ~[];
565565
match p.find(&~"tags") {
566-
Some(&json::List(ref js)) => {
566+
Some(&json::List(js)) => {
567567
for js.each |j| {
568568
match *j {
569569
json::String(ref j) => tags.grow(1u, j),
@@ -635,11 +635,11 @@ pub fn load_source_packages(c: &Cargo, src: @Source) {
635635
if !os::path_exists(&pkgfile) { return; }
636636
let pkgstr = io::read_whole_file_str(&pkgfile);
637637
match json::from_str(pkgstr.get()) {
638-
Ok(json::List(ref js)) => {
638+
Ok(json::List(js)) => {
639639
for js.each |j| {
640640
match *j {
641-
json::Object(ref p) => {
642-
load_one_source_package(src, *p);
641+
json::Object(p) => {
642+
load_one_source_package(src, p);
643643
}
644644
_ => {
645645
warn(~"malformed source json: " + src.name +
@@ -730,7 +730,7 @@ pub fn configure(opts: Options) -> Cargo {
730730
need_dir(&c.libdir);
731731
need_dir(&c.bindir);
732732

733-
for sources.each_key |&k| {
733+
for sources.each_key_ref |&k| {
734734
let mut s = sources.get(&k);
735735
load_source_packages(&c, s);
736736
sources.insert(k, s);
@@ -748,7 +748,7 @@ pub fn configure(opts: Options) -> Cargo {
748748
}
749749

750750
pub fn for_each_package(c: &Cargo, b: fn(s: @Source, p: &Package)) {
751-
for c.sources.each_value |&v| {
751+
for c.sources.each_value_ref |&v| {
752752
for v.packages.each |p| {
753753
b(v, p);
754754
}
@@ -1155,7 +1155,7 @@ pub fn cmd_install(c: &mut Cargo) {
11551155
}
11561156

11571157
pub fn sync(c: &Cargo) {
1158-
for c.sources.each_key |&k| {
1158+
for c.sources.each_key_ref |&k| {
11591159
let mut s = c.sources.get(&k);
11601160
sync_one(c, s);
11611161
c.sources.insert(k, s);
@@ -1569,7 +1569,7 @@ pub fn cmd_list(c: &Cargo) {
15691569
}
15701570
}
15711571
} else {
1572-
for c.sources.each_value |&v| {
1572+
for c.sources.each_value_ref |&v| {
15731573
print_source(v);
15741574
}
15751575
}
@@ -1636,7 +1636,7 @@ pub fn dump_sources(c: &Cargo) {
16361636
result::Ok(writer) => {
16371637
let mut hash = ~LinearMap::new();
16381638

1639-
for c.sources.each |&k, &v| {
1639+
for c.sources.each_ref |&k, &v| {
16401640
let mut chash = ~LinearMap::new();
16411641

16421642
chash.insert(~"url", json::String(v.url));
@@ -1675,7 +1675,7 @@ pub fn copy_warn(srcfile: &Path, destfile: &Path) {
16751675

16761676
pub fn cmd_sources(c: &Cargo) {
16771677
if vec::len(c.opts.free) < 3u {
1678-
for c.sources.each_value |&v| {
1678+
for c.sources.each_value_ref |&v| {
16791679
info(fmt!("%s (%s) via %s",
16801680
v.name, v.url, v.method));
16811681
}
@@ -1686,7 +1686,7 @@ pub fn cmd_sources(c: &Cargo) {
16861686

16871687
match action {
16881688
~"clear" => {
1689-
for c.sources.each_key |&k| {
1689+
for c.sources.each_key_ref |&k| {
16901690
c.sources.remove(&k);
16911691
}
16921692

@@ -1706,7 +1706,7 @@ pub fn cmd_sources(c: &Cargo) {
17061706
return;
17071707
}
17081708

1709-
if c.sources.contains_key(&name) {
1709+
if c.sources.contains_key_ref(&name) {
17101710
error(fmt!("source already exists: %s", name));
17111711
} else {
17121712
c.sources.insert(name, @Source {
@@ -1733,7 +1733,7 @@ pub fn cmd_sources(c: &Cargo) {
17331733
return;
17341734
}
17351735

1736-
if c.sources.contains_key(&name) {
1736+
if c.sources.contains_key_ref(&name) {
17371737
c.sources.remove(&name);
17381738
info(fmt!("removed source: %s", name));
17391739
} else {

0 commit comments

Comments
 (0)