From 161e599b840d77b95fcd73c1c86facae2c52e4ff Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <frank.winklmeier@cern.ch>
Date: Tue, 30 Apr 2024 16:06:13 +0200
Subject: [PATCH 1/2] Add Find-modules for flake8 bugbear and builtins

Add Find-modules for the flake8 plugins `bugbear` and `builtins`.
Install the former by default via the `flake8_atlas` package.

Requires LCG_104d_ATLAS_15/16 or LCG_105b_ATLAS_1/2.
---
 .../AtlasLCG/modules/Findflake8_bugbear.cmake | 23 +++++++++++++++++++
 .../modules/Findflake8_builtins.cmake         | 23 +++++++++++++++++++
 External/flake8_atlas/CMakeLists.txt          |  3 ++-
 3 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 Build/AtlasLCG/modules/Findflake8_bugbear.cmake
 create mode 100644 Build/AtlasLCG/modules/Findflake8_builtins.cmake

diff --git a/Build/AtlasLCG/modules/Findflake8_bugbear.cmake b/Build/AtlasLCG/modules/Findflake8_bugbear.cmake
new file mode 100644
index 00000000..d1ccaa93
--- /dev/null
+++ b/Build/AtlasLCG/modules/Findflake8_bugbear.cmake
@@ -0,0 +1,23 @@
+# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
+#
+# Sets:
+#  FLAKE8_BUGBEAR_PYTHON_PATH
+#
+# Can be steered by FLAKE8_BUGBEAR_LCGROOT.
+#
+
+# The LCG include(s).
+include( LCGFunctions )
+
+# Find it.
+lcg_python_external_module( NAME flake8_bugbear
+   MODULE_NAME bugbear
+   PYTHON_NAMES bugbear.py bugbear/__init__.py )
+
+# Handle the standard find_package arguments.
+include( FindPackageHandleStandardArgs )
+find_package_handle_standard_args( flake8_bugbear DEFAULT_MSG
+   _FLAKE8_BUGBEAR_PYTHON_PATH )
+
+# Set up the RPM dependency.
+lcg_need_rpm( flake8_bugbear )
diff --git a/Build/AtlasLCG/modules/Findflake8_builtins.cmake b/Build/AtlasLCG/modules/Findflake8_builtins.cmake
new file mode 100644
index 00000000..b5ec1e32
--- /dev/null
+++ b/Build/AtlasLCG/modules/Findflake8_builtins.cmake
@@ -0,0 +1,23 @@
+# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
+#
+# Sets:
+#  FLAKE8_BUILTINS_PYTHON_PATH
+#
+# Can be steered by FLAKE8_BUILTINS_LCGROOT.
+#
+
+# The LCG include(s).
+include( LCGFunctions )
+
+# Find it.
+lcg_python_external_module( NAME flake8_builtins
+   MODULE_NAME flake8_builtins
+   PYTHON_NAMES flake8_builtins.py flake8_builtins/__init__.py )
+
+# Handle the standard find_package arguments.
+include( FindPackageHandleStandardArgs )
+find_package_handle_standard_args( flake8_builtins DEFAULT_MSG
+   _FLAKE8_BUILTINS_PYTHON_PATH )
+
+# Set up the RPM dependency.
+lcg_need_rpm( flake8_builtins )
diff --git a/External/flake8_atlas/CMakeLists.txt b/External/flake8_atlas/CMakeLists.txt
index a154eb9a..58a12bf7 100644
--- a/External/flake8_atlas/CMakeLists.txt
+++ b/External/flake8_atlas/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 
 # The name of the package:
 atlas_subdir( flake8_atlas )
@@ -6,6 +6,7 @@ atlas_subdir( flake8_atlas )
 # External(s) needed::
 find_package( Python COMPONENTS Interpreter )
 find_package( flake8 )
+find_package( flake8_bugbear )
 find_package( pip )
 find_package( libffi )
 
-- 
GitLab


From ace5f9095caf9f2642b7918a5cd2d776fe50a540 Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <frank.winklmeier@cern.ch>
Date: Wed, 1 May 2024 08:39:59 +0200
Subject: [PATCH 2/2] Add unit test for LCG layer

---
 Build/Tests/UnitTests/CMakeLists.txt | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/Build/Tests/UnitTests/CMakeLists.txt b/Build/Tests/UnitTests/CMakeLists.txt
index 1d7d8d46..21cd703b 100644
--- a/Build/Tests/UnitTests/CMakeLists.txt
+++ b/Build/Tests/UnitTests/CMakeLists.txt
@@ -95,10 +95,15 @@ list( APPEND _ignore "HJets" )              # only available for gcc8
 list( APPEND _ignore "dcap;gfal;srm_ifce" ) # grid tools not available on el9
 list( APPEND _ignore "libzip" )             # only available if Sherpa>=3
 list( APPEND _ignore "PNG" )                # depends on libzip
-list( APPEND _ignore "MCFM" )               # Is not in LCG_104 but only from layer LCG_104c_ATLAS_3 onwards
-list( APPEND _ignore "HighFive" )           # Is not in LCG_104d but only from layer LCG_104d_ATLAS_9 onwards
 
-# LCG base release + ALRB
+# Select packages to only test in LCG ATLAS layer:
+set( _select)
+list( APPEND _select "MCFM" )               # Is not in LCG_104 but only from layer LCG_104c_ATLAS_3 onwards
+list( APPEND _select "HighFive" )           # Is not in LCG_104d but only from layer LCG_104d_ATLAS_9 onwards
+list( APPEND _select "flake8_bugbear" )     # Is not in LCG_104d but only from layer LCG_104d_ATLAS_15 onwards
+list( APPEND _ignore ${_select} )           # ignore these in the full test
+
+# LCG base release + ALRB:
 atlas_add_test( find_modules_lcg
    SCRIPT source \${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh &&
           lsetup cppcheck &&
@@ -108,3 +113,13 @@ atlas_add_test( find_modules_lcg
             ${CMAKE_CURRENT_SOURCE_DIR}/../../AtlasLCG/test
    PRIVATE_WORKING_DIRECTORY
    PROPERTIES TIMEOUT 300 )
+
+# LCG ATLAS layer:
+atlas_add_test( find_modules_lcg_layer
+   SCRIPT source \${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh &&
+          ${CMAKE_COMMAND} --fresh -DLCG_VERSION_NUMBER="104" -DLCG_VERSION_POSTFIX="d_ATLAS_15"
+            -DATLAS_LCGTEST_FIND_MODE=REQUIRED
+            -DATLAS_LCGTEST_SELECT="${_select}"
+            ${CMAKE_CURRENT_SOURCE_DIR}/../../AtlasLCG/test
+   PRIVATE_WORKING_DIRECTORY
+   PROPERTIES TIMEOUT 300 )
-- 
GitLab