Commit dcdbad20 authored by Chris Cantwell's avatar Chris Cantwell

Move executable name override to TestData class.

parent b720cadb
......@@ -44,7 +44,8 @@ using namespace std;
namespace Nektar
{
TestData::TestData(const fs::path& pFilename)
TestData::TestData(const fs::path& pFilename, po::variables_map& pVm)
: m_cmdoptions(pVm)
{
// Process test file format.
#if BOOST_VERSION > 104200
......@@ -71,15 +72,9 @@ namespace Nektar
return m_description;
}
const std::string TestData::GetExecutable() const
const fs::path& TestData::GetExecutable() const
{
std::string execname = m_executable;
#if defined(RELWITHDEBINFO)
execname += "-rg";
#elif !defined(NDEBUG)
execname += "-g";
#endif
return execname;
return m_executable;
}
const std::string& TestData::GetParameters() const
......@@ -145,10 +140,23 @@ namespace Nektar
ASSERTL0(tmp, "Cannot find 'description' for test.");
m_description = string(tmp->GetText());
// Find executable tag.
tmp = testElement->FirstChildElement("executable");
ASSERTL0(tmp, "Cannot find 'executable' for test.");
m_executable = string(tmp->GetText());
// Find executable.
if (m_cmdoptions.count("executable"))
{
m_executable = fs::path(
m_cmdoptions["executable"].as<std::string>());
}
else
{
tmp = testElement->FirstChildElement("executable");
ASSERTL0(tmp, "Cannot find 'executable' for test.");
m_executable = fs::current_path() / fs::path(tmp->GetText());
#if defined(RELWITHDEBINFO)
m_executable += "-rg";
#elif !defined(NDEBUG)
m_executable += "-g";
#endif
}
// Find parameters tag.
tmp = testElement->FirstChildElement("parameters");
......
......@@ -36,6 +36,7 @@
#ifndef NEKTAR_TESTER_TESTDATA
#define NEKTAR_TESTER_TESTDATA
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <string>
......@@ -44,6 +45,7 @@
#include <tinyxml.h>
namespace fs = boost::filesystem;
namespace po = boost::program_options;
namespace Nektar
{
......@@ -56,11 +58,11 @@ namespace Nektar
class TestData
{
public:
TestData(const fs::path& pFilename);
TestData(const fs::path& pFilename, po::variables_map& pVm);
TestData(const TestData& pSrc);
const std::string& GetDescription() const;
const std::string GetExecutable() const;
const fs::path& GetExecutable() const;
const std::string& GetParameters() const;
const unsigned int& GetNProcesses() const;
......@@ -75,9 +77,9 @@ namespace Nektar
void SaveFile();
private:
std::string m_filename;
po::variables_map m_cmdoptions;
std::string m_description;
std::string m_executable;
fs::path m_executable;
std::string m_parameters;
unsigned int m_processes;
TiXmlDocument* m_doc;
......
......@@ -148,7 +148,7 @@ int main(int argc, char *argv[])
try
{
// Parse the test file
TestData file(specFile);
TestData file(specFile, vm);
// Generate the metric objects
vector<MetricSharedPtr> metrics;
......@@ -220,22 +220,12 @@ int main(int argc, char *argv[])
+ " ";
}
fs::path execPath;
if (vm.count("executable"))
fs::path execPath = file.GetExecutable();
if (!fs::exists(execPath))
{
execPath = vm["executable"].as<std::string>();
execPath = fs::path(file.GetExecutable());
}
else
{
// If executable doesn't exist in path then hope that it is in the
// user's PATH environment variable.
execPath = startDir / fs::path(file.GetExecutable());
if (!fs::exists(execPath))
{
execPath = fs::path(file.GetExecutable());
}
}
command += PortablePath(execPath);
command += " ";
command += file.GetParameters();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment