diff options
author | Wouter Klouwen <wouter.klouwen@youview.com> | 2018-11-20 10:17:33 (GMT) |
---|---|---|
committer | Wouter Klouwen <wouter.klouwen@youview.com> | 2018-11-27 08:50:36 (GMT) |
commit | 12b471e828e4462cce4354c87bb4fe18aeb600e3 (patch) | |
tree | ac94c73bfff84d0f6af70104ec4ab686e81a27b3 /Tests/RunCMake/file | |
parent | d851a8b457251a577f10055d9fb277b75a82da6c (diff) | |
download | CMake-12b471e828e4462cce4354c87bb4fe18aeb600e3.zip CMake-12b471e828e4462cce4354c87bb4fe18aeb600e3.tar.gz CMake-12b471e828e4462cce4354c87bb4fe18aeb600e3.tar.bz2 |
file: add SIZE option
This commit adds the SIZE option to file(). It returns the file size of
the given path if it exists and produces an error if not.
Diffstat (limited to 'Tests/RunCMake/file')
-rw-r--r-- | Tests/RunCMake/file/RunCMakeTest.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/file/SIZE-error-does-not-exist-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/file/SIZE-error-does-not-exist-stderr.txt | 5 | ||||
-rw-r--r-- | Tests/RunCMake/file/SIZE-error-does-not-exist.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/file/SIZE.cmake | 9 |
5 files changed, 20 insertions, 0 deletions
diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index b383230..b9d76bf 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -36,6 +36,8 @@ run_cmake(READ_ELF) run_cmake(GLOB) run_cmake(GLOB_RECURSE) run_cmake(GLOB_RECURSE-noexp-FOLLOW_SYMLINKS) +run_cmake(SIZE) +run_cmake(SIZE-error-does-not-exist) # tests are valid both for GLOB and GLOB_RECURSE run_cmake(GLOB-sort-dedup) diff --git a/Tests/RunCMake/file/SIZE-error-does-not-exist-result.txt b/Tests/RunCMake/file/SIZE-error-does-not-exist-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/SIZE-error-does-not-exist-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/SIZE-error-does-not-exist-stderr.txt b/Tests/RunCMake/file/SIZE-error-does-not-exist-stderr.txt new file mode 100644 index 0000000..b797a41 --- /dev/null +++ b/Tests/RunCMake/file/SIZE-error-does-not-exist-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at SIZE-error-does-not-exist.cmake:[0-9]+ \(file\): + file SIZE requested of path that is not readable + /a/file/that/does-not-exist +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file/SIZE-error-does-not-exist.cmake b/Tests/RunCMake/file/SIZE-error-does-not-exist.cmake new file mode 100644 index 0000000..edcc222 --- /dev/null +++ b/Tests/RunCMake/file/SIZE-error-does-not-exist.cmake @@ -0,0 +1,3 @@ +set(file "/a/file/that/does-not-exist") + +file(SIZE "${file}" CALCULATED_SIZE) diff --git a/Tests/RunCMake/file/SIZE.cmake b/Tests/RunCMake/file/SIZE.cmake new file mode 100644 index 0000000..4d9dbd2 --- /dev/null +++ b/Tests/RunCMake/file/SIZE.cmake @@ -0,0 +1,9 @@ +set(file "${CMAKE_CURRENT_BINARY_DIR}/a-test-file") + +file(WRITE "${file}" "test") + +file(SIZE "${file}" CALCULATED_SIZE) + +if (NOT CALCULATED_SIZE EQUAL 4) + message(FATAL_ERROR "Unexpected file size") +endif() |