Record backtrace for every add_test command
We teach cmTest to hold a backtrace for the add_test command that created it. This will be used later to report context for errors at generate time.
This commit is contained in:
parent
6e3c6a1a80
commit
0bc050677f
|
@ -3314,9 +3314,8 @@ cmTest* cmMakefile::CreateTest(const char* testName)
|
||||||
{
|
{
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
test = new cmTest;
|
test = new cmTest(this);
|
||||||
test->SetName(testName);
|
test->SetName(testName);
|
||||||
test->SetMakefile(this);
|
|
||||||
this->Tests[testName] = test;
|
this->Tests[testName] = test;
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,15 +21,25 @@
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmTest::cmTest()
|
cmTest::cmTest(cmMakefile* mf)
|
||||||
{
|
{
|
||||||
this->Makefile = 0;
|
this->Makefile = mf;
|
||||||
this->OldStyle = true;
|
this->OldStyle = true;
|
||||||
|
this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
|
||||||
|
this->Backtrace = new cmListFileBacktrace;
|
||||||
|
this->Makefile->GetBacktrace(*this->Backtrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmTest::~cmTest()
|
cmTest::~cmTest()
|
||||||
{
|
{
|
||||||
|
delete this->Backtrace;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
cmListFileBacktrace const& cmTest::GetBacktrace() const
|
||||||
|
{
|
||||||
|
return *this->Backtrace;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -88,13 +98,6 @@ void cmTest::AppendProperty(const char* prop, const char* value)
|
||||||
this->Properties.AppendProperty(prop, value, cmProperty::TEST);
|
this->Properties.AppendProperty(prop, value, cmProperty::TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmTest::SetMakefile(cmMakefile* mf)
|
|
||||||
{
|
|
||||||
this->Makefile = mf;
|
|
||||||
this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmTest::DefineProperties(cmake *cm)
|
void cmTest::DefineProperties(cmake *cm)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "cmCustomCommand.h"
|
#include "cmCustomCommand.h"
|
||||||
#include "cmPropertyMap.h"
|
#include "cmPropertyMap.h"
|
||||||
class cmMakefile;
|
class cmMakefile;
|
||||||
|
class cmListFileBacktrace;
|
||||||
|
|
||||||
/** \class cmTest
|
/** \class cmTest
|
||||||
* \brief Represent a test
|
* \brief Represent a test
|
||||||
|
@ -31,7 +32,7 @@ class cmTest
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
cmTest();
|
cmTest(cmMakefile* mf);
|
||||||
~cmTest();
|
~cmTest();
|
||||||
|
|
||||||
///! Set the test name
|
///! Set the test name
|
||||||
|
@ -59,10 +60,12 @@ public:
|
||||||
// Define the properties
|
// Define the properties
|
||||||
static void DefineProperties(cmake *cm);
|
static void DefineProperties(cmake *cm);
|
||||||
|
|
||||||
///! Set the cmMakefile that owns this test
|
/** Get the cmMakefile instance that owns this test. */
|
||||||
void SetMakefile(cmMakefile *mf);
|
|
||||||
cmMakefile *GetMakefile() { return this->Makefile;};
|
cmMakefile *GetMakefile() { return this->Makefile;};
|
||||||
|
|
||||||
|
/** Get the backtrace of the command that created this test. */
|
||||||
|
cmListFileBacktrace const& GetBacktrace() const;
|
||||||
|
|
||||||
/** Get/Set whether this is an old-style test. */
|
/** Get/Set whether this is an old-style test. */
|
||||||
bool GetOldStyle() const { return this->OldStyle; }
|
bool GetOldStyle() const { return this->OldStyle; }
|
||||||
void SetOldStyle(bool b) { this->OldStyle = b; }
|
void SetOldStyle(bool b) { this->OldStyle = b; }
|
||||||
|
@ -74,9 +77,8 @@ private:
|
||||||
|
|
||||||
bool OldStyle;
|
bool OldStyle;
|
||||||
|
|
||||||
// The cmMakefile instance that owns this target. This should
|
|
||||||
// always be set.
|
|
||||||
cmMakefile* Makefile;
|
cmMakefile* Makefile;
|
||||||
|
cmListFileBacktrace* Backtrace;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue