mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
ctest: Explicitly normalize input paths as they exist on disk
This commit is contained in:
@@ -580,9 +580,6 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
|
||||
int numErrorsAllowed = this->MaxErrors;
|
||||
int numWarningsAllowed = this->MaxWarnings;
|
||||
std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory");
|
||||
// make sure the source dir is in the correct case on windows
|
||||
// via a call to collapse full path.
|
||||
srcdir = cmStrCat(cmSystemTools::CollapseFullPath(srcdir), '/');
|
||||
for (it = ew.begin();
|
||||
it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++) {
|
||||
cmCTestBuildErrorWarning* cm = &(*it);
|
||||
@@ -613,8 +610,9 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
|
||||
}
|
||||
} else {
|
||||
// make sure it is a full path with the correct case
|
||||
cm->SourceFile = cmSystemTools::CollapseFullPath(cm->SourceFile);
|
||||
cmSystemTools::ReplaceString(cm->SourceFile, srcdir.c_str(), "");
|
||||
cm->SourceFile =
|
||||
cmSystemTools::ToNormalizedPathOnDisk(cm->SourceFile);
|
||||
cmSystemTools::ReplaceString(cm->SourceFile, srcdir, "");
|
||||
}
|
||||
cm->LineNumber = atoi(re->match(rit.LineIndex).c_str());
|
||||
break;
|
||||
|
||||
@@ -146,7 +146,7 @@ std::string cmCTestGIT::FindTopDir()
|
||||
!cdup.empty()) {
|
||||
top_dir += "/";
|
||||
top_dir += cdup;
|
||||
top_dir = cmSystemTools::CollapseFullPath(top_dir);
|
||||
top_dir = cmSystemTools::ToNormalizedPathOnDisk(top_dir);
|
||||
}
|
||||
return top_dir;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "cmCTestScriptHandler.h"
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status)
|
||||
@@ -36,7 +37,8 @@ bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args,
|
||||
++i;
|
||||
} else {
|
||||
int ret;
|
||||
cmCTestScriptHandler::RunScript(this->CTest, this->Makefile, args[i],
|
||||
cmCTestScriptHandler::RunScript(this->CTest, this->Makefile,
|
||||
cmSystemTools::CollapseFullPath(args[i]),
|
||||
!np, &ret);
|
||||
this->Makefile->AddDefinition(returnVariable, std::to_string(ret));
|
||||
}
|
||||
|
||||
@@ -74,9 +74,8 @@ int cmCTestScriptHandler::ProcessHandler()
|
||||
int res = 0;
|
||||
for (size_t i = 0; i < this->ConfigurationScripts.size(); ++i) {
|
||||
// for each script run it
|
||||
res |= this->RunConfigurationScript(
|
||||
cmSystemTools::CollapseFullPath(this->ConfigurationScripts[i]),
|
||||
this->ScriptProcessScope[i]);
|
||||
res |= this->RunConfigurationScript(this->ConfigurationScripts[i],
|
||||
this->ScriptProcessScope[i]);
|
||||
}
|
||||
if (res) {
|
||||
return -1;
|
||||
|
||||
@@ -1786,7 +1786,7 @@ std::string cmCTestTestHandler::FindExecutable(
|
||||
for (unsigned int ai = 0; ai < attempted.size() && fullPath.empty(); ++ai) {
|
||||
// first check without exe extension
|
||||
if (cmSystemTools::FileExists(attempted[ai], true)) {
|
||||
fullPath = cmSystemTools::CollapseFullPath(attempted[ai]);
|
||||
fullPath = cmSystemTools::ToNormalizedPathOnDisk(attempted[ai]);
|
||||
resultingConfig = attemptedConfigs[ai];
|
||||
}
|
||||
// then try with the exe extension
|
||||
@@ -1795,7 +1795,7 @@ std::string cmCTestTestHandler::FindExecutable(
|
||||
tempPath =
|
||||
cmStrCat(attempted[ai], cmSystemTools::GetExecutableExtension());
|
||||
if (cmSystemTools::FileExists(tempPath, true)) {
|
||||
fullPath = cmSystemTools::CollapseFullPath(tempPath);
|
||||
fullPath = cmSystemTools::ToNormalizedPathOnDisk(tempPath);
|
||||
resultingConfig = attemptedConfigs[ai];
|
||||
} else {
|
||||
failed.push_back(tempPath);
|
||||
|
||||
@@ -818,7 +818,7 @@ int cmCTest::ProcessSteps()
|
||||
const std::string currDir = cmSystemTools::GetCurrentWorkingDirectory();
|
||||
std::string workDir = currDir;
|
||||
if (!this->Impl->TestDir.empty()) {
|
||||
workDir = cmSystemTools::CollapseFullPath(this->Impl->TestDir);
|
||||
workDir = cmSystemTools::ToNormalizedPathOnDisk(this->Impl->TestDir);
|
||||
}
|
||||
|
||||
cmWorkingDirectory changeDir(workDir);
|
||||
@@ -2104,21 +2104,24 @@ int cmCTest::Run(std::vector<std::string> const& args)
|
||||
[&runScripts, &SRArgumentSpecified](std::string const& script) -> bool {
|
||||
// -SR is an internal argument, -SP should be ignored when it is passed
|
||||
if (!SRArgumentSpecified) {
|
||||
runScripts.emplace_back(script, false);
|
||||
runScripts.emplace_back(cmSystemTools::ToNormalizedPathOnDisk(script),
|
||||
false);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
auto const dashSR =
|
||||
[&runScripts, &SRArgumentSpecified](std::string const& script) -> bool {
|
||||
SRArgumentSpecified = true;
|
||||
runScripts.emplace_back(script, true);
|
||||
runScripts.emplace_back(cmSystemTools::ToNormalizedPathOnDisk(script),
|
||||
true);
|
||||
return true;
|
||||
};
|
||||
auto const dash_S =
|
||||
[&runScripts, &SRArgumentSpecified](std::string const& script) -> bool {
|
||||
// -SR is an internal argument, -S should be ignored when it is passed
|
||||
if (!SRArgumentSpecified) {
|
||||
runScripts.emplace_back(script, true);
|
||||
runScripts.emplace_back(cmSystemTools::ToNormalizedPathOnDisk(script),
|
||||
true);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
@@ -2274,9 +2277,9 @@ int cmCTest::Run(std::vector<std::string> const& args)
|
||||
return false;
|
||||
}
|
||||
this->Impl->BuildAndTest.SourceDir =
|
||||
cmSystemTools::CollapseFullPath(dirList[0]);
|
||||
cmSystemTools::ToNormalizedPathOnDisk(dirList[0]);
|
||||
this->Impl->BuildAndTest.BinaryDir =
|
||||
cmSystemTools::CollapseFullPath(dirList[1]);
|
||||
cmSystemTools::ToNormalizedPathOnDisk(dirList[1]);
|
||||
cmSystemTools::MakeDirectory(this->Impl->BuildAndTest.BinaryDir);
|
||||
return true;
|
||||
} },
|
||||
@@ -2847,7 +2850,7 @@ int cmCTest::ExecuteTests()
|
||||
const std::string currDir = cmSystemTools::GetCurrentWorkingDirectory();
|
||||
std::string workDir = currDir;
|
||||
if (!this->Impl->TestDir.empty()) {
|
||||
workDir = cmSystemTools::CollapseFullPath(this->Impl->TestDir);
|
||||
workDir = cmSystemTools::ToNormalizedPathOnDisk(this->Impl->TestDir);
|
||||
}
|
||||
|
||||
cmWorkingDirectory changeDir(workDir);
|
||||
@@ -3039,10 +3042,9 @@ void cmCTest::PopulateCustomInteger(cmMakefile* mf, const std::string& def,
|
||||
|
||||
std::string cmCTest::GetShortPathToFile(const std::string& cfname)
|
||||
{
|
||||
const std::string& sourceDir = cmSystemTools::CollapseFullPath(
|
||||
this->GetCTestConfiguration("SourceDirectory"));
|
||||
const std::string& buildDir = cmSystemTools::CollapseFullPath(
|
||||
this->GetCTestConfiguration("BuildDirectory"));
|
||||
const std::string& sourceDir =
|
||||
this->GetCTestConfiguration("SourceDirectory");
|
||||
const std::string& buildDir = this->GetCTestConfiguration("BuildDirectory");
|
||||
std::string fname = cmSystemTools::CollapseFullPath(cfname);
|
||||
|
||||
// Find relative paths to both directories
|
||||
|
||||
Reference in New Issue
Block a user