about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJed Davis <jld@panix.com>2013-08-31 14:41:35 -0700
committerJed Davis <jld@panix.com>2013-10-29 09:09:20 -0700
commit01097cbab00f64b922bcf5b91fb26a68f6d0d9cf (patch)
tree372b464afcee7c0e97b024df05c24f04d3523494
parenta027f164bcda6f99d0b44f79ca9f676ecc12a50a (diff)
Unbreak the debuginfo tests.
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.
-rw-r--r--src/compiletest/runtest.rs27
-rw-r--r--src/test/debug-info/method-on-enum.rs16
2 files changed, 33 insertions, 10 deletions
diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs
index e7e1b110289..13c4c7948b8 100644
--- a/src/compiletest/runtest.rs
+++ b/src/compiletest/runtest.rs
@@ -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);
@@ -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 {
diff --git a/src/test/debug-info/method-on-enum.rs b/src/test/debug-info/method-on-enum.rs
index 2f02844fdc5..a6aacdf8e66 100644
--- a/src/test/debug-info/method-on-enum.rs
+++ b/src/test/debug-info/method-on-enum.rs
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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