Skip to content

Commit

Permalink
Unbreak the debuginfo tests.
Browse files Browse the repository at this point in the history
The variant used in debug-info/method-on-enum.rs had its layout changed
by the smaller discriminant, so that the `u32` no longer overlaps both
of the `u16`s, and thus the debugger is printing partially uninitialized
data when it prints the wrong variant.

Thus, the test runner is modified to accept wildcards (using a string
that should be unlikely to occur literally), to allow for this.
  • Loading branch information
jld committed Oct 29, 2013
1 parent a027f16 commit 01097cb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
27 changes: 25 additions & 2 deletions src/compiletest/runtest.rs
Expand Up @@ -281,7 +281,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
};
let config = &mut config;
let cmds = props.debugger_cmds.connect("\n");
let check_lines = props.check_lines.clone();
let check_lines = &props.check_lines;

// compile test file (it shoud have 'compile-flags:-g' in the header)
let mut ProcRes = compile_test(config, props, testfile);
Expand Down Expand Up @@ -315,11 +315,34 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {

let num_check_lines = check_lines.len();
if num_check_lines > 0 {
// Allow check lines to leave parts unspecified (e.g., uninitialized
// bits in the wrong case of an enum) with the notation "[...]".
let check_fragments: ~[~[&str]] = check_lines.map(|s| s.split_str_iter("[...]").collect());
// check if each line in props.check_lines appears in the
// output (in order)
let mut i = 0u;
for line in ProcRes.stdout.line_iter() {
if check_lines[i].trim() == line.trim() {
let mut rest = line.trim();
let mut first = true;
let mut failed = false;
for &frag in check_fragments[i].iter() {
let found = if first {
if rest.starts_with(frag) { Some(0) } else { None }
} else {
rest.find_str(frag)
};
match found {
None => {
failed = true;
break;
}
Some(i) => {
rest = rest.slice_from(i + frag.len());
}
}
first = false;
}
if !failed && rest.len() == 0 {
i += 1u;
}
if i == num_check_lines {
Expand Down
16 changes: 8 additions & 8 deletions src/test/debug-info/method-on-enum.rs
Expand Up @@ -15,7 +15,7 @@
// STACK BY REF
// debugger:finish
// debugger:print *self
// check:$1 = {{Variant2, x = 1799, y = 1799}, {Variant2, 117901063}}
// check:$1 = {{Variant2, [...]}, {Variant2, 117901063}}
// debugger:print arg1
// check:$2 = -1
// debugger:print arg2
Expand All @@ -25,7 +25,7 @@
// STACK BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {{Variant2, x = 1799, y = 1799}, {Variant2, 117901063}}
// c heck:$X = {{Variant2, [...]}, {Variant2, 117901063}}
// debugger:print arg1
// check:$4 = -3
// debugger:print arg2
Expand All @@ -35,7 +35,7 @@
// OWNED BY REF
// debugger:finish
// debugger:print *self
// check:$6 = {{Variant1, x = 1799, y = 1799}, {Variant1, 117901063}}
// check:$6 = {{Variant1, x = 1799, y = 1799}, {Variant1, [...]}}
// debugger:print arg1
// check:$7 = -5
// debugger:print arg2
Expand All @@ -45,7 +45,7 @@
// OWNED BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {{Variant1, x = 1799, y = 1799}, {Variant1, 117901063}}
// c heck:$X = {{Variant1, x = 1799, y = 1799}, {Variant1, [...]}}
// debugger:print arg1
// check:$9 = -7
// debugger:print arg2
Expand All @@ -55,7 +55,7 @@
// OWNED MOVED
// debugger:finish
// debugger:print *self
// check:$11 = {{Variant1, x = 1799, y = 1799}, {Variant1, 117901063}}
// check:$11 = {{Variant1, x = 1799, y = 1799}, {Variant1, [...]}}
// debugger:print arg1
// check:$12 = -9
// debugger:print arg2
Expand All @@ -65,7 +65,7 @@
// MANAGED BY REF
// debugger:finish
// debugger:print *self
// check:$14 = {{Variant2, x = 1799, y = 1799}, {Variant2, 117901063}}
// check:$14 = {{Variant2, [...]}, {Variant2, 117901063}}
// debugger:print arg1
// check:$15 = -11
// debugger:print arg2
Expand All @@ -75,7 +75,7 @@
// MANAGED BY VAL
// debugger:finish
// d ebugger:print self -- ignored for now because of issue #8512
// c heck:$X = {{Variant2, x = 1799, y = 1799}, {Variant2, 117901063}}
// c heck:$X = {{Variant2, [...]}, {Variant2, 117901063}}
// debugger:print arg1
// check:$17 = -13
// debugger:print arg2
Expand All @@ -85,7 +85,7 @@
// MANAGED SELF
// debugger:finish
// debugger:print self->val
// check:$19 = {{Variant2, x = 1799, y = 1799}, {Variant2, 117901063}}
// check:$19 = {{Variant2, [...]}, {Variant2, 117901063}}
// debugger:print arg1
// check:$20 = -15
// debugger:print arg2
Expand Down

0 comments on commit 01097cb

Please sign in to comment.