summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CommandLine/ProfilingTest-check.cmake
diff options
context:
space:
mode:
authorWouter Klouwen <wouter.klouwen@youview.com>2019-02-02 09:06:36 (GMT)
committerWouter Klouwen <wouter.klouwen@youview.com>2020-03-07 13:36:27 (GMT)
commit9aa4640792bd99b232abfe826b0cb0ae72f6644a (patch)
tree6d576cb085d48a0073ddc09036a7e1a2b95df2d6 /Tests/RunCMake/CommandLine/ProfilingTest-check.cmake
parent8f122b45570e8357886df115d78007c4ea437daa (diff)
downloadCMake-9aa4640792bd99b232abfe826b0cb0ae72f6644a.zip
CMake-9aa4640792bd99b232abfe826b0cb0ae72f6644a.tar.gz
CMake-9aa4640792bd99b232abfe826b0cb0ae72f6644a.tar.bz2
cmake: add command line options to output script profiling data
For users of CMake who want to optimize their scripts if they take a while to run, this commit adds the ability to output profiling data. To enable this output, it adds the two command line parameters to select the output path and format. This commit adds the first profiling format of type ``google-trace``, which is the output is a JSON file containing Duration events as per the Google Trace Format specification: https://docs.google.com/document/d/1CvAClvFfyA5R- PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview#
Diffstat (limited to 'Tests/RunCMake/CommandLine/ProfilingTest-check.cmake')
-rw-r--r--Tests/RunCMake/CommandLine/ProfilingTest-check.cmake18
1 files changed, 18 insertions, 0 deletions
diff --git a/Tests/RunCMake/CommandLine/ProfilingTest-check.cmake b/Tests/RunCMake/CommandLine/ProfilingTest-check.cmake
new file mode 100644
index 0000000..19ece86
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/ProfilingTest-check.cmake
@@ -0,0 +1,18 @@
+if (NOT EXISTS ${ProfilingTestOutput})
+ set(RunCMake_TEST_FAILED "Expected ${ProfilingTestOutput} to exists")
+endif()
+
+file(READ "${ProfilingTestOutput}" JSON_HEADER LIMIT 2)
+if (NOT JSON_HEADER MATCHES "^\\[{")
+ set(RunCMake_TEST_FAILED "Expected valid JSON start")
+ return()
+endif()
+
+file(SIZE "${ProfilingTestOutput}" OUTPUT_SIZE)
+math(EXPR END_OFFSET "${OUTPUT_SIZE} -2 ")
+
+file(READ "${ProfilingTestOutput}" JSON_TRAILER OFFSET ${END_OFFSET})
+if (NOT JSON_TRAILER MATCHES "^}]$")
+ set(RunCMake_TEST_FAILED "Expected valid JSON end")
+ return()
+endif()