mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
file(COPY_FILE): Report if failure occurred on input or output path
When we know whether a failure was associated with the input or the output path, include this information in the error message.
This commit is contained in:
@@ -1140,7 +1140,7 @@ cmSystemTools::CopyResult cmSystemTools::CopySingleFile(
|
||||
return CopyResult::Success;
|
||||
}
|
||||
|
||||
cmsys::Status status;
|
||||
cmsys::SystemTools::CopyStatus status;
|
||||
status = cmsys::SystemTools::CloneFileContent(oldname, newname);
|
||||
if (!status) {
|
||||
// if cloning did not succeed, fall back to blockwise copy
|
||||
@@ -1149,14 +1149,24 @@ cmSystemTools::CopyResult cmSystemTools::CopySingleFile(
|
||||
if (!status) {
|
||||
if (err) {
|
||||
*err = status.GetString();
|
||||
switch (status.Path) {
|
||||
case cmsys::SystemTools::CopyStatus::SourcePath:
|
||||
*err = cmStrCat(*err, " (input)");
|
||||
break;
|
||||
case cmsys::SystemTools::CopyStatus::DestPath:
|
||||
*err = cmStrCat(*err, " (output)");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return CopyResult::Failure;
|
||||
}
|
||||
if (perms) {
|
||||
status = SystemTools::SetPermissions(newname, perm);
|
||||
if (!status) {
|
||||
perms = SystemTools::SetPermissions(newname, perm);
|
||||
if (!perms) {
|
||||
if (err) {
|
||||
*err = status.GetString();
|
||||
*err = cmStrCat(perms.GetString(), " (output)");
|
||||
}
|
||||
return CopyResult::Failure;
|
||||
}
|
||||
|
||||
1
Tests/RunCMake/file/COPY_FILE-input-missing-result.txt
Normal file
1
Tests/RunCMake/file/COPY_FILE-input-missing-result.txt
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
14
Tests/RunCMake/file/COPY_FILE-input-missing-stderr.txt
Normal file
14
Tests/RunCMake/file/COPY_FILE-input-missing-stderr.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
^CMake Error at [^
|
||||
]*/Tests/RunCMake/file/COPY_FILE-input-missing.cmake:[0-9]+ \(file\):
|
||||
file COPY_FILE failed to copy
|
||||
|
||||
[^
|
||||
]*/Tests/RunCMake/file/COPY_FILE-input-missing-build/input-missing
|
||||
|
||||
to
|
||||
|
||||
[^
|
||||
]*/Tests/RunCMake/file/COPY_FILE-input-missing-build/output
|
||||
|
||||
because: [^
|
||||
]+ \(input\)$
|
||||
3
Tests/RunCMake/file/COPY_FILE-input-missing.cmake
Normal file
3
Tests/RunCMake/file/COPY_FILE-input-missing.cmake
Normal file
@@ -0,0 +1,3 @@
|
||||
set(oldname "${CMAKE_CURRENT_BINARY_DIR}/input-missing")
|
||||
set(newname "${CMAKE_CURRENT_BINARY_DIR}/output")
|
||||
file(COPY_FILE "${oldname}" "${newname}")
|
||||
1
Tests/RunCMake/file/COPY_FILE-output-missing-result.txt
Normal file
1
Tests/RunCMake/file/COPY_FILE-output-missing-result.txt
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
14
Tests/RunCMake/file/COPY_FILE-output-missing-stderr.txt
Normal file
14
Tests/RunCMake/file/COPY_FILE-output-missing-stderr.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
^CMake Error at [^
|
||||
]*/Tests/RunCMake/file/COPY_FILE-output-missing.cmake:[0-9]+ \(file\):
|
||||
file COPY_FILE failed to copy
|
||||
|
||||
[^
|
||||
]*/Tests/RunCMake/file/COPY_FILE-output-missing-build/input
|
||||
|
||||
to
|
||||
|
||||
[^
|
||||
]*/Tests/RunCMake/file/COPY_FILE-output-missing-build/output-missing/output
|
||||
|
||||
because: [^
|
||||
]+ \(output\)$
|
||||
4
Tests/RunCMake/file/COPY_FILE-output-missing.cmake
Normal file
4
Tests/RunCMake/file/COPY_FILE-output-missing.cmake
Normal file
@@ -0,0 +1,4 @@
|
||||
set(oldname "${CMAKE_CURRENT_BINARY_DIR}/input")
|
||||
set(newname "${CMAKE_CURRENT_BINARY_DIR}/output-missing/output")
|
||||
file(WRITE "${oldname}" "")
|
||||
file(COPY_FILE "${oldname}" "${newname}")
|
||||
@@ -65,6 +65,8 @@ run_cmake_script(COPY_FILE-file-ONLY_IF_DIFFERENT-no-overwrite)
|
||||
run_cmake_script(COPY_FILE-link-to-file)
|
||||
run_cmake_script(COPY_FILE-arg-missing)
|
||||
run_cmake_script(COPY_FILE-arg-unknown)
|
||||
run_cmake_script(COPY_FILE-input-missing)
|
||||
run_cmake_script(COPY_FILE-output-missing)
|
||||
|
||||
run_cmake_script(RENAME-file-replace)
|
||||
run_cmake_script(RENAME-file-to-file)
|
||||
|
||||
Reference in New Issue
Block a user