Truncate the filename location for tests

Francois Gouget fgouget at free.fr
Tue Dec 10 14:43:51 CST 2002


Currently the tests print the full path name of the file where the error
occurred. In fact just the filename should be more than enough and this
seems to be irritating everyone, including me. So here is a patch that
truncates the pathname to only keep the filename. I also merge
winetest_set_ok_location and winetest_set_trace_location since they do
exactly the same thing and I don't see why we would ever need them to do
different things.


Changelog:

 * include/wine/test.h

   When reporting a test failure, only report the file name, not the
full path
   Merge winetest_set_trace_location with winetest_set_ok_location


Index: include/wine/test.h
===================================================================
RCS file: /home/wine/wine/include/wine/test.h,v
retrieving revision 1.7
diff -u -r1.7 test.h
--- include/wine/test.h	30 Oct 2002 20:36:21 -0000	1.7
+++ include/wine/test.h	10 Dec 2002 20:30:22 -0000
@@ -30,8 +30,7 @@
 /* current platform */
 extern const char *winetest_platform;

-extern void winetest_set_ok_location( const char* file, int line );
-extern void winetest_set_trace_location( const char* file, int line );
+extern void winetest_set_location( const char* file, int line );
 extern void winetest_start_todo( const char* platform );
 extern int winetest_loop_todo(void);
 extern void winetest_end_todo( const char* platform );
@@ -51,8 +50,8 @@

 #endif /* __GNUC__ */

-#define ok_(file, line)     (winetest_set_ok_location(file, line), 0) ? 0 : winetest_ok
-#define trace_(file, line)  (winetest_set_trace_location(file, line), 0) ? (void)0 : winetest_trace
+#define ok_(file, line)     (winetest_set_location(file, line), 0) ? 0 : winetest_ok
+#define trace_(file, line)  (winetest_set_location(file, line), 0) ? (void)0 : winetest_trace

 #define ok     ok_(__FILE__, __LINE__)
 #define trace  trace_(__FILE__, __LINE__)
@@ -125,6 +124,19 @@
 }


+void winetest_set_location( const char* file, int line )
+{
+    tls_data* data=get_tls_data();
+    data->current_file=strrchr(file,'/');
+    if (data->current_file==NULL)
+        data->current_file=strrchr(file,'\\');
+    if (data->current_file==NULL)
+        data->current_file=file;
+    else
+        data->current_file++;
+    data->current_line=line;
+}
+
 /*
  * Checks condition.
  * Parameters:
@@ -187,13 +199,6 @@
     return 1;
 }

-void winetest_set_ok_location( const char* file, int line )
-{
-    tls_data* data=get_tls_data();
-    data->current_file=file;
-    data->current_line=line;
-}
-
 void winetest_trace( const char *msg, ... )
 {
     va_list valist;
@@ -208,13 +213,6 @@
     }
 }

-void winetest_set_trace_location( const char* file, int line )
-{
-    tls_data* data=get_tls_data();
-    data->current_file=file;
-    data->current_line=line;
-}
-
 void winetest_start_todo( const char* platform )
 {
     tls_data* data=get_tls_data();



-- 
Francois Gouget         fgouget at free.fr        http://fgouget.free.fr/
                  A black hole is just God dividing by zero.




More information about the wine-patches mailing list