Browse Source

Improve error message on unexpected end of file

Suggested-by: Stephen Kelly <[email protected]>
Brad King 9 years ago
parent
commit
1dda2ec55a

+ 1 - 2
Source/cmListFileCache.cxx

@@ -163,8 +163,7 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
   if (!token) {
     std::ostringstream error;
     /* clang-format off */
-    error << "Error in cmake code at\n" << this->FileName << ":"
-          << cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
+    error << "Unexpected end of file.\n"
           << "Parse error.  Function missing opening \"(\".";
     /* clang-format on */
     this->IssueError(error.str());

+ 1 - 0
Tests/RunCMake/Syntax/CommandEOF-result.txt

@@ -0,0 +1 @@
+1

+ 6 - 0
Tests/RunCMake/Syntax/CommandEOF-stderr.txt

@@ -0,0 +1,6 @@
+^CMake Error in CommandEOF.cmake:
+  Unexpected end of file.
+
+  Parse error.  Function missing opening "\(".
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$

+ 1 - 0
Tests/RunCMake/Syntax/CommandEOF.cmake

@@ -0,0 +1 @@
+message

+ 1 - 0
Tests/RunCMake/Syntax/RunCMakeTest.cmake

@@ -17,6 +17,7 @@ run_cmake(CommandSpaces)
 run_cmake(CommandTabs)
 run_cmake(CommandNewlines)
 run_cmake(CommandComments)
+run_cmake(CommandEOF)
 run_cmake(CommandError0)
 run_cmake(CommandError1)
 run_cmake(CommandError2)