~brianaker/libmemcached/gear-clean

« back to all changes in this revision

Viewing changes to libtest/main.cc

  • Committer: Brian Aker
  • Date: 2012-08-02 16:14:34 UTC
  • mto: This revision was merged to the branch mainline in revision 1058.
  • Revision ID: brian@tangent.org-20120802161434-gj4slc2hchroierg
Update to support new warnings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
#include <ctime>
44
44
#include <fnmatch.h>
45
45
#include <iostream>
 
46
#include <fstream>
46
47
#include <memory>
47
48
#include <sys/stat.h>
48
49
#include <sys/time.h>
58
59
 
59
60
using namespace libtest;
60
61
 
61
 
static void stats_print(Framework *frame)
 
62
static void stats_print(libtest::Framework *frame)
62
63
{
63
64
  if (frame->failed() == 0 and frame->success() == 0)
64
65
  {
87
88
  bool opt_quiet= false;
88
89
  std::string collection_to_run;
89
90
  std::string wildcard;
 
91
  std::string binary_name;
 
92
 
 
93
  const char *just_filename= rindex(argv[0], '/');
 
94
  if (just_filename)
 
95
  {
 
96
    just_filename++;
 
97
  }
 
98
  else
 
99
  {
 
100
    just_filename= argv[0];
 
101
  }
 
102
 
 
103
  if (just_filename[0] == 'l' and just_filename[1] == 't' and  just_filename[2] == '-')
 
104
  {
 
105
    just_filename+= 3;
 
106
  }
 
107
  binary_name.append(just_filename);
90
108
 
91
109
  /*
92
110
    Valgrind does not currently work reliably, or sometimes at all, on OSX
261
279
        return EXIT_FAILURE;
262
280
      }
263
281
 
264
 
      std::auto_ptr<Framework> frame(new Framework(signal, collection_to_run, wildcard));
 
282
      std::auto_ptr<libtest::Framework> frame(new libtest::Framework(signal, binary_name, collection_to_run, wildcard));
265
283
 
266
284
      // Run create(), bail on error.
267
285
      {
303
321
      }
304
322
      else if (frame->success() and (frame->failed() == 0))
305
323
      {
 
324
        Out;
306
325
        Out << "All tests completed successfully.";
307
326
      }
308
327
 
309
328
      stats_print(frame.get());
310
329
 
 
330
      std::ofstream xml_file;
 
331
      std::string file_name;
 
332
      if (getenv("LIBTEST_TEMP"))
 
333
      {
 
334
        file_name.append(getenv("LIBTEST_TEMP"));
 
335
      }
 
336
      file_name.append(frame->name());
 
337
      file_name.append(".xml");
 
338
      xml_file.open(file_name.c_str(), std::ios::trunc);
 
339
      libtest::Formatter::xml(*frame, xml_file);
 
340
 
311
341
      Outn(); // Generate a blank to break up the messages if make check/test has been run
312
342
    } while (exit_code == EXIT_SUCCESS and --opt_repeat);
313
343
  }