proj home

Files   Classes   Functions   Hierarchy  

unittestcmd Class Reference

One line unit test. More...

#include <projunittest.h>

Inheritance diagram for unittestcmd:
Collaboration diagram for unittestcmd:

List of all members.

Public Member Functions

 unittestcmd ()
 Bad state.
 unittestcmd (stringc &line_)
 Not evaluated.
int eval ()
 Execute the command in the shell.
stringc xml () const
 Write as xml.

Public Attributes

projprint terminal
 Print mode.
string line
 Invoked at shell.
string output
 First few lines out output.

Static Public Attributes

static string tempfile = "/tmp/projunittestcmdtemp.txt"
 Tempory file.


Detailed Description

One line unit test.

Definition at line 25 of file projunittest.h.


Constructor & Destructor Documentation

unittestcmd::unittestcmd (  ) 

Bad state.

Definition at line 10 of file projunittest.cpp.

00011 {
00012 }

unittestcmd::unittestcmd ( stringc line_  ) 

Not evaluated.

Definition at line 14 of file projunittest.cpp.

00015   : line(line_)
00016 {
00017 }


Member Function Documentation

int unittestcmd::eval (  ) 

Execute the command in the shell.

Definition at line 19 of file projunittest.cpp.

References systemcalls::combine, systemcalls::eval(), exitint::exitstatus, projprint::isall(), projprint::issummary(), systemcalls::output(), output, tempfile, and terminal.

00020 {
00021 //cout << SHOW3(line) << endl;
00022 assert(line.empty()==false);
00023 
00024   stringc cmdline("$ " + line + "\n");
00025 
00026   if (terminal.isall())
00027     cout << cmdline;
00028   
00029   {
00030     systemcalls sys(line,tempfile);
00031     sys.combine=true;
00032     exitstatus=sys.eval();
00033 
00034     // Summary takes the first few lines only.
00035     //if (printstate!=summary)
00036     if (!terminal.issummary())
00037       output= sys.output();
00038   }
00039 //cout << SHOW3(exitstatus) << endl;
00040 //cout << SHOW3(printstate) << endl;
00041 
00042   if (terminal.issummary())
00043   {
00044 
00045   systemcalls sys2("head -n 15 " + tempfile);
00046   sys2.combine=true;
00047   sys2.eval();
00048   output= sys2.output(); 
00049 //cout << SHOW(output) << endl;
00050   }
00051 
00052   //if (printstate==all)
00053   if (terminal.isall())
00054     cout << output << endl;
00055 
00056   return exitstatus;
00057 }

stringc unittestcmd::xml (  )  const

Write as xml.

Definition at line 59 of file projunittest.cpp.

References exitint::exitstatus, output, and stringtag().

00060 {
00061   string s1;
00062   s1 += stringtag(exitstatus,"exitstatus");
00063   s1 += stringtag(line,"line");
00064   s1 += stringtag(output,"output");
00065 
00066   return s1=stringtag(s1,"cmd");
00067 }


Member Data Documentation

Invoked at shell.

Definition at line 38 of file projunittest.h.

First few lines out output.

Definition at line 40 of file projunittest.h.

Referenced by eval(), and xml().

string unittestcmd::tempfile = "/tmp/projunittestcmdtemp.txt" [static]

Tempory file.

Definition at line 43 of file projunittest.h.

Referenced by eval().

Print mode.

Definition at line 30 of file projunittest.h.

Referenced by eval().


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:50:22 2011 for Chelton Evans Source by  doxygen 1.5.8