tasn pushed a commit to branch master.

commit b5523094af6b1d2cbc22389b05d627b890c31a19
Author: Tom Hacohen <[email protected]>
Date:   Wed Jun 12 15:15:02 2013 +0100

    Print an error if report file can't be opened for writing.
---
 src/bin/exactness.c | 73 +++++++++++++++++++++++++++++------------------------
 1 file changed, 40 insertions(+), 33 deletions(-)

diff --git a/src/bin/exactness.c b/src/bin/exactness.c
index 7fa781c..64ac78d 100644
--- a/src/bin/exactness.c
+++ b/src/bin/exactness.c
@@ -180,47 +180,54 @@ main(int argc, char *argv[])
               "%s/%s/errors.html",
               exactness_config.dest_dir, CURRENT_SUBDIR);
         report_file = fopen(report_filename, "w+");
-        printf("%s %p\n", report_filename, report_file);
-        fprintf(report_file,
-              "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html PUBLIC 
\"-//W3C//DTD XHTML 1.0 Strict//EN\" 
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\";>"
-              "<html 
xmlns=\"http://www.w3.org/1999/xhtml\";><head><title>Exactness 
report</title></head><body>");
-
-        if (exactness_ctx.errors)
+        if (report_file)
           {
+             printf("%s %p\n", report_filename, report_file);
              fprintf(report_file,
-                   "<h1>Tests that failed execution:</h1><ul>");
-             Eina_List *itr;
-             List_Entry *ent;
-             printf("List of tests that failed execution:\n");
-             EINA_LIST_FOREACH(exactness_ctx.errors, itr, ent)
-               {
-                  printf("\t* %s\n", ent->name);
+                   "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html 
PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" 
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\";>"
+                   "<html 
xmlns=\"http://www.w3.org/1999/xhtml\";><head><title>Exactness 
report</title></head><body>");
 
-                  fprintf(report_file, "<li>%s</li>", ent->name);
+             if (exactness_ctx.errors)
+               {
+                  fprintf(report_file,
+                        "<h1>Tests that failed execution:</h1><ul>");
+                  Eina_List *itr;
+                  List_Entry *ent;
+                  printf("List of tests that failed execution:\n");
+                  EINA_LIST_FOREACH(exactness_ctx.errors, itr, ent)
+                    {
+                       printf("\t* %s\n", ent->name);
+
+                       fprintf(report_file, "<li>%s</li>", ent->name);
+                    }
+                  fprintf(report_file, "</ul>");
                }
-             fprintf(report_file, "</ul>");
-          }
 
-        if (exactness_ctx.compare_errors)
-          {
-             fprintf(report_file,
-                   "<h1>Images that failed comparison: (Original, Current, 
Diff)</h1><ul>");
-             char *test_name;
-             printf("List of images that failed comparison:\n");
-             EINA_LIST_FREE(exactness_ctx.compare_errors, test_name)
+             if (exactness_ctx.compare_errors)
                {
-                  printf("\t* %s\n", test_name);
-
-                  fprintf(report_file, "<li><h2>%s</h2> <img src='../orig/%s' 
alt='Original' /> <img src='%s' alt='Current' /> <img src='comp_%s' alt='Diff' 
/></li>", test_name, test_name, test_name, test_name);
-                  free(test_name);
+                  fprintf(report_file,
+                        "<h1>Images that failed comparison: (Original, 
Current, Diff)</h1><ul>");
+                  char *test_name;
+                  printf("List of images that failed comparison:\n");
+                  EINA_LIST_FREE(exactness_ctx.compare_errors, test_name)
+                    {
+                       printf("\t* %s\n", test_name);
+
+                       fprintf(report_file, "<li><h2>%s</h2> <img 
src='../orig/%s' alt='Original' /> <img src='%s' alt='Current' /> <img 
src='comp_%s' alt='Diff' /></li>", test_name, test_name, test_name, test_name);
+                       free(test_name);
+                    }
+                  fprintf(report_file, "</ul>");
                }
-             fprintf(report_file, "</ul>");
-          }
-        fprintf(report_file,
-              "</body></html>");
+             fprintf(report_file,
+                   "</body></html>");
 
-        printf("Report html: %s\n", report_filename);
-        ret = 1;
+             printf("Report html: %s\n", report_filename);
+             ret = 1;
+          }
+        else
+          {
+             perror("Failed opening report file");
+          }
      }
 
    list_file_free(test_list);

-- 

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev

Reply via email to