aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Cord-Landwehr <cordlandwehr@kde.org>2020-09-26 10:32:56 +0000
committerAndreas Cord-Landwehr <cordlandwehr@kde.org>2020-09-26 10:32:56 +0000
commit7e73f1a972f13699c3c2cb80ad50c834b8a8464e (patch)
tree56c80b957ed9f6dd3f5130011ed866ae6512daaf /tests
parent250932795701e8c6f88bf150dcf4d3668c3173c7 (diff)
downloadextra-cmake-modules-7e73f1a972f13699c3c2cb80ad50c834b8a8464e.tar.gz
extra-cmake-modules-7e73f1a972f13699c3c2cb80ad50c834b8a8464e.tar.bz2
Introduce plausibility check for outbound licenes
When creating a library or executable, several source files are combined into a binary artifact that has an outbound license of its own. This test generator allows to check if the combined source files are compatible with the desired outbound license. Requirements for using these tests: - input source files must contain the SPDX-License-Information tag - python3 must be available - the "reuse spdx" tool must be available
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt5
-rw-r--r--tests/ECMCheckOutboundLicenseTest/CMakeLists.txt88
-rw-r--r--tests/ECMCheckOutboundLicenseTest/run_test.cmake.config0
-rw-r--r--tests/ECMCheckOutboundLicenseTest/testdata/BSD-2-Clause.cpp6
-rw-r--r--tests/ECMCheckOutboundLicenseTest/testdata/GPL-2.0-only.cpp6
-rw-r--r--tests/ECMCheckOutboundLicenseTest/testdata/GPL-2.0-or-later.cpp6
-rw-r--r--tests/ECMCheckOutboundLicenseTest/testdata/GPL-3.0-only.cpp6
-rw-r--r--tests/ECMCheckOutboundLicenseTest/testdata/LGPL-2.1-or-later.cpp6
-rw-r--r--tests/ECMCheckOutboundLicenseTest/testdata/LGPL-3.0-only.cpp6
9 files changed, 129 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 866df5bb..1901ca16 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -60,6 +60,11 @@ endmacro()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/find-modules)
+# enforce finding of ReuseTool in parent scope of module, beause
+# only here the module path can point into the source directory
+find_package(ReuseTool)
+add_subdirectory(ECMCheckOutboundLicenseTest)
+
# Skip if PyQt not available
find_file(SIP_Qt5Core_Mod_FILE
NAMES QtCoremod.sip
diff --git a/tests/ECMCheckOutboundLicenseTest/CMakeLists.txt b/tests/ECMCheckOutboundLicenseTest/CMakeLists.txt
new file mode 100644
index 00000000..1aab9a58
--- /dev/null
+++ b/tests/ECMCheckOutboundLicenseTest/CMakeLists.txt
@@ -0,0 +1,88 @@
+set(ECM_MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../modules)
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../modules)
+include(ECMCheckOutboundLicense)
+
+# check relative and absolute input paths
+ecm_check_outbound_license(
+LICENSES LGPL-2.1-only
+TEST_NAME absolute-path-handling
+FILES
+ testdata/BSD-2-Clause.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/testdata/LGPL-2.1-or-later.cpp
+)
+
+# check test case generation wihout TEST_NAME statement
+ecm_check_outbound_license(
+LICENSES LGPL-2.1-only
+FILES
+ testdata/BSD-2-Clause.cpp
+)
+
+# check multi license case
+ecm_check_outbound_license(
+LICENSES LGPL-2.1-only GPL-3.0-only
+TEST_NAME multiple-licenses
+FILES
+ testdata/BSD-2-Clause.cpp
+)
+
+
+# check for valid LGPL-2.1-only
+ecm_check_outbound_license(
+LICENSES LGPL-2.1-only
+TEST_NAME valid-LGPL-2.1-only
+FILES
+ testdata/BSD-2-Clause.cpp
+ testdata/LGPL-2.1-or-later.cpp
+)
+
+# check for valid LGPL-3.0-only
+ecm_check_outbound_license(
+LICENSES LGPL-3.0-only
+TEST_NAME valid-LGPL-3.0-only
+FILES
+ testdata/BSD-2-Clause.cpp
+ testdata/LGPL-2.1-or-later.cpp
+ testdata/LGPL-3.0-only.cpp
+)
+
+# check for valid GPL-2.0-only
+ecm_check_outbound_license(
+LICENSES GPL-2.0-only
+TEST_NAME valid-GPL-2.0-only
+FILES
+ testdata/BSD-2-Clause.cpp
+ testdata/LGPL-2.1-or-later.cpp
+ testdata/GPL-2.0-only.cpp
+)
+
+# check for valid GPL-3.0-only
+ecm_check_outbound_license(
+LICENSES GPL-3.0-only
+TEST_NAME valid-GPL-3.0-only
+FILES
+ testdata/BSD-2-Clause.cpp
+ testdata/LGPL-2.1-or-later.cpp
+ testdata/LGPL-3.0-only.cpp
+ testdata/GPL-3.0-only.cpp
+)
+
+# check for invalid GPL-3.0-only
+ecm_check_outbound_license(
+LICENSES LGPL-2.1-only
+TEST_NAME invalid-LGPL-2.1-only
+FILES
+ testdata/LGPL-2.0-only.cpp
+ testdata/GPL-3.0-only.cpp
+WILL_FAIL
+)
+
+# check for invalid GPL-3.0-only
+ecm_check_outbound_license(
+LICENSES GPL-3.0-only
+TEST_NAME invalid-GPL-3.0-only
+FILES
+ testdata/GPL-2.0-only.cpp
+ testdata/GPL-3.0-only.cpp
+WILL_FAIL
+)
diff --git a/tests/ECMCheckOutboundLicenseTest/run_test.cmake.config b/tests/ECMCheckOutboundLicenseTest/run_test.cmake.config
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/ECMCheckOutboundLicenseTest/run_test.cmake.config
diff --git a/tests/ECMCheckOutboundLicenseTest/testdata/BSD-2-Clause.cpp b/tests/ECMCheckOutboundLicenseTest/testdata/BSD-2-Clause.cpp
new file mode 100644
index 00000000..18c14530
--- /dev/null
+++ b/tests/ECMCheckOutboundLicenseTest/testdata/BSD-2-Clause.cpp
@@ -0,0 +1,6 @@
+/*
+ SPDX-FileCopyrightText: 2020 Jane Doe <nomail@example.com>
+ SPDX-License-Identifier: BSD-2-Clause
+*/
+
+// nothing in here, it is only a test
diff --git a/tests/ECMCheckOutboundLicenseTest/testdata/GPL-2.0-only.cpp b/tests/ECMCheckOutboundLicenseTest/testdata/GPL-2.0-only.cpp
new file mode 100644
index 00000000..7c227947
--- /dev/null
+++ b/tests/ECMCheckOutboundLicenseTest/testdata/GPL-2.0-only.cpp
@@ -0,0 +1,6 @@
+/*
+ SPDX-FileCopyrightText: 2020 John Doe <nomail@example.com>
+ SPDX-License-Identifier: GPL-2.0-only
+*/
+
+// nothing in here, it is only a test
diff --git a/tests/ECMCheckOutboundLicenseTest/testdata/GPL-2.0-or-later.cpp b/tests/ECMCheckOutboundLicenseTest/testdata/GPL-2.0-or-later.cpp
new file mode 100644
index 00000000..58769c51
--- /dev/null
+++ b/tests/ECMCheckOutboundLicenseTest/testdata/GPL-2.0-or-later.cpp
@@ -0,0 +1,6 @@
+/*
+ SPDX-FileCopyrightText: 2020 John Doe <nomail@example.com>
+ SPDX-License-Identifier: GPL-2.0-or-later
+*/
+
+// nothing in here, it is only a test
diff --git a/tests/ECMCheckOutboundLicenseTest/testdata/GPL-3.0-only.cpp b/tests/ECMCheckOutboundLicenseTest/testdata/GPL-3.0-only.cpp
new file mode 100644
index 00000000..8261c2ba
--- /dev/null
+++ b/tests/ECMCheckOutboundLicenseTest/testdata/GPL-3.0-only.cpp
@@ -0,0 +1,6 @@
+/*
+ SPDX-FileCopyrightText: 2020 John Doe <nomail@example.com>
+ SPDX-License-Identifier: GPL-3.0-only
+*/
+
+// nothing in here, it is only a test
diff --git a/tests/ECMCheckOutboundLicenseTest/testdata/LGPL-2.1-or-later.cpp b/tests/ECMCheckOutboundLicenseTest/testdata/LGPL-2.1-or-later.cpp
new file mode 100644
index 00000000..44b52a38
--- /dev/null
+++ b/tests/ECMCheckOutboundLicenseTest/testdata/LGPL-2.1-or-later.cpp
@@ -0,0 +1,6 @@
+/*
+ SPDX-FileCopyrightText: 2020 John Doe <nomail@example.com>
+ SPDX-License-Identifier: LGPL-2.1-or-later
+*/
+
+// nothing in here, it is only a test
diff --git a/tests/ECMCheckOutboundLicenseTest/testdata/LGPL-3.0-only.cpp b/tests/ECMCheckOutboundLicenseTest/testdata/LGPL-3.0-only.cpp
new file mode 100644
index 00000000..3ffd899b
--- /dev/null
+++ b/tests/ECMCheckOutboundLicenseTest/testdata/LGPL-3.0-only.cpp
@@ -0,0 +1,6 @@
+/*
+ SPDX-FileCopyrightText: 2020 Jane Doe <nomail@example.com>
+ SPDX-License-Identifier: LGPL-3.0-only
+*/
+
+// nothing in here, it is only a test