Francois Gouget : cmd/tests: Treat lines that start with '---' as resynchronization points.

Alexandre Julliard julliard at winehq.org
Tue Nov 29 14:20:38 CST 2011


Module: wine
Branch: master
Commit: 81f64ee906888875de10a4c804bed88c103a282c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=81f64ee906888875de10a4c804bed88c103a282c

Author: Francois Gouget <fgouget at free.fr>
Date:   Tue Nov 29 11:44:37 2011 +0100

cmd/tests: Treat lines that start with '---' as resynchronization points.

---

 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




More information about the wine-cvs mailing list