summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-08-11 13:07:28 (GMT)
committerBrad King <brad.king@kitware.com>2009-08-11 13:07:28 (GMT)
commit0bc050677f71651ae7ef403ec063af06b6ecd751 (patch)
tree9114397bec4c196b3b8cdd9ae7a91371ac35719b /Source
parent6e3c6a1a8028bf02785468fc23244ef5403beb55 (diff)
downloadCMake-0bc050677f71651ae7ef403ec063af06b6ecd751.zip
CMake-0bc050677f71651ae7ef403ec063af06b6ecd751.tar.gz
CMake-0bc050677f71651ae7ef403ec063af06b6ecd751.tar.bz2
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.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmMakefile.cxx3
-rw-r--r--Source/cmTest.cxx21
-rw-r--r--Source/cmTest.h14
3 files changed, 21 insertions, 17 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 5057ef4..ef9a726 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -3314,9 +3314,8 @@ cmTest* cmMakefile::CreateTest(const char* testName)
{
return test;
}
- test = new cmTest;
+ test = new cmTest(this);
test->SetName(testName);
- test->SetMakefile(this);
this->Tests[testName] = test;
return test;
}
diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx
index 5cf7598..8686e06 100644
--- a/Source/cmTest.cxx
+++ b/Source/cmTest.cxx
@@ -21,15 +21,25 @@
#include "cmMakefile.h"
//----------------------------------------------------------------------------
-cmTest::cmTest()
+cmTest::cmTest(cmMakefile* mf)
{
- this->Makefile = 0;
+ this->Makefile = mf;
this->OldStyle = true;
+ this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
+ this->Backtrace = new cmListFileBacktrace;
+ this->Makefile->GetBacktrace(*this->Backtrace);
}
//----------------------------------------------------------------------------
cmTest::~cmTest()
{
+ delete this->Backtrace;
+}
+
+//----------------------------------------------------------------------------
+cmListFileBacktrace const& cmTest::GetBacktrace() const
+{
+ return *this->Backtrace;
}
//----------------------------------------------------------------------------
@@ -89,13 +99,6 @@ void cmTest::AppendProperty(const char* prop, const char* value)
}
//----------------------------------------------------------------------------
-void cmTest::SetMakefile(cmMakefile* mf)
-{
- this->Makefile = mf;
- this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
-}
-
-//----------------------------------------------------------------------------
void cmTest::DefineProperties(cmake *cm)
{
cm->DefineProperty
diff --git a/Source/cmTest.h b/Source/cmTest.h
index 0d601ec..76c79d5 100644
--- a/Source/cmTest.h
+++ b/Source/cmTest.h
@@ -20,6 +20,7 @@
#include "cmCustomCommand.h"
#include "cmPropertyMap.h"
class cmMakefile;
+class cmListFileBacktrace;
/** \class cmTest
* \brief Represent a test
@@ -31,7 +32,7 @@ class cmTest
public:
/**
*/
- cmTest();
+ cmTest(cmMakefile* mf);
~cmTest();
///! Set the test name
@@ -59,10 +60,12 @@ public:
// Define the properties
static void DefineProperties(cmake *cm);
- ///! Set the cmMakefile that owns this test
- void SetMakefile(cmMakefile *mf);
+ /** Get the cmMakefile instance that owns this test. */
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. */
bool GetOldStyle() const { return this->OldStyle; }
void SetOldStyle(bool b) { this->OldStyle = b; }
@@ -74,9 +77,8 @@ private:
bool OldStyle;
- // The cmMakefile instance that owns this target. This should
- // always be set.
- cmMakefile* Makefile;
+ cmMakefile* Makefile;
+ cmListFileBacktrace* Backtrace;
};
#endif