diff options
author | Asit Dhal <dhal.asitk@gmail.com> | 2020-06-12 04:59:32 +0200 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-06-15 12:39:37 -0400 |
commit | b5b60755228e3b1489d5cd43622c08d0d8d77bc9 (patch) | |
tree | 1c9b1df401df457c0db676bf1d90c98111fe85db | |
parent | 43b10e2411858ae7734c54480a8c0c6c3ccd659b (diff) | |
download | cmake-b5b60755228e3b1489d5cd43622c08d0d8d77bc9.tar.gz |
cmake: add dedicated error for -E compare_files invalid arguments
Return 2 when user provides invalid arguments
Fixes: #20815
-rw-r--r-- | Help/manual/cmake.1.rst | 3 | ||||
-rw-r--r-- | Source/cmcmd.cxx | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CommandLine/E_compare_files-invalid-arguments-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CommandLine/E_compare_files-invalid-arguments-stderr.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CommandLine/RunCMakeTest.cmake | 1 |
5 files changed, 6 insertions, 2 deletions
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 9becfc60d8..e4c662eaf5 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -566,7 +566,8 @@ Available commands are: ``compare_files [--ignore-eol] <file1> <file2>`` Check if ``<file1>`` is same as ``<file2>``. If files are the same, - then returns ``0``, if not it returns ``1``. The ``--ignore-eol`` option + then returns ``0``, if not it returns ``1``. In case of invalid + arguments, it retruns 2. The ``--ignore-eol`` option implies line-wise comparison and ignores LF/CRLF differences. ``copy <file>... <destination>`` diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index cbc8e8f4ae..6882fddea8 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -582,7 +582,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args) filesDiffer = cmsys::SystemTools::TextFilesDiffer(args[3], args[4]); } else { ::CMakeCommandUsage(args[0].c_str()); - return 1; + return 2; } if (filesDiffer) { diff --git a/Tests/RunCMake/CommandLine/E_compare_files-invalid-arguments-result.txt b/Tests/RunCMake/CommandLine/E_compare_files-invalid-arguments-result.txt new file mode 100644 index 0000000000..0cfbf08886 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_compare_files-invalid-arguments-result.txt @@ -0,0 +1 @@ +2 diff --git a/Tests/RunCMake/CommandLine/E_compare_files-invalid-arguments-stderr.txt b/Tests/RunCMake/CommandLine/E_compare_files-invalid-arguments-stderr.txt new file mode 100644 index 0000000000..8d98f9debd --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_compare_files-invalid-arguments-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 16fdeefa42..f291f15921 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -22,6 +22,7 @@ run_cmake_command(E_compare_files-different-eol ${CMAKE_COMMAND} -E compare_file run_cmake_command(E_compare_files-ignore-eol-same ${CMAKE_COMMAND} -E compare_files --ignore-eol ${RunCMake_SOURCE_DIR}/compare_files/lf ${RunCMake_SOURCE_DIR}/compare_files/crlf) run_cmake_command(E_compare_files-ignore-eol-empty ${CMAKE_COMMAND} -E compare_files --ignore-eol ${RunCMake_SOURCE_DIR}/compare_files/empty1 ${RunCMake_SOURCE_DIR}/compare_files/empty2) run_cmake_command(E_compare_files-ignore-eol-nonexistent ${CMAKE_COMMAND} -E compare_files --ignore-eol nonexistent_a nonexistent_b) +run_cmake_command(E_compare_files-invalid-arguments ${CMAKE_COMMAND} -E compare_files file1.txt file2.txt file3.txt) run_cmake_command(E_echo_append ${CMAKE_COMMAND} -E echo_append) run_cmake_command(E_rename-no-arg ${CMAKE_COMMAND} -E rename) run_cmake_command(E_server-arg ${CMAKE_COMMAND} -E server --extra-arg) |