50cdbb1f9945eb4a7ddbb69a4a458d0144f9833a
braney
  Wed Sep 21 13:44:55 2011 -0700
allow for appending to log files #5148
diff --git src/hg/hgTablesTest/hgTablesTest.c src/hg/hgTablesTest/hgTablesTest.c
index d17cedb..635d313 100644
--- src/hg/hgTablesTest/hgTablesTest.c
+++ src/hg/hgTablesTest/hgTablesTest.c
@@ -17,69 +17,72 @@
 #define MAX_ATTEMPTS 10
 
 static char const rcsid[] = "$Id: hgTablesTest.c,v 1.35 2006/04/12 14:17:35 angie Exp $";
 
 /* Command line variables. */
 char *clOrg = NULL;	/* Organism from command line. */
 char *clDb = NULL;	/* DB from command line */
 char *clGroup = NULL;	/* Group from command line. */
 char *clTrack = NULL;	/* Track from command line. */
 char *clTable = NULL;	/* Table from command line. */
 int clGroups = BIGNUM;	/* Number of groups to test. */
 int clTracks = 4;	/* Number of track to test. */
 int clTables = 2;	/* Number of tables to test. */
 int clDbs = 1;		/* Number of databases per organism. */
 int clOrgs = 2;		/* Number of organisms to test. */
+boolean appendLog;      /* append to log rather than create it */
 
 void usage()
 /* Explain usage and exit. */
 {
 errAbort(
   "hgTablesTest - Test hgTables web page\n"
   "usage:\n"
   "   hgTablesTest url log\n"
   "Where url is something like hgwbeta.cse.ucsc.edu/cgi-bin/hgTables\n"
   "and log is a file where error messages and statistics will be written\n"
   "options:\n"
   "   -org=Human - Restrict to Human (or Mouse, Fruitfly, etc.)\n"
   "   -db=hg17 - Restrict to particular database\n"
   "   -group=genes - Restrict to a particular group\n"
   "   -track=knownGene - Restrict to a particular track\n"
   "   -table=knownGeneMrna - Restrict to a particular table\n"
   "   -orgs=N - Number of organisms to test.  Default %d\n"
   "   -dbs=N - Number of databases per organism to test. Default %d\n"
   "   -groups=N - Number of groups to test (default all)\n"
   "   -tracks=N - Number of tracks per group to test (default %d)\n"
   "   -tables=N - Number of tables per track to test (deault %d)\n"
   "   -verbose=N - Set to 0 for silent operation, 2 or 3 for debugging\n"
+  "   -appendLog - Append to log file rather than creating it\n"
   , clOrgs, clDbs, clTracks, clTables);
 }
 
 FILE *logFile;	/* Log file. */
 
 static struct optionSpec options[] = {
    {"org", OPTION_STRING},
    {"db", OPTION_STRING},
    {"group", OPTION_STRING},
    {"track", OPTION_STRING},
    {"table", OPTION_STRING},
    {"orgs", OPTION_INT},
    {"dbs", OPTION_INT},
    {"search", OPTION_STRING},
    {"groups", OPTION_INT},
    {"tracks", OPTION_INT},
    {"tables", OPTION_INT},
+   {"appendLog", OPTION_BOOLEAN},
    {NULL, 0},
 };
 
 struct tablesTest
 /* Test on one column. */
     {
     struct tablesTest *next;
     struct qaStatus *status;	/* Result of test. */
     char *info[6];
     };
 
 enum tablesTestInfoIx {
    ntiiType,
    ntiiOrg,
    ntiiDb,
@@ -1100,30 +1103,33 @@
 /* Report all tests. */
 {
 struct tablesTest *test;
 for (test = list; test != NULL; test = test->next)
     {
     if (test->status->errMessage != NULL)
 	tablesTestLogOne(test, f);
     }
 }
 
 void hgTablesTest(char *url, char *logName)
 /* hgTablesTest - Test hgTables web page. */
 {
 /* Get default page, and open log. */
 struct htmlPage *rootPage = htmlPageGet(url);
+if (appendLog)
+    logFile = mustOpen(logName, "a");
+else
 logFile = mustOpen(logName, "w");
 if (! endsWith(url, "hgTables"))
     warn("Warning: first argument should be a complete URL to hgTables, "
 	 "but doesn't look like one (%s)", url);
 htmlPageValidateOrAbort(rootPage);
 
 /* Go test what they've specified in command line. */
 if (clDb != NULL)
     {
     testDb(rootPage, NULL, clDb);
     }
 else
     {
     struct htmlForm *mainForm;
     struct htmlFormVar *orgVar;
@@ -1164,21 +1170,22 @@
 {
 pushCarefulMemHandler(500000000);
 optionInit(&argc, argv, options);
 if (argc != 3)
     usage();
 clDb = optionVal("db", clDb);
 clOrg = optionVal("org", clOrg);
 clGroup = optionVal("group", clGroup);
 clTrack = optionVal("track", clTrack);
 clTable = optionVal("table", clTable);
 clDbs = optionInt("dbs", clDbs);
 clOrgs = optionInt("orgs", clOrgs);
 clGroups = optionInt("groups", clGroups);
 clTracks = optionInt("tracks", clTracks);
 clTables = optionInt("tables", clTables);
+appendLog = optionExists("appendLog");
 if (clOrg != NULL)
    clOrgs = BIGNUM;
 hgTablesTest(argv[1], argv[2]);
 carefulCheckHeap();
 return 0;
 }