diff options
-rw-r--r-- | kde-modules/KDECMakeSettings.cmake | 10 | ||||
-rw-r--r-- | kde-modules/appstreamtest.cmake | 27 |
2 files changed, 37 insertions, 0 deletions
diff --git a/kde-modules/KDECMakeSettings.cmake b/kde-modules/KDECMakeSettings.cmake index dd37e7f1..46fd10a8 100644 --- a/kde-modules/KDECMakeSettings.cmake +++ b/kde-modules/KDECMakeSettings.cmake @@ -130,6 +130,15 @@ endif() ################ Testing setup #################################### +find_program(APPSTREAMCLI appstreamcli) +function(appstreamtest) + if(APPSTREAMCLI AND NOT _done) + set(_done TRUE) + add_test(NAME appstreamtest COMMAND cmake -DAPPSTREAMCLI=${APPSTREAMCLI} -DINSTALL_FILES=${CMAKE_BINARY_DIR}/install_manifest.txt -P ${CMAKE_CURRENT_LIST_DIR}/appstreamtest.cmake) + else() + message(STATUS "Could not set up the appstream test. appstreamcli is missing.") + endif() +endfunction() if(NOT KDE_SKIP_TEST_SETTINGS) @@ -143,6 +152,7 @@ if(NOT KDE_SKIP_TEST_SETTINGS) option(BUILD_TESTING "Build the testing tree." ON) if(BUILD_TESTING) enable_testing() + appstreamtest() endif () endif () diff --git a/kde-modules/appstreamtest.cmake b/kde-modules/appstreamtest.cmake new file mode 100644 index 00000000..e524bacb --- /dev/null +++ b/kde-modules/appstreamtest.cmake @@ -0,0 +1,27 @@ +file(READ "${INSTALL_FILES}" out) +string(REPLACE "\n" ";" out "${out}") + +set(metadatafiles) +foreach(file IN LISTS out) + if(NOT (file MATCHES ".+\\.appdata.xml" OR file MATCHES ".+\\.metainfo.xml")) + continue() + endif() + + list(APPEND metadatafiles ${file}) +endforeach() + +if(metadatafiles) + set(appstreamcliout "") + execute_process(COMMAND ${APPSTREAMCLI} validate ${metadatafiles} + ERROR_VARIABLE appstreamcliout + OUTPUT_VARIABLE appstreamcliout + RESULT_VARIABLE result + ) + + if(result EQUAL 0) + set(msgType STATUS) + else() + set(msgType FATAL_ERROR) + endif() + message(${msgType} ${appstreamcliout}) +endif() |