[1/3] cmd/tests: Treat lines that start with '---' as resynchronization points. (rediffed)

Francois Gouget fgouget at free.fr
Tue Nov 29 04:44:37 CST 2011


This lets us better deal with missing and extra lines in the test output.
Also, all standard test section headers act as resynchronization points so this also limits the flurry or error messages one gets in case of missing or extra lines.
---

Same patch as yesterday but rediffed to avoid some fuzzing caused by 
another patch that contained traces for debugging. Also only sending the 
first three for now, just in case.

 programs/cmd/tests/batch.c               |   32 +++++++++++++++++++++++------
 programs/cmd/tests/test_builtins.cmd     |    2 +-
 programs/cmd/tests/test_builtins.cmd.exp |    2 +-
 3 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/programs/cmd/tests/batch.c b/programs/cmd/tests/batch.c
index 8347c03..8236352 100644
--- a/programs/cmd/tests/batch.c
+++ b/programs/cmd/tests/batch.c
@@ -276,7 +276,8 @@ static void test_output(const char *out_data, DWORD out_size, const char *exp_da
     const char *out_ptr = out_data, *exp_ptr = exp_data, *out_nl, *exp_nl, *err;
     DWORD line = 0;
     static const char todo_wine_cmd[] = {'@','t','o','d','o','_','w','i','n','e','@'};
-    BOOL is_todo_wine;
+    static const char resync_cmd[] = {'-','-','-'};
+    BOOL is_todo_wine, is_out_resync, is_exp_resync;
 
     while(out_ptr < out_data+out_size && exp_ptr < exp_data+exp_size) {
         line++;
@@ -290,6 +291,10 @@ static void test_output(const char *out_data, DWORD out_size, const char *exp_da
             exp_ptr += sizeof(todo_wine_cmd);
             winetest_start_todo("wine");
         }
+        is_exp_resync=(exp_ptr+sizeof(resync_cmd) <= exp_nl &&
+                       !memcmp(exp_ptr, resync_cmd, sizeof(resync_cmd)));
+        is_out_resync=(out_ptr+sizeof(resync_cmd) <= out_nl &&
+                       !memcmp(out_ptr, resync_cmd, sizeof(resync_cmd)));
 
         err = compare_line(out_ptr, out_nl, exp_ptr, exp_nl);
         if(err == out_nl)
@@ -298,18 +303,31 @@ static void test_output(const char *out_data, DWORD out_size, const char *exp_da
         else if(err == exp_nl)
             ok(0, "excess characters on line %d (got '%.*s', wanted '%.*s')\n",
                line, (int)(out_nl-out_ptr), out_ptr, (int)(exp_nl-exp_ptr), exp_ptr);
+        else if (!err && is_todo_wine && is_out_resync && is_exp_resync)
+            /* Consider that the todo_wine was to deal with extra lines,
+             * not for the resync line itself
+             */
+            err = NULL;
         else
             ok(!err, "unexpected char 0x%x position %d in line %d (got '%.*s', wanted '%.*s')\n",
                (err ? *err : 0), (err ? (int)(err-out_ptr) : -1), line, (int)(out_nl-out_ptr), out_ptr, (int)(exp_nl-exp_ptr), exp_ptr);
 
         if(is_todo_wine) winetest_end_todo("wine");
 
-        exp_ptr = exp_nl+1;
-        out_ptr = out_nl+1;
-        if(out_nl+1 < out_data+out_size && out_nl[0] == '\r' && out_nl[1] == '\n')
-            out_ptr++;
-        if(exp_nl+1 < exp_data+exp_size && exp_nl[0] == '\r' && exp_nl[1] == '\n')
-            exp_ptr++;
+        if (is_exp_resync && err && is_todo_wine)
+            exp_ptr -= sizeof(todo_wine_cmd);
+        else if (!is_exp_resync || (is_exp_resync && !err))
+        {
+            exp_ptr = exp_nl+1;
+            if(exp_nl+1 < exp_data+exp_size && exp_nl[0] == '\r' && exp_nl[1] == '\n')
+                exp_ptr++;
+        }
+        if (!is_out_resync || (is_out_resync && !err))
+        {
+            out_ptr = out_nl+1;
+            if(out_nl+1 < out_data+out_size && out_nl[0] == '\r' && out_nl[1] == '\n')
+                out_ptr++;
+        }
     }
 
     ok(exp_ptr >= exp_data+exp_size, "unexpected end of output in line %d, missing %s\n", line, exp_ptr);
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index bcaccb2..1734650 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -164,7 +164,7 @@ type C
 (if 1==0 (echo A > B) else echo C)
 cd .. & rd /s/q foobar
 
-echo ------------ Testing ^^ escape character --------------
+echo ------------ Testing circumflex escape character --------------
 rem Using something like "echo foo^" asks for an additional char after a "More?" prompt on the following line; it's not possible to currently test that non-interactively
 echo ^hell^o, world
 echo hell^o, world
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index e35b710..68355c4 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -178,7 +178,7 @@ foo
 A
 B
 C
- at todo_wine@------------ Testing ^ escape character --------------
+------------ Testing circumflex escape character --------------
 @todo_wine at hello, world
 @todo_wine at hello, world
 @todo_wine at hell^o, world
-- 
1.7.7.1




More information about the wine-patches mailing list