From e777012520a5298f8b74038b6f774e03c02ff835 Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Mon, 29 Jan 2024 13:28:08 +0100 Subject: [PATCH 1/9] [INFRA] Remove doc test --- .github/workflows/ci_documentation.yml | 63 ---- CMakeLists.txt | 4 - doc/CMakeLists.txt | 27 -- doc/README.md | 7 - doc/doxygen_cfg | 404 ------------------------- 5 files changed, 505 deletions(-) delete mode 100644 .github/workflows/ci_documentation.yml delete mode 100644 doc/CMakeLists.txt delete mode 100644 doc/README.md delete mode 100644 doc/doxygen_cfg diff --git a/.github/workflows/ci_documentation.yml b/.github/workflows/ci_documentation.yml deleted file mode 100644 index d67801f..0000000 --- a/.github/workflows/ci_documentation.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: Documentation - -on: - push: - pull_request: - workflow_dispatch: - -concurrency: - group: documentation-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.event_name != 'push' }} - -env: - TZ: Europe/Berlin - -defaults: - run: - shell: bash -Eexuo pipefail {0} - -jobs: - build: - name: Documentation - runs-on: ubuntu-22.04 - timeout-minutes: 120 - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - submodules: false - - - name: Install CMake - uses: seqan/actions/setup-cmake@main - with: - cmake: 3.21.7 - - - name: Install Doxygen - uses: seqan/actions/setup-doxygen@main - with: - doxygen: 1.9.8 - - - name: Configure - run: | - mkdir build - cd build - cmake .. - - - name: Build documentation - run: | - cd build - make -k -j${{ matrix.test_threads }} doc 2>doxygen_warnings.txt - cat doxygen_warnings.txt - test ! -s doxygen_warnings.txt - - - name: Package documentation - continue-on-error: true - run: tar -zcf documentation.tar.gz build/doc/html - - - name: Upload documentation - continue-on-error: true - uses: actions/upload-artifact@v3 - with: - name: documentation - path: documentation.tar.gz diff --git a/CMakeLists.txt b/CMakeLists.txt index 639a5b8..e8c52c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,10 +49,6 @@ list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/test/cmake/") add_subdirectory (src) message (STATUS "${FontBold}You can run `make` to build the application.${FontReset}") -## DOCUMENTATION - -add_subdirectory (doc EXCLUDE_FROM_ALL) - ## TEST enable_testing () diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt deleted file mode 100644 index 73229bc..0000000 --- a/doc/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -cmake_minimum_required (VERSION 3.16) - -# Find doxygen. -find_package (Doxygen QUIET) - -if (${DOXYGEN_FOUND}) - message (STATUS "Found Doxygen: ${DOXYGEN_EXECUTABLE}") - - # Configure doxygen options. - set (APP_TEMPLATE_DOXYFILE_IN ${CMAKE_SOURCE_DIR}/doc/doxygen_cfg) - set (APP_TEMPLATE_DOXYGEN_OUTPUT_DIR "${PROJECT_BINARY_DIR}/doc") - set (APP_TEMPLATE_DOXYGEN_EXCLUDE_SYMBOLS "") - set (APP_TEMPLATE_DOXYGEN_PREDEFINED_NDEBUG "") - set (APP_TEMPLATE_DOXYGEN_ENABLED_SECTIONS "DEV") - set (APP_TEMPLATE_DOXYGEN_EXTRACT_PRIVATE "YES") - - configure_file (${APP_TEMPLATE_DOXYFILE_IN} ${APP_TEMPLATE_DOXYGEN_OUTPUT_DIR}/Doxyfile) - add_custom_target (doc - COMMAND ${DOXYGEN_EXECUTABLE} - WORKING_DIRECTORY ${APP_TEMPLATE_DOXYGEN_OUTPUT_DIR} - COMMENT "Generating (developer) API documentation with Doxygen." - VERBATIM - ) - message (STATUS "${FontBold}You can run `make doc` to build api documentation.${FontReset}") -else () - message (STATUS "Doxygen not found.") -endif () diff --git a/doc/README.md b/doc/README.md deleted file mode 100644 index 2a56fbd..0000000 --- a/doc/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Documentation - -To build the API documentation, you need to install `doxygen`. We use Doxygen version 1.8.17. -Run `make doc` and open the API documentation via `open doc/html/index.html`. - -You can run `doxygen -u doxygen_cfg` to convert the configuration file to its verbose version. -`doxygen -u -s doxygen_cfg` will convert it back to its compact version. diff --git a/doc/doxygen_cfg b/doc/doxygen_cfg deleted file mode 100644 index 07cc4e6..0000000 --- a/doc/doxygen_cfg +++ /dev/null @@ -1,404 +0,0 @@ -# Doxyfile 1.9.8 - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- -DOXYFILE_ENCODING = UTF-8 -PROJECT_NAME = fastq_to_fasta -PROJECT_NUMBER = -PROJECT_BRIEF = "A template for creation of SeqAn3 apps, with a FASTQ to FASTA example app." -PROJECT_LOGO = -OUTPUT_DIRECTORY = ${APP_TEMPLATE_DOXYGEN_OUTPUT_DIR} -CREATE_SUBDIRS = NO -CREATE_SUBDIRS_LEVEL = 8 -ALLOW_UNICODE_NAMES = NO -OUTPUT_LANGUAGE = English -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the -ALWAYS_DETAILED_SEC = NO -INLINE_INHERITED_MEMB = NO -FULL_PATH_NAMES = YES -STRIP_FROM_PATH = ${CMAKE_SOURCE_DIR} -STRIP_FROM_INC_PATH = ${CMAKE_SOURCE_DIR}/include -SHORT_NAMES = NO -JAVADOC_AUTOBRIEF = NO -JAVADOC_BANNER = NO -QT_AUTOBRIEF = NO -MULTILINE_CPP_IS_BRIEF = NO -PYTHON_DOCSTRING = YES -INHERIT_DOCS = YES -SEPARATE_MEMBER_PAGES = NO -TAB_SIZE = 4 -ALIASES = -OPTIMIZE_OUTPUT_FOR_C = NO -OPTIMIZE_OUTPUT_JAVA = NO -OPTIMIZE_FOR_FORTRAN = NO -OPTIMIZE_OUTPUT_VHDL = NO -OPTIMIZE_OUTPUT_SLICE = NO -EXTENSION_MAPPING = -MARKDOWN_SUPPORT = YES -TOC_INCLUDE_HEADINGS = 5 -MARKDOWN_ID_STYLE = DOXYGEN -AUTOLINK_SUPPORT = YES -BUILTIN_STL_SUPPORT = NO -CPP_CLI_SUPPORT = NO -SIP_SUPPORT = NO -IDL_PROPERTY_SUPPORT = YES -DISTRIBUTE_GROUP_DOC = NO -GROUP_NESTED_COMPOUNDS = NO -SUBGROUPING = YES -INLINE_GROUPED_CLASSES = NO -INLINE_SIMPLE_STRUCTS = NO -TYPEDEF_HIDES_STRUCT = NO -LOOKUP_CACHE_SIZE = 0 -NUM_PROC_THREADS = 1 -TIMESTAMP = NO -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- -EXTRACT_ALL = YES -EXTRACT_PRIVATE = NO -EXTRACT_PRIV_VIRTUAL = NO -EXTRACT_PACKAGE = NO -EXTRACT_STATIC = NO -EXTRACT_LOCAL_CLASSES = YES -EXTRACT_LOCAL_METHODS = NO -EXTRACT_ANON_NSPACES = NO -RESOLVE_UNNAMED_PARAMS = YES -HIDE_UNDOC_MEMBERS = NO -HIDE_UNDOC_CLASSES = NO -HIDE_FRIEND_COMPOUNDS = NO -HIDE_IN_BODY_DOCS = NO -INTERNAL_DOCS = NO -CASE_SENSE_NAMES = NO -HIDE_SCOPE_NAMES = NO -HIDE_COMPOUND_REFERENCE= NO -SHOW_HEADERFILE = YES -SHOW_INCLUDE_FILES = YES -SHOW_GROUPED_MEMB_INC = NO -FORCE_LOCAL_INCLUDES = NO -INLINE_INFO = YES -SORT_MEMBER_DOCS = YES -SORT_BRIEF_DOCS = NO -SORT_MEMBERS_CTORS_1ST = NO -SORT_GROUP_NAMES = NO -SORT_BY_SCOPE_NAME = NO -STRICT_PROTO_MATCHING = NO -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -GENERATE_DEPRECATEDLIST= YES -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 30 -SHOW_USED_FILES = YES -SHOW_FILES = YES -SHOW_NAMESPACES = YES -FILE_VERSION_FILTER = -LAYOUT_FILE = -CITE_BIB_FILES = -#--------------------------------------------------------------------------- -# Configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_IF_DOC_ERROR = YES -WARN_IF_INCOMPLETE_DOC = YES -WARN_NO_PARAMDOC = NO -WARN_IF_UNDOC_ENUM_VAL = NO -WARN_AS_ERROR = NO -WARN_FORMAT = "$file:$line: $text" -WARN_LINE_FORMAT = "at line $line of file $file" -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# Configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = ${CMAKE_SOURCE_DIR}/include \ - ${CMAKE_SOURCE_DIR}/src \ - ${CMAKE_SOURCE_DIR}/LICENSE.md -INPUT_ENCODING = UTF-8 -INPUT_FILE_ENCODING = -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.idl \ - *.ddl \ - *.odl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.cs \ - *.d \ - *.php \ - *.php4 \ - *.php5 \ - *.phtml \ - *.inc \ - *.m \ - *.markdown \ - *.md \ - *.mm \ - *.dox \ - *.doc \ - *.txt \ - *.py \ - *.pyw \ - *.f90 \ - *.f95 \ - *.f03 \ - *.f08 \ - *.f \ - *.for \ - *.tcl \ - *.vhd \ - *.vhdl \ - *.ucf \ - *.qsf \ - *.ice -RECURSIVE = YES -EXCLUDE = -EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = -EXCLUDE_SYMBOLS = -EXAMPLE_PATH = -EXAMPLE_PATTERNS = * -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_PATTERNS = -FILTER_SOURCE_FILES = NO -FILTER_SOURCE_PATTERNS = -USE_MDFILE_AS_MAINPAGE = -FORTRAN_COMMENT_AFTER = 72 -#--------------------------------------------------------------------------- -# Configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = NO -INLINE_SOURCES = NO -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = NO -REFERENCES_RELATION = NO -REFERENCES_LINK_SOURCE = YES -SOURCE_TOOLTIPS = YES -USE_HTAGS = NO -VERBATIM_HEADERS = YES -#--------------------------------------------------------------------------- -# Configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = YES -IGNORE_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = html -HTML_FILE_EXTENSION = .html -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_EXTRA_STYLESHEET = -HTML_EXTRA_FILES = -HTML_COLORSTYLE = AUTO_LIGHT -HTML_COLORSTYLE_HUE = 220 -HTML_COLORSTYLE_SAT = 100 -HTML_COLORSTYLE_GAMMA = 80 -HTML_DYNAMIC_MENUS = YES -HTML_DYNAMIC_SECTIONS = NO -HTML_CODE_FOLDING = YES -HTML_INDEX_NUM_ENTRIES = 100 -GENERATE_DOCSET = NO -DOCSET_FEEDNAME = "Doxygen generated docs" -DOCSET_FEEDURL = -DOCSET_BUNDLE_ID = org.doxygen.Project -DOCSET_PUBLISHER_ID = org.doxygen.Publisher -DOCSET_PUBLISHER_NAME = Publisher -GENERATE_HTMLHELP = NO -CHM_FILE = -HHC_LOCATION = -GENERATE_CHI = NO -CHM_INDEX_ENCODING = -BINARY_TOC = NO -TOC_EXPAND = NO -SITEMAP_URL = -GENERATE_QHP = NO -QCH_FILE = -QHP_NAMESPACE = org.doxygen.Project -QHP_VIRTUAL_FOLDER = doc -QHP_CUST_FILTER_NAME = -QHP_CUST_FILTER_ATTRS = -QHP_SECT_FILTER_ATTRS = -QHG_LOCATION = -GENERATE_ECLIPSEHELP = NO -ECLIPSE_DOC_ID = org.doxygen.Project -DISABLE_INDEX = NO -GENERATE_TREEVIEW = NO -FULL_SIDEBAR = NO -ENUM_VALUES_PER_LINE = 4 -TREEVIEW_WIDTH = 250 -EXT_LINKS_IN_WINDOW = NO -OBFUSCATE_EMAILS = YES -HTML_FORMULA_FORMAT = png -FORMULA_FONTSIZE = 10 -FORMULA_MACROFILE = -USE_MATHJAX = YES -MATHJAX_VERSION = MathJax_3 -MATHJAX_FORMAT = HTML-CSS -MATHJAX_RELPATH = https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/ -MATHJAX_EXTENSIONS = -MATHJAX_CODEFILE = -SEARCHENGINE = YES -SERVER_BASED_SEARCH = NO -EXTERNAL_SEARCH = NO -SEARCHENGINE_URL = -SEARCHDATA_FILE = searchdata.xml -EXTERNAL_SEARCH_ID = -EXTRA_SEARCH_MAPPINGS = -#--------------------------------------------------------------------------- -# Configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = NO -LATEX_OUTPUT = latex -LATEX_CMD_NAME = -MAKEINDEX_CMD_NAME = makeindex -LATEX_MAKEINDEX_CMD = makeindex -COMPACT_LATEX = NO -PAPER_TYPE = a4 -EXTRA_PACKAGES = -LATEX_HEADER = -LATEX_FOOTER = -LATEX_EXTRA_STYLESHEET = -LATEX_EXTRA_FILES = -PDF_HYPERLINKS = YES -USE_PDFLATEX = YES -LATEX_BATCHMODE = NO -LATEX_HIDE_INDICES = NO -LATEX_BIB_STYLE = plain -LATEX_EMOJI_DIRECTORY = -#--------------------------------------------------------------------------- -# Configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = rtf -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -#--------------------------------------------------------------------------- -# Configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = NO -MAN_OUTPUT = man -MAN_EXTENSION = .3 -MAN_SUBDIR = -MAN_LINKS = NO -#--------------------------------------------------------------------------- -# Configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = NO -XML_OUTPUT = xml -XML_PROGRAMLISTING = YES -XML_NS_MEMB_FILE_SCOPE = NO -#--------------------------------------------------------------------------- -# Configuration options related to the DOCBOOK output -#--------------------------------------------------------------------------- -GENERATE_DOCBOOK = NO -DOCBOOK_OUTPUT = docbook -#--------------------------------------------------------------------------- -# Configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- -GENERATE_AUTOGEN_DEF = NO -#--------------------------------------------------------------------------- -# Configuration options related to Sqlite3 output -#--------------------------------------------------------------------------- -GENERATE_SQLITE3 = NO -SQLITE3_OUTPUT = sqlite3 -SQLITE3_RECREATE_DB = YES -#--------------------------------------------------------------------------- -# Configuration options related to the Perl module output -#--------------------------------------------------------------------------- -GENERATE_PERLMOD = NO -PERLMOD_LATEX = NO -PERLMOD_PRETTY = YES -PERLMOD_MAKEVAR_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = YES -INCLUDE_PATH = ${CMAKE_SOURCE_DIR}/include -INCLUDE_FILE_PATTERNS = -PREDEFINED = -EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = YES -#--------------------------------------------------------------------------- -# Configuration options related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = -ALLEXTERNALS = NO -EXTERNAL_GROUPS = YES -EXTERNAL_PAGES = YES -#--------------------------------------------------------------------------- -# Configuration options related to diagram generator tools -#--------------------------------------------------------------------------- -HIDE_UNDOC_RELATIONS = YES -HAVE_DOT = NO -DOT_NUM_THREADS = 0 -DOT_COMMON_ATTR = "fontname=Helvetica,fontsize=10" -DOT_EDGE_ATTR = "labelfontname=Helvetica,labelfontsize=10" -DOT_NODE_ATTR = "shape=box,height=0.2,width=0.4" -DOT_FONTPATH = -CLASS_GRAPH = YES -COLLABORATION_GRAPH = YES -GROUP_GRAPHS = YES -UML_LOOK = NO -UML_LIMIT_NUM_FIELDS = 10 -DOT_UML_DETAILS = NO -DOT_WRAP_THRESHOLD = 17 -TEMPLATE_RELATIONS = NO -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -CALL_GRAPH = NO -CALLER_GRAPH = NO -GRAPHICAL_HIERARCHY = YES -DIRECTORY_GRAPH = YES -DIR_GRAPH_MAX_DEPTH = 1 -DOT_IMAGE_FORMAT = png -INTERACTIVE_SVG = NO -DOT_PATH = -DOTFILE_DIRS = -DIA_PATH = -DIAFILE_DIRS = -PLANTUML_JAR_PATH = -PLANTUML_CFG_FILE = -PLANTUML_INCLUDE_PATH = -DOT_GRAPH_MAX_NODES = 50 -MAX_DOT_GRAPH_DEPTH = 0 -DOT_MULTI_TARGETS = NO -GENERATE_LEGEND = YES -DOT_CLEANUP = YES -MSCGEN_TOOL = -MSCFILE_DIRS = From 4aef199643ba95e4b1650aa23f4533c6bc66a503 Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Mon, 29 Jan 2024 14:27:45 +0100 Subject: [PATCH 2/9] [INFRA] Remove benchmark --- .github/workflows/ci_coverage.yml | 2 +- .github/workflows/ci_linux.yml | 2 +- .github/workflows/ci_macos.yml | 2 +- cmake/package-lock.cmake | 10 ---------- test/CMakeLists.txt | 11 ----------- test/benchmark/README.md | 6 ------ test/header/CMakeLists.txt | 5 +++-- test/header/dummy_include/benchmark/benchmark.h | 1 - 8 files changed, 6 insertions(+), 33 deletions(-) delete mode 100644 test/benchmark/README.md delete mode 100644 test/header/dummy_include/benchmark/benchmark.h diff --git a/.github/workflows/ci_coverage.yml b/.github/workflows/ci_coverage.yml index dd53966..92d469d 100644 --- a/.github/workflows/ci_coverage.yml +++ b/.github/workflows/ci_coverage.yml @@ -64,7 +64,7 @@ jobs: mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - make -j2 gtest_main benchmark_main yaml-cpp + make -j2 gtest_main yaml-cpp - name: Build tests env: diff --git a/.github/workflows/ci_linux.yml b/.github/workflows/ci_linux.yml index 30a9739..d6505a1 100644 --- a/.github/workflows/ci_linux.yml +++ b/.github/workflows/ci_linux.yml @@ -71,7 +71,7 @@ jobs: cd build cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}" - make -j2 gtest_main benchmark_main yaml-cpp + make -j2 gtest_main yaml-cpp - name: Build application run: | diff --git a/.github/workflows/ci_macos.yml b/.github/workflows/ci_macos.yml index d2be181..c9c9a7e 100644 --- a/.github/workflows/ci_macos.yml +++ b/.github/workflows/ci_macos.yml @@ -71,7 +71,7 @@ jobs: cd build cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}" - make -j3 gtest_main benchmark_main yaml-cpp + make -j3 gtest_main yaml-cpp - name: Build application run: | diff --git a/cmake/package-lock.cmake b/cmake/package-lock.cmake index 9774342..c660b75 100644 --- a/cmake/package-lock.cmake +++ b/cmake/package-lock.cmake @@ -35,16 +35,6 @@ CPMDeclarePackage (seqan3 SYSTEM TRUE OPTIONS "INSTALL_SEQAN3 OFF" "CMAKE_MESSAGE_LOG_LEVEL WARNING" ) -# benchmark -set (BENCHMARK_VERSION 1.8.3) -CPMDeclarePackage (benchmark - NAME benchmark - VERSION ${BENCHMARK_VERSION} - GITHUB_REPOSITORY google/benchmark - SYSTEM TRUE - OPTIONS "BENCHMARK_ENABLE_TESTING OFF" "BENCHMARK_ENABLE_WERROR OFF" - "CMAKE_MESSAGE_LOG_LEVEL WARNING" -) # googletest set (GOOGLETEST_VERSION 1.14.0) CPMDeclarePackage (googletest diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c15d490..7acf321 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,15 +1,5 @@ cmake_minimum_required (VERSION 3.16) -# CMake sometimes has trouble detecting pthreads on macOS, so we just assume a built-in pthreads. -if (APPLE) - set (CMAKE_THREAD_LIBS_INIT "-lpthread") - set (CMAKE_HAVE_THREADS_LIBRARY 1) - set (CMAKE_USE_WIN32_THREADS_INIT 0) - set (CMAKE_USE_PTHREADS_INIT 1) - set (THREADS_PREFER_PTHREAD_FLAG ON) -endif () - -CPMGetSystemPackage (benchmark) CPMGetSystemPackage (googletest) include (GoogleTest OPTIONAL) @@ -45,7 +35,6 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") endif () target_link_libraries (${PROJECT_NAME}_test INTERFACE "${PROJECT_NAME}_lib" "GTest::gtest_main" - "benchmark::benchmark_main" ) target_include_directories (${PROJECT_NAME}_test INTERFACE "${seqan3_SOURCE_DIR}/test/include") add_library (${PROJECT_NAME}::test ALIAS ${PROJECT_NAME}_test) diff --git a/test/benchmark/README.md b/test/benchmark/README.md deleted file mode 100644 index b495e29..0000000 --- a/test/benchmark/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Benchmarks - -Here are test files for benchmarks with respect to time, space consumption and memory. -They are usually based on the command-line interface, but you can also add micro benchmark if you wish. - -The benchmark tests are not yet implemented. diff --git a/test/header/CMakeLists.txt b/test/header/CMakeLists.txt index 9a463a4..3c5359b 100644 --- a/test/header/CMakeLists.txt +++ b/test/header/CMakeLists.txt @@ -5,8 +5,9 @@ include (seqan3_test_component) add_library ("${PROJECT_NAME}_header_test_lib" INTERFACE) target_link_libraries ("${PROJECT_NAME}_header_test_lib" INTERFACE "${PROJECT_NAME}_test") -# SeqAn3 script adds an include for -target_include_directories ("${PROJECT_NAME}_header_test_lib" INTERFACE ./dummy_include) +# SeqAn3 script adds an include for +file (WRITE "${PROJECT_BINARY_DIR}/dummy_include/benchmark/benchmark.h" "#pragma once") +target_include_directories ("${PROJECT_NAME}_header_test_lib" INTERFACE "${PROJECT_BINARY_DIR}/dummy_include") set (target "${PROJECT_NAME}_header_test") set (header_base_path "${CMAKE_CURRENT_LIST_DIR}/../../include/") diff --git a/test/header/dummy_include/benchmark/benchmark.h b/test/header/dummy_include/benchmark/benchmark.h deleted file mode 100644 index 6f70f09..0000000 --- a/test/header/dummy_include/benchmark/benchmark.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once From 04bd0e2b672bff26307b1d578e4abcde889f6e0a Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Mon, 29 Jan 2024 14:50:23 +0100 Subject: [PATCH 3/9] [INFRA] Some more refactoring --- .github/workflows/ci_coverage.yml | 4 +-- .github/workflows/ci_linux.yml | 6 ++-- .github/workflows/ci_macos.yml | 6 ++-- CMakeLists.txt | 7 ++--- test/CMakeLists.txt | 50 ++++++++++++++++++------------- test/api/CMakeLists.txt | 9 ------ test/cli/CMakeLists.txt | 10 ------- test/header/CMakeLists.txt | 1 + 8 files changed, 41 insertions(+), 52 deletions(-) diff --git a/.github/workflows/ci_coverage.yml b/.github/workflows/ci_coverage.yml index 92d469d..66c0ca4 100644 --- a/.github/workflows/ci_coverage.yml +++ b/.github/workflows/ci_coverage.yml @@ -64,7 +64,7 @@ jobs: mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - make -j2 gtest_main yaml-cpp + make -j2 -k gtest_main yaml-cpp - name: Build tests env: @@ -72,7 +72,7 @@ jobs: run: | ccache -z cd build - CMAKE_BUILD_PARALLEL_LEVEL=2 cmake --build . -- -k test + make -j2 -k check ccache -sv - name: Generate coverage report diff --git a/.github/workflows/ci_linux.yml b/.github/workflows/ci_linux.yml index d6505a1..6374978 100644 --- a/.github/workflows/ci_linux.yml +++ b/.github/workflows/ci_linux.yml @@ -71,14 +71,14 @@ jobs: cd build cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}" - make -j2 gtest_main yaml-cpp + make -j2 -k gtest_main yaml-cpp - name: Build application run: | cd build - CMAKE_BUILD_PARALLEL_LEVEL=2 cmake --build . -- -k + make -j2 -k - name: Build and run tests run: | cd build - CMAKE_BUILD_PARALLEL_LEVEL=2 cmake --build . -- -k test + make -j2 -k check diff --git a/.github/workflows/ci_macos.yml b/.github/workflows/ci_macos.yml index c9c9a7e..5f02f1d 100644 --- a/.github/workflows/ci_macos.yml +++ b/.github/workflows/ci_macos.yml @@ -71,14 +71,14 @@ jobs: cd build cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}" - make -j3 gtest_main yaml-cpp + make -j3 -k gtest_main yaml-cpp - name: Build application run: | cd build - CMAKE_BUILD_PARALLEL_LEVEL=3 cmake --build . -- -k + make -j3 -k - name: Build and run tests run: | cd build - CMAKE_BUILD_PARALLEL_LEVEL=3 cmake --build . -- -k test + make -j3 -k check diff --git a/CMakeLists.txt b/CMakeLists.txt index e8c52c5..dfd7b73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,7 @@ string (ASCII 27 Esc) set (FontBold "${Esc}[1m") set (FontReset "${Esc}[m") +# Allow to include CMake scripts from the app-template. list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") # Use ccache. @@ -40,16 +41,12 @@ CPMUsePackageLock (${CMAKE_CURRENT_LIST_DIR}/cmake/package-lock.cmake) CPMGetSystemPackage (sharg) CPMGetSystemPackage (seqan3) -# Allow to include CMake scripts from seqan3. -list (APPEND CMAKE_MODULE_PATH "${seqan3_SOURCE_DIR}/test/cmake/") -# Allow to include CMake scripts from the app-template. -list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/test/cmake/") - # Add the application. add_subdirectory (src) message (STATUS "${FontBold}You can run `make` to build the application.${FontReset}") ## TEST +list (APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure") # Must be before `enable_testing ()`. enable_testing () add_subdirectory (test EXCLUDE_FROM_ALL) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7acf321..eb268cd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,10 @@ cmake_minimum_required (VERSION 3.16) +# Allow to include CMake scripts from seqan3. +list (APPEND CMAKE_MODULE_PATH "${seqan3_SOURCE_DIR}/test/cmake/") +# Allow to include CMake scripts from the app-template. +list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/") + CPMGetSystemPackage (googletest) include (GoogleTest OPTIONAL) @@ -39,6 +44,8 @@ target_link_libraries (${PROJECT_NAME}_test INTERFACE "${PROJECT_NAME}_lib" "GTe target_include_directories (${PROJECT_NAME}_test INTERFACE "${seqan3_SOURCE_DIR}/test/include") add_library (${PROJECT_NAME}::test ALIAS ${PROJECT_NAME}_test) +add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND}) + # A macro that adds an api or cli test. macro (add_app_test test_filename) # Extract the test target name. @@ -52,36 +59,39 @@ macro (add_app_test test_filename) # Generate and set the test name. add_test (NAME "${test_name}" COMMAND ${target}) + add_dependencies (check ${target}) unset (source_file) unset (target) unset (test_name) endmacro () -# Build tests just before their execution, because they have not been built with "all" target. -# The trick is here to provide a cmake file as a directory property that executes the build command. -file (WRITE "${CMAKE_CURRENT_BINARY_DIR}/build_test_targets.cmake" - "execute_process (COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target api_test)\n" - "execute_process (COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target cli_test)\n" - "execute_process (COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target ${PROJECT_NAME}_header_test)\n" -) -set_directory_properties (PROPERTIES TEST_INCLUDE_FILE "${CMAKE_CURRENT_BINARY_DIR}/build_test_targets.cmake") -list (APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure") - # Fetch data and add the tests. include (data/datasources.cmake) + +add_custom_target (api_test ALL) + +macro (add_api_test test_filename) + add_app_test (${test_filename}) + + seqan3_test_component (target "${test_filename}" TARGET_NAME) + add_dependencies (api_test ${target}) +endmacro () + add_subdirectory (api) + +add_custom_target (cli_test ALL) + +macro (add_cli_test test_filename) + add_app_test (${test_filename}) + + seqan3_test_component (target "${test_filename}" TARGET_NAME) + add_dependencies (cli_test ${target}) + add_dependencies (${target} "${PROJECT_NAME}") +endmacro () + add_subdirectory (cli) add_subdirectory (header) add_subdirectory (coverage) -add_custom_target (unit_test - COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target api_test cli_test - COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -R \"api/ \|cli/\" -) -add_custom_target (header_test - COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target ${PROJECT_NAME}_header_test - COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -R \"header\" -) - -message (STATUS "${FontBold}You can run `make test` to build and run tests.${FontReset}") +message (STATUS "${FontBold}You can run `make check` to build and run tests.${FontReset}") diff --git a/test/api/CMakeLists.txt b/test/api/CMakeLists.txt index a625f48..53a8b17 100644 --- a/test/api/CMakeLists.txt +++ b/test/api/CMakeLists.txt @@ -1,13 +1,4 @@ cmake_minimum_required (VERSION 3.16) -add_custom_target (api_test ALL) - -macro (add_api_test test_filename) - add_app_test (${test_filename}) - - seqan3_test_component (target "${test_filename}" TARGET_NAME) - add_dependencies (api_test ${target}) -endmacro () - add_api_test (convert_fastq_test.cpp) target_use_datasources (convert_fastq_test FILES in.fastq) diff --git a/test/cli/CMakeLists.txt b/test/cli/CMakeLists.txt index fbfc93b..223dbcc 100644 --- a/test/cli/CMakeLists.txt +++ b/test/cli/CMakeLists.txt @@ -1,14 +1,4 @@ cmake_minimum_required (VERSION 3.16) -add_custom_target (cli_test ALL) - -macro (add_cli_test test_filename) - add_app_test (${test_filename}) - - seqan3_test_component (target "${test_filename}" TARGET_NAME) - add_dependencies (cli_test ${target}) - add_dependencies (${target} "${PROJECT_NAME}") -endmacro () - add_cli_test (fastq_to_fasta_options_test.cpp) target_use_datasources (fastq_to_fasta_options_test FILES in.fastq) diff --git a/test/header/CMakeLists.txt b/test/header/CMakeLists.txt index 3c5359b..4664ece 100644 --- a/test/header/CMakeLists.txt +++ b/test/header/CMakeLists.txt @@ -21,6 +21,7 @@ file (WRITE "${PROJECT_BINARY_DIR}/${target}.cpp" "") add_executable (${target} ${PROJECT_BINARY_DIR}/${target}.cpp) target_link_libraries (${target} ${PROJECT_NAME}_header_test_lib) add_test (NAME "${target}" COMMAND ${target}) +add_dependencies (check ${target}) foreach (header ${header_files}) seqan3_test_component (header_test_name "${header}" TEST_NAME) From 1249dae682c177e4e7cbd699219768ef0cf66ef5 Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Mon, 29 Jan 2024 15:15:08 +0100 Subject: [PATCH 4/9] [INFRA] cleanup add_app_test --- CMakeLists.txt | 2 +- test/CMakeLists.txt | 74 ++++++++++++++++------------------------- test/api/CMakeLists.txt | 2 +- test/cli/CMakeLists.txt | 2 +- 4 files changed, 32 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dfd7b73..3af5223 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") include (ccache) require_ccache () +# Add packages. set (CPM_INDENT " CMake Package Manager CPM: ") include (CPM) include (CPMGetSystemPackage) @@ -46,7 +47,6 @@ add_subdirectory (src) message (STATUS "${FontBold}You can run `make` to build the application.${FontReset}") ## TEST - list (APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure") # Must be before `enable_testing ()`. enable_testing () add_subdirectory (test EXCLUDE_FROM_ALL) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index eb268cd..610ae95 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,13 +1,14 @@ cmake_minimum_required (VERSION 3.16) +# Add googletest. +CPMGetSystemPackage (googletest) +include (GoogleTest OPTIONAL) + # Allow to include CMake scripts from seqan3. list (APPEND CMAKE_MODULE_PATH "${seqan3_SOURCE_DIR}/test/cmake/") # Allow to include CMake scripts from the app-template. list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/") -CPMGetSystemPackage (googletest) -include (GoogleTest OPTIONAL) - # Set directories for test output files, input data and binaries. file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/output) add_definitions (-DOUTPUTDIR=\"${CMAKE_CURRENT_BINARY_DIR}/output/\") @@ -15,37 +16,40 @@ add_definitions (-DDATADIR=\"${CMAKE_CURRENT_BINARY_DIR}/data/\") add_definitions (-DBINDIR=\"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/\") # Test executables and libraries should not mix with the application files. +# This must happen after setting the output directories. unset (CMAKE_ARCHIVE_OUTPUT_DIRECTORY) unset (CMAKE_LIBRARY_OUTPUT_DIRECTORY) unset (CMAKE_RUNTIME_OUTPUT_DIRECTORY) -include (seqan3_test_component) - -add_library (${PROJECT_NAME}_test INTERFACE) -target_compile_options (${PROJECT_NAME}_test INTERFACE "-pedantic" "-Wall" "-Wextra" "-Werror") +# Add the test interface library. +if (NOT TARGET ${PROJECT_NAME}_test) + add_library (${PROJECT_NAME}_test INTERFACE) + target_compile_options (${PROJECT_NAME}_test INTERFACE "-pedantic" "-Wall" "-Wextra" "-Werror") -# GCC12 and above: Disable warning about std::hardware_destructive_interference_size not being ABI-stable. -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12) - target_compile_options (${PROJECT_NAME}_test INTERFACE "-Wno-interference-size") + # GCC12 and above: Disable warning about std::hardware_destructive_interference_size not being ABI-stable. + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12) + target_compile_options (${PROJECT_NAME}_test INTERFACE "-Wno-interference-size") + endif () endif () -endif () -# GCC12 has some bogus warnings. They will not be fixed in googletest. -# https://github.com/google/googletest/issues/4232 -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13) - target_compile_options (${PROJECT_NAME}_test INTERFACE "-Wno-restrict") + # GCC12 has some bogus warnings. They will not be fixed in googletest. + # https://github.com/google/googletest/issues/4232 + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13) + target_compile_options (${PROJECT_NAME}_test INTERFACE "-Wno-restrict") + endif () endif () -endif () -target_link_libraries (${PROJECT_NAME}_test INTERFACE "${PROJECT_NAME}_lib" "GTest::gtest_main" -) -target_include_directories (${PROJECT_NAME}_test INTERFACE "${seqan3_SOURCE_DIR}/test/include") -add_library (${PROJECT_NAME}::test ALIAS ${PROJECT_NAME}_test) + target_link_libraries (${PROJECT_NAME}_test INTERFACE "${PROJECT_NAME}_lib" "GTest::gtest_main") + target_include_directories (${PROJECT_NAME}_test INTERFACE "${seqan3_SOURCE_DIR}/test/include") + add_library (${PROJECT_NAME}::test ALIAS ${PROJECT_NAME}_test) +endif () -add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND}) +# Add the check target that builds and runs tests. +add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND} ${CMAKE_CTEST_ARGUMENTS}) +include (seqan3_test_component) # A macro that adds an api or cli test. macro (add_app_test test_filename) # Extract the test target name. @@ -56,10 +60,11 @@ macro (add_app_test test_filename) # Create the test target. add_executable (${target} ${test_filename}) target_link_libraries (${target} ${PROJECT_NAME}::test) + add_dependencies (${target} ${PROJECT_NAME}) + add_dependencies (check ${target}) # Generate and set the test name. add_test (NAME "${test_name}" COMMAND ${target}) - add_dependencies (check ${target}) unset (source_file) unset (target) @@ -68,28 +73,7 @@ endmacro () # Fetch data and add the tests. include (data/datasources.cmake) - -add_custom_target (api_test ALL) - -macro (add_api_test test_filename) - add_app_test (${test_filename}) - - seqan3_test_component (target "${test_filename}" TARGET_NAME) - add_dependencies (api_test ${target}) -endmacro () - add_subdirectory (api) - -add_custom_target (cli_test ALL) - -macro (add_cli_test test_filename) - add_app_test (${test_filename}) - - seqan3_test_component (target "${test_filename}" TARGET_NAME) - add_dependencies (cli_test ${target}) - add_dependencies (${target} "${PROJECT_NAME}") -endmacro () - add_subdirectory (cli) add_subdirectory (header) add_subdirectory (coverage) diff --git a/test/api/CMakeLists.txt b/test/api/CMakeLists.txt index 53a8b17..f356055 100644 --- a/test/api/CMakeLists.txt +++ b/test/api/CMakeLists.txt @@ -1,4 +1,4 @@ cmake_minimum_required (VERSION 3.16) -add_api_test (convert_fastq_test.cpp) +add_app_test (convert_fastq_test.cpp) target_use_datasources (convert_fastq_test FILES in.fastq) diff --git a/test/cli/CMakeLists.txt b/test/cli/CMakeLists.txt index 223dbcc..18b0483 100644 --- a/test/cli/CMakeLists.txt +++ b/test/cli/CMakeLists.txt @@ -1,4 +1,4 @@ cmake_minimum_required (VERSION 3.16) -add_cli_test (fastq_to_fasta_options_test.cpp) +add_app_test (fastq_to_fasta_options_test.cpp) target_use_datasources (fastq_to_fasta_options_test FILES in.fastq) From dfb38643e6ed0b263609d8ee5479d9e06e90b4b9 Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Mon, 29 Jan 2024 16:46:03 +0100 Subject: [PATCH 5/9] [INFRA] Update tests --- test/api/CMakeLists.txt | 1 + test/api/convert_fastq_test.cpp | 50 ++++++++--------- test/cli/CMakeLists.txt | 1 + test/cli/cli_test.hpp | 47 ++++++++++++---- test/cli/fastq_to_fasta_options_test.cpp | 70 ++++++++++-------------- test/data/datasources.cmake | 3 + test/data/out.fasta | 4 ++ 7 files changed, 96 insertions(+), 80 deletions(-) create mode 100644 test/data/out.fasta diff --git a/test/api/CMakeLists.txt b/test/api/CMakeLists.txt index f356055..fd956b2 100644 --- a/test/api/CMakeLists.txt +++ b/test/api/CMakeLists.txt @@ -2,3 +2,4 @@ cmake_minimum_required (VERSION 3.16) add_app_test (convert_fastq_test.cpp) target_use_datasources (convert_fastq_test FILES in.fastq) +target_use_datasources (convert_fastq_test FILES out.fasta) diff --git a/test/api/convert_fastq_test.cpp b/test/api/convert_fastq_test.cpp index fbce26e..18848e0 100644 --- a/test/api/convert_fastq_test.cpp +++ b/test/api/convert_fastq_test.cpp @@ -1,39 +1,33 @@ #include -#include -#include -#include -#include +#include +#include "../cli/cli_test.hpp" // For cli_test::data and cli_test::string_from_file. #include "fastq_conversion.hpp" -TEST(group1, out_empty) +TEST(convert_fastq, out_empty) { - std::string expected{">seq1\nACGTTTGATTCGCG\n>seq2\nTCGGGGGATTCGCG\n"}; + std::string_view const expected{">seq1\nACGTTTGATTCGCG\n>seq2\nTCGGGGGATTCGCG\n"}; + testing::internal::CaptureStdout(); - convert_fastq(DATADIR "in.fastq", ""); - std::string std_cout = testing::internal::GetCapturedStdout(); - EXPECT_RANGE_EQ(expected, std_cout); + convert_fastq(cli_test::data("in.fastq"), ""); + std::string const std_cout = testing::internal::GetCapturedStdout(); + + EXPECT_EQ(expected, std_cout); } -TEST(group1, out_not_empty) +TEST(convert_fastq, out_not_empty) { - std::filesystem::path tmp_dir = std::filesystem::temp_directory_path(); // get the temp directory - convert_fastq(DATADIR "in.fastq", tmp_dir / "out.fasta"); // create out.fasta - - // Check if out.fasta is correct - using seqan3::operator""_dna5; - std::vector expected_seqs = {"ACGTTTGATTCGCG"_dna5, "TCGGGGGATTCGCG"_dna5}; - std::vector expected_ids{"seq1", "seq2"}; - std::vector seqs{}; - std::vector ids{}; - seqan3::sequence_file_input fin{tmp_dir / "out.fasta"}; - - for (auto & [seq, id, qual] : fin) - { - ids.push_back(id); - seqs.push_back(seq); - } - EXPECT_RANGE_EQ(seqs, expected_seqs); - EXPECT_RANGE_EQ(ids, expected_ids); + // Creates a temporary directory and deletes it after the test. + seqan3::test::tmp_directory const tmp_dir{}; + + std::filesystem::path const test_output = tmp_dir.path() / "out.fasta"; + convert_fastq(cli_test::data("in.fastq"), test_output); // create out.fasta + + ASSERT_TRUE(std::filesystem::exists(test_output)); // check whether out.fasta exists + + // Check whether out.fasta is correct + std::string const expected = cli_test::string_from_file(cli_test::data("out.fasta")); + std::string const actual = cli_test::string_from_file(test_output); + EXPECT_EQ(actual, expected); } diff --git a/test/cli/CMakeLists.txt b/test/cli/CMakeLists.txt index 18b0483..672855f 100644 --- a/test/cli/CMakeLists.txt +++ b/test/cli/CMakeLists.txt @@ -2,3 +2,4 @@ cmake_minimum_required (VERSION 3.16) add_app_test (fastq_to_fasta_options_test.cpp) target_use_datasources (fastq_to_fasta_options_test FILES in.fastq) +target_use_datasources (fastq_to_fasta_options_test FILES out.fasta) diff --git a/test/cli/cli_test.hpp b/test/cli/cli_test.hpp index 37ec7df..1587c3c 100644 --- a/test/cli/cli_test.hpp +++ b/test/cli/cli_test.hpp @@ -2,10 +2,21 @@ #include -#include // system calls -#include // test directory creation -#include // ostringstream -#include // strings +#include +#include +#include +#include +#include + +// Checks for CLI test result for success, and prints the command line call if the test fails. +#ifndef EXPECT_SUCCESS +# define EXPECT_SUCCESS(arg) EXPECT_EQ(arg.exit_code, 0) << "Command: " << arg.command +#endif + +// Checks the exit code of a CLI test result for failure, and prints the command line call if the test fails. +#ifndef EXPECT_FAILURE +# define EXPECT_FAILURE(arg) EXPECT_NE(arg.exit_code, 0) << "Command: " << arg.command +#endif // Provides functions for CLI test implementation. struct cli_test : public ::testing::Test @@ -14,12 +25,13 @@ struct cli_test : public ::testing::Test // Holds the original work directory where Gtest has been started. std::filesystem::path original_workdir{}; -protected: +public: // Result struct for captured streams and exit code. struct cli_test_result { std::string out{}; std::string err{}; + std::string command{}; int exit_code{}; }; @@ -30,17 +42,20 @@ struct cli_test : public ::testing::Test cli_test_result result{}; // Assemble the command string and disable version check. - std::ostringstream command{}; - command << "SEQAN3_NO_VERSION_CHECK=1 " << BINDIR; - int a[] = {0, ((void)(command << command_items << ' '), 0)...}; - (void)a; + result.command = [&command_items...]() + { + std::ostringstream command{}; + command << "SHARG_NO_VERSION_CHECK=1 " << BINDIR; + (void)((command << command_items << ' '), ...); // (void) silences "state has no effect" warning if no items + return command.str(); + }(); // Always capture the output streams. testing::internal::CaptureStdout(); testing::internal::CaptureStderr(); // Run the command and return results. - result.exit_code = std::system(command.str().c_str()); + result.exit_code = std::system(result.command.c_str()); result.out = testing::internal::GetCapturedStdout(); result.err = testing::internal::GetCapturedStderr(); return result; @@ -52,6 +67,18 @@ struct cli_test : public ::testing::Test return std::filesystem::path{std::string{DATADIR}}.concat(filename); } + // Read the contents of a file into a string. + static std::string const string_from_file(std::filesystem::path const & path, + std::ios_base::openmode const mode = std::ios_base::in) + { + std::ifstream file_stream(path, mode); + if (!file_stream.is_open()) + throw std::logic_error{"Cannot open " + path.string()}; + std::stringstream file_buffer; + file_buffer << file_stream.rdbuf(); + return {file_buffer.str()}; + } + // Create an individual work directory for the current test. void SetUp() override { diff --git a/test/cli/fastq_to_fasta_options_test.cpp b/test/cli/fastq_to_fasta_options_test.cpp index 54d4c4b..e1e8637 100644 --- a/test/cli/fastq_to_fasta_options_test.cpp +++ b/test/cli/fastq_to_fasta_options_test.cpp @@ -1,15 +1,3 @@ -#include // range comparisons -#include // strings -#include // vectors - -#include -#include -#include -#include - -// Include the EXPECT_RANGE_EQ macro for better information if range elements differ. -#include - #include "cli_test.hpp" // To prevent issues when running multiple CLI tests in parallel, give each CLI test unique names: @@ -18,55 +6,53 @@ struct fastq_to_fasta : public cli_test TEST_F(fastq_to_fasta, no_options) { - cli_test_result result = execute_app("app-template"); - std::string expected{"Fastq-to-Fasta-Converter\n" - "========================\n" - " Try -h or --help for more information.\n"}; - EXPECT_EQ(result.exit_code, 0); + cli_test_result const result = execute_app("app-template"); + std::string_view const expected{"Fastq-to-Fasta-Converter\n" + "========================\n" + " Try -h or --help for more information.\n"}; + + EXPECT_SUCCESS(result); EXPECT_EQ(result.out, expected); - EXPECT_EQ(result.err, std::string{}); + EXPECT_EQ(result.err, ""); } TEST_F(fastq_to_fasta, fail_no_argument) { - cli_test_result result = execute_app("app-template", "-v"); - std::string expected{"Parsing error. Not enough positional arguments provided (Need at least 1). " - "See -h/--help for more information.\n"}; - EXPECT_NE(result.exit_code, 0); - EXPECT_EQ(result.out, std::string{}); + cli_test_result const result = execute_app("app-template", "-v"); + std::string_view const expected{"Parsing error. Not enough positional arguments provided (Need at least 1). " + "See -h/--help for more information.\n"}; + + EXPECT_FAILURE(result); + EXPECT_EQ(result.out, ""); EXPECT_EQ(result.err, expected); } TEST_F(fastq_to_fasta, with_argument) { - cli_test_result result = execute_app("app-template", data("in.fastq")); - EXPECT_EQ(result.exit_code, 0); + cli_test_result const result = execute_app("app-template", data("in.fastq")); + + EXPECT_SUCCESS(result); EXPECT_EQ(result.out, ">seq1\nACGTTTGATTCGCG\n>seq2\nTCGGGGGATTCGCG\n"); - EXPECT_EQ(result.err, std::string{}); + EXPECT_EQ(result.err, ""); } TEST_F(fastq_to_fasta, with_argument_verbose) { - cli_test_result result = execute_app("app-template", data("in.fastq"), "-v"); - EXPECT_EQ(result.exit_code, 0); + cli_test_result const result = execute_app("app-template", data("in.fastq"), "-v"); + + EXPECT_SUCCESS(result); EXPECT_EQ(result.out, ">seq1\nACGTTTGATTCGCG\n>seq2\nTCGGGGGATTCGCG\n"); EXPECT_EQ(result.err, "Conversion was a success. Congrats!\n"); } TEST_F(fastq_to_fasta, with_out_file) { - cli_test_result result = execute_app("app-template", data("in.fastq"), "-o", "out.fasta"); - seqan3::sequence_file_input fin{"out.fasta", seqan3::fields{}}; - - // create records to compare - using record_type = typename decltype(fin)::record_type; - using seqan3::operator""_dna5; - std::vector records{}; - records.emplace_back("ACGTTTGATTCGCG"_dna5, std::string{"seq1"}); - records.emplace_back("TCGGGGGATTCGCG"_dna5, std::string{"seq2"}); - - EXPECT_RANGE_EQ(fin, records); - EXPECT_EQ(result.exit_code, 0); - EXPECT_EQ(result.out, std::string{}); - EXPECT_EQ(result.err, std::string{}); + cli_test_result const result = execute_app("app-template", data("in.fastq"), "-o", "out.fasta"); + std::string const expected = string_from_file(data("out.fasta")); + std::string const actual = string_from_file("out.fasta"); + + EXPECT_SUCCESS(result); + EXPECT_EQ(result.out, ""); + EXPECT_EQ(result.err, ""); + EXPECT_EQ(actual, expected); } diff --git a/test/data/datasources.cmake b/test/data/datasources.cmake index adb2574..46374ed 100644 --- a/test/data/datasources.cmake +++ b/test/data/datasources.cmake @@ -6,3 +6,6 @@ include (cmake/app_datasources.cmake) declare_datasource (FILE in.fastq URL ${CMAKE_SOURCE_DIR}/test/data/in.fastq URL_HASH SHA256=6e30fc35f908a36fe0c68a7a35c47f51f9570da16622fb0c072a20e6a9ba5b3e ) +declare_datasource (FILE out.fasta URL ${CMAKE_SOURCE_DIR}/test/data/out.fasta URL_HASH + SHA256=2c1ccd1b391c45cbbe1b4448584106d2ad2dc996a1636dcfd67342b7f943116a +) diff --git a/test/data/out.fasta b/test/data/out.fasta new file mode 100644 index 0000000..28292a3 --- /dev/null +++ b/test/data/out.fasta @@ -0,0 +1,4 @@ +>seq1 +ACGTTTGATTCGCG +>seq2 +TCGGGGGATTCGCG From bdabf7e1e0825d72ba2d9eba4ca8cfdf77be20ee Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Mon, 29 Jan 2024 17:03:26 +0100 Subject: [PATCH 6/9] [INFRA] Make app a bit more interesting --- include/configuration.hpp | 10 +++++++ include/fastq_conversion.hpp | 9 +++--- src/fastq_conversion.cpp | 12 ++++---- src/main.cpp | 37 ++++++++++++------------ test/api/convert_fastq_test.cpp | 6 ++-- test/cli/fastq_to_fasta_options_test.cpp | 19 ++++++++++++ 6 files changed, 61 insertions(+), 32 deletions(-) create mode 100644 include/configuration.hpp diff --git a/include/configuration.hpp b/include/configuration.hpp new file mode 100644 index 0000000..d48a5fa --- /dev/null +++ b/include/configuration.hpp @@ -0,0 +1,10 @@ +#pragma once + +#include + +struct configuration +{ + std::filesystem::path fastq_input{}; + std::filesystem::path fasta_output{}; + bool verbose{}; // Default is false. +}; diff --git a/include/fastq_conversion.hpp b/include/fastq_conversion.hpp index cdf164d..2f0edcb 100644 --- a/include/fastq_conversion.hpp +++ b/include/fastq_conversion.hpp @@ -1,12 +1,11 @@ #pragma once -#include +#include "configuration.hpp" /*! \brief Function, converting fastq files to fasta files. - * \param fastq_file input file path to the fastq file - * \param out output file path for the fasta file + * \param config The configuration. * * Simple function, converting fastq files to fasta files using the seqan3 library. - * For more information about the SeqAn Library functions see https://docs.seqan.de/seqan/3-master-user/. + * For more information about the SeqAn Library functions see https://docs.seqan.de/seqan3/main_user. */ -void convert_fastq(std::filesystem::path fastq_file, std::filesystem::path out); +void convert_fastq(configuration const & config); diff --git a/src/fastq_conversion.cpp b/src/fastq_conversion.cpp index a1e57e4..50982c8 100644 --- a/src/fastq_conversion.cpp +++ b/src/fastq_conversion.cpp @@ -2,12 +2,12 @@ #include -void convert_fastq(std::filesystem::path const fastq_file, std::filesystem::path const out) +void convert_fastq(configuration const & config) { - seqan3::sequence_file_input fin{fastq_file}; - seqan3::sequence_file_output fout{std::cout, seqan3::format_fasta{}}; - if (!out.empty()) // If an output path is given - fout = out; + seqan3::sequence_file_input file_input{config.fastq_input}; + seqan3::sequence_file_output file_output{std::cout, seqan3::format_fasta{}}; + if (!config.fasta_output.empty()) + file_output = config.fasta_output; - fout = fin; // conversion + file_output = file_input; // conversion } diff --git a/src/main.cpp b/src/main.cpp index 7ad56e3..263d35c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,36 +1,35 @@ -#include - #include #include "fastq_conversion.hpp" int main(int argc, char ** argv) { - sharg::parser parser{"Fastq-to-Fasta-Converter", argc, argv}; - - // Declarations for argument parser - std::filesystem::path fastq_file{}; - std::filesystem::path output_file{}; - bool verbose = false; + // Configuration + configuration config{}; // Parser - // Give the parser some infos. + sharg::parser parser{"Fastq-to-Fasta-Converter", argc, argv}; + + // General information. parser.info.author = "SeqAn-Team"; parser.info.version = "1.0.0"; - // Takes a fastq file and validates it. - parser.add_positional_option(fastq_file, - sharg::config{.description = "Please provide a fastq file.", + + // Positional option: The FASTQ file to convert. + parser.add_positional_option(config.fastq_input, + sharg::config{.description = "The FASTQ file to convert.", .validator = sharg::input_file_validator{{"fq", "fastq"}}}); - // Takes an output path, default is printing it to the terminal. - parser.add_option(output_file, + + // Open: Output FASTA file. Default: print to terminal - handled in fastq_conversion.cpp. + parser.add_option(config.fasta_output, sharg::config{.short_id = 'o', .long_id = "output", - .description = "The file for fasta output.", + .description = "The output FASTA file.", .default_message = "Print to terminal (stdout)", .validator = sharg::output_file_validator{}}); - // Example for a flag. + + // Flag: Verose output. parser.add_flag( - verbose, + config.verbose, sharg::config{.short_id = 'v', .long_id = "verbose", .description = "Give more detailed information."}); try @@ -43,9 +42,9 @@ int main(int argc, char ** argv) return -1; } - convert_fastq(fastq_file, output_file); // Call fastq to fasta converter. + convert_fastq(config); // Call fastq to fasta converter. - if (verbose) // If flag is set. + if (config.verbose) // If flag is set. std::cerr << "Conversion was a success. Congrats!\n"; return 0; diff --git a/test/api/convert_fastq_test.cpp b/test/api/convert_fastq_test.cpp index 18848e0..18ab112 100644 --- a/test/api/convert_fastq_test.cpp +++ b/test/api/convert_fastq_test.cpp @@ -10,7 +10,8 @@ TEST(convert_fastq, out_empty) std::string_view const expected{">seq1\nACGTTTGATTCGCG\n>seq2\nTCGGGGGATTCGCG\n"}; testing::internal::CaptureStdout(); - convert_fastq(cli_test::data("in.fastq"), ""); + configuration const config{.fastq_input = cli_test::data("in.fastq")}; + convert_fastq(config); std::string const std_cout = testing::internal::GetCapturedStdout(); EXPECT_EQ(expected, std_cout); @@ -22,7 +23,8 @@ TEST(convert_fastq, out_not_empty) seqan3::test::tmp_directory const tmp_dir{}; std::filesystem::path const test_output = tmp_dir.path() / "out.fasta"; - convert_fastq(cli_test::data("in.fastq"), test_output); // create out.fasta + configuration const config{.fastq_input = cli_test::data("in.fastq"), .fasta_output = test_output}; + convert_fastq(config); // create out.fasta ASSERT_TRUE(std::filesystem::exists(test_output)); // check whether out.fasta exists diff --git a/test/cli/fastq_to_fasta_options_test.cpp b/test/cli/fastq_to_fasta_options_test.cpp index e1e8637..1aca5cb 100644 --- a/test/cli/fastq_to_fasta_options_test.cpp +++ b/test/cli/fastq_to_fasta_options_test.cpp @@ -56,3 +56,22 @@ TEST_F(fastq_to_fasta, with_out_file) EXPECT_EQ(result.err, ""); EXPECT_EQ(actual, expected); } + +TEST_F(fastq_to_fasta, missing_path) +{ + cli_test_result const result = execute_app("app-template", data("in.fastq"), "-o", ""); + + EXPECT_FAILURE(result); + EXPECT_EQ(result.out, ""); + EXPECT_EQ(result.err, "Parsing error. Missing value for option -o\n"); +} + +TEST_F(fastq_to_fasta, invalid_path) +{ + cli_test_result const result = execute_app("app-template", data("in.fastq"), "-o", "does_not_exist/out.fasta"); + + EXPECT_FAILURE(result); + EXPECT_EQ(result.out, ""); + EXPECT_EQ(result.err, + "Parsing error. Validation failed for option -o/--output: Cannot write \"does_not_exist/out.fasta\"!\n"); +} From 5d6e560f0165d8dc1042e0680a557050d657abf2 Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Mon, 29 Jan 2024 17:23:44 +0100 Subject: [PATCH 7/9] [INFRA] cli_test -> app_test --- test/api/convert_fastq_test.cpp | 25 ++++++++++++------------ test/{cli/cli_test.hpp => app_test.hpp} | 18 ++++++++--------- test/cli/fastq_to_fasta_options_test.cpp | 19 +++++++++--------- 3 files changed, 31 insertions(+), 31 deletions(-) rename test/{cli/cli_test.hpp => app_test.hpp} (93%) diff --git a/test/api/convert_fastq_test.cpp b/test/api/convert_fastq_test.cpp index 18ab112..5984fac 100644 --- a/test/api/convert_fastq_test.cpp +++ b/test/api/convert_fastq_test.cpp @@ -1,35 +1,34 @@ #include -#include - -#include "../cli/cli_test.hpp" // For cli_test::data and cli_test::string_from_file. +#include "../app_test.hpp" #include "fastq_conversion.hpp" -TEST(convert_fastq, out_empty) +// To prevent issues when running multiple API tests in parallel, give each API test unique names: +struct fastq_to_fasta : public app_test +{}; + +TEST_F(fastq_to_fasta, out_empty) { std::string_view const expected{">seq1\nACGTTTGATTCGCG\n>seq2\nTCGGGGGATTCGCG\n"}; testing::internal::CaptureStdout(); - configuration const config{.fastq_input = cli_test::data("in.fastq")}; + configuration const config{.fastq_input = data("in.fastq")}; convert_fastq(config); std::string const std_cout = testing::internal::GetCapturedStdout(); EXPECT_EQ(expected, std_cout); } -TEST(convert_fastq, out_not_empty) +TEST_F(fastq_to_fasta, out_not_empty) { - // Creates a temporary directory and deletes it after the test. - seqan3::test::tmp_directory const tmp_dir{}; - - std::filesystem::path const test_output = tmp_dir.path() / "out.fasta"; - configuration const config{.fastq_input = cli_test::data("in.fastq"), .fasta_output = test_output}; + std::filesystem::path const test_output = "out.fasta"; + configuration const config{.fastq_input = data("in.fastq"), .fasta_output = test_output}; convert_fastq(config); // create out.fasta ASSERT_TRUE(std::filesystem::exists(test_output)); // check whether out.fasta exists // Check whether out.fasta is correct - std::string const expected = cli_test::string_from_file(cli_test::data("out.fasta")); - std::string const actual = cli_test::string_from_file(test_output); + std::string const expected = string_from_file(data("out.fasta")); + std::string const actual = string_from_file(test_output); EXPECT_EQ(actual, expected); } diff --git a/test/cli/cli_test.hpp b/test/app_test.hpp similarity index 93% rename from test/cli/cli_test.hpp rename to test/app_test.hpp index 1587c3c..fb797a6 100644 --- a/test/cli/cli_test.hpp +++ b/test/app_test.hpp @@ -2,11 +2,11 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include // Checks for CLI test result for success, and prints the command line call if the test fails. #ifndef EXPECT_SUCCESS @@ -19,7 +19,7 @@ #endif // Provides functions for CLI test implementation. -struct cli_test : public ::testing::Test +struct app_test : public ::testing::Test { private: // Holds the original work directory where Gtest has been started. @@ -27,7 +27,7 @@ struct cli_test : public ::testing::Test public: // Result struct for captured streams and exit code. - struct cli_test_result + struct app_test_result { std::string out{}; std::string err{}; @@ -37,9 +37,9 @@ struct cli_test : public ::testing::Test // Invoke the app execution. The command line call should be given as separate parameters. template - cli_test_result execute_app(CommandItemTypes &&... command_items) + app_test_result execute_app(CommandItemTypes &&... command_items) { - cli_test_result result{}; + app_test_result result{}; // Assemble the command string and disable version check. result.command = [&command_items...]() diff --git a/test/cli/fastq_to_fasta_options_test.cpp b/test/cli/fastq_to_fasta_options_test.cpp index 1aca5cb..da9a200 100644 --- a/test/cli/fastq_to_fasta_options_test.cpp +++ b/test/cli/fastq_to_fasta_options_test.cpp @@ -1,12 +1,12 @@ -#include "cli_test.hpp" +#include "../app_test.hpp" // To prevent issues when running multiple CLI tests in parallel, give each CLI test unique names: -struct fastq_to_fasta : public cli_test +struct fastq_to_fasta : public app_test {}; TEST_F(fastq_to_fasta, no_options) { - cli_test_result const result = execute_app("app-template"); + app_test_result const result = execute_app("app-template"); std::string_view const expected{"Fastq-to-Fasta-Converter\n" "========================\n" " Try -h or --help for more information.\n"}; @@ -18,7 +18,7 @@ TEST_F(fastq_to_fasta, no_options) TEST_F(fastq_to_fasta, fail_no_argument) { - cli_test_result const result = execute_app("app-template", "-v"); + app_test_result const result = execute_app("app-template", "-v"); std::string_view const expected{"Parsing error. Not enough positional arguments provided (Need at least 1). " "See -h/--help for more information.\n"}; @@ -29,7 +29,7 @@ TEST_F(fastq_to_fasta, fail_no_argument) TEST_F(fastq_to_fasta, with_argument) { - cli_test_result const result = execute_app("app-template", data("in.fastq")); + app_test_result const result = execute_app("app-template", data("in.fastq")); EXPECT_SUCCESS(result); EXPECT_EQ(result.out, ">seq1\nACGTTTGATTCGCG\n>seq2\nTCGGGGGATTCGCG\n"); @@ -38,7 +38,7 @@ TEST_F(fastq_to_fasta, with_argument) TEST_F(fastq_to_fasta, with_argument_verbose) { - cli_test_result const result = execute_app("app-template", data("in.fastq"), "-v"); + app_test_result const result = execute_app("app-template", data("in.fastq"), "-v"); EXPECT_SUCCESS(result); EXPECT_EQ(result.out, ">seq1\nACGTTTGATTCGCG\n>seq2\nTCGGGGGATTCGCG\n"); @@ -47,8 +47,9 @@ TEST_F(fastq_to_fasta, with_argument_verbose) TEST_F(fastq_to_fasta, with_out_file) { - cli_test_result const result = execute_app("app-template", data("in.fastq"), "-o", "out.fasta"); + app_test_result const result = execute_app("app-template", data("in.fastq"), "-o", "out.fasta"); std::string const expected = string_from_file(data("out.fasta")); + ASSERT_TRUE(std::filesystem::exists("out.fasta")); // check whether out.fasta exists std::string const actual = string_from_file("out.fasta"); EXPECT_SUCCESS(result); @@ -59,7 +60,7 @@ TEST_F(fastq_to_fasta, with_out_file) TEST_F(fastq_to_fasta, missing_path) { - cli_test_result const result = execute_app("app-template", data("in.fastq"), "-o", ""); + app_test_result const result = execute_app("app-template", data("in.fastq"), "-o", ""); EXPECT_FAILURE(result); EXPECT_EQ(result.out, ""); @@ -68,7 +69,7 @@ TEST_F(fastq_to_fasta, missing_path) TEST_F(fastq_to_fasta, invalid_path) { - cli_test_result const result = execute_app("app-template", data("in.fastq"), "-o", "does_not_exist/out.fasta"); + app_test_result const result = execute_app("app-template", data("in.fastq"), "-o", "does_not_exist/out.fasta"); EXPECT_FAILURE(result); EXPECT_EQ(result.out, ""); From 13f161e301dc53b022a7f5a9a74f4682f8262ec6 Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Mon, 29 Jan 2024 17:39:30 +0100 Subject: [PATCH 8/9] [INFRA] lint CI --- .github/dependabot.yml | 9 ++++++++ .github/workflows/lint.yml | 46 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/lint.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..dcbcb65 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..d4ec012 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,46 @@ +name: Lint + +on: + workflow_dispatch: + +env: + TZ: Europe/Berlin + +defaults: + run: + shell: bash -Eeuxo pipefail {0} + +jobs: + lint: + name: Lint + runs-on: ubuntu-22.04 + timeout-minutes: 30 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + submodules: false + + - name: Run clang-format + uses: DoozyX/clang-format-lint-action@v0.17 + with: + clangFormatVersion: 17 + inplace: True + + - name: Run cmake-format + uses: PuneetMatharu/cmake-format-lint-action@v1.0.4 + with: + args: --config-files .cmake-format.yaml --in-place + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + commit-message: '[MISC] Automatic linting' + committer: github-actions[bot] + author: github-actions[bot] + body: Automatic linting + signoff: false + branch: actions/lint + delete-branch: true + title: '[MISC] Automatic linting' From 0d9328c0e094ebcca36817ce86b3470d6c653afd Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Mon, 29 Jan 2024 19:14:09 +0100 Subject: [PATCH 9/9] [INFRA] Make execute_app generic --- test/CMakeLists.txt | 1 + test/app_test.hpp | 6 +++--- test/cli/fastq_to_fasta_options_test.cpp | 14 +++++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 610ae95..54ea99c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -14,6 +14,7 @@ file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/output) add_definitions (-DOUTPUTDIR=\"${CMAKE_CURRENT_BINARY_DIR}/output/\") add_definitions (-DDATADIR=\"${CMAKE_CURRENT_BINARY_DIR}/data/\") add_definitions (-DBINDIR=\"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/\") +add_definitions (-DAPPNAME=\"${PROJECT_NAME}\") # Test executables and libraries should not mix with the application files. # This must happen after setting the output directories. diff --git a/test/app_test.hpp b/test/app_test.hpp index fb797a6..b9a8092 100644 --- a/test/app_test.hpp +++ b/test/app_test.hpp @@ -25,7 +25,7 @@ struct app_test : public ::testing::Test // Holds the original work directory where Gtest has been started. std::filesystem::path original_workdir{}; -public: +protected: // Result struct for captured streams and exit code. struct app_test_result { @@ -45,8 +45,8 @@ struct app_test : public ::testing::Test result.command = [&command_items...]() { std::ostringstream command{}; - command << "SHARG_NO_VERSION_CHECK=1 " << BINDIR; - (void)((command << command_items << ' '), ...); // (void) silences "state has no effect" warning if no items + command << "SHARG_NO_VERSION_CHECK=1 " << BINDIR << APPNAME; + (void)((command << ' ' << command_items), ...); // (void) silences "state has no effect" warning if no items return command.str(); }(); diff --git a/test/cli/fastq_to_fasta_options_test.cpp b/test/cli/fastq_to_fasta_options_test.cpp index da9a200..2c1f17f 100644 --- a/test/cli/fastq_to_fasta_options_test.cpp +++ b/test/cli/fastq_to_fasta_options_test.cpp @@ -6,7 +6,7 @@ struct fastq_to_fasta : public app_test TEST_F(fastq_to_fasta, no_options) { - app_test_result const result = execute_app("app-template"); + app_test_result const result = execute_app(); std::string_view const expected{"Fastq-to-Fasta-Converter\n" "========================\n" " Try -h or --help for more information.\n"}; @@ -18,7 +18,7 @@ TEST_F(fastq_to_fasta, no_options) TEST_F(fastq_to_fasta, fail_no_argument) { - app_test_result const result = execute_app("app-template", "-v"); + app_test_result const result = execute_app("-v"); std::string_view const expected{"Parsing error. Not enough positional arguments provided (Need at least 1). " "See -h/--help for more information.\n"}; @@ -29,7 +29,7 @@ TEST_F(fastq_to_fasta, fail_no_argument) TEST_F(fastq_to_fasta, with_argument) { - app_test_result const result = execute_app("app-template", data("in.fastq")); + app_test_result const result = execute_app(data("in.fastq")); EXPECT_SUCCESS(result); EXPECT_EQ(result.out, ">seq1\nACGTTTGATTCGCG\n>seq2\nTCGGGGGATTCGCG\n"); @@ -38,7 +38,7 @@ TEST_F(fastq_to_fasta, with_argument) TEST_F(fastq_to_fasta, with_argument_verbose) { - app_test_result const result = execute_app("app-template", data("in.fastq"), "-v"); + app_test_result const result = execute_app(data("in.fastq"), "-v"); EXPECT_SUCCESS(result); EXPECT_EQ(result.out, ">seq1\nACGTTTGATTCGCG\n>seq2\nTCGGGGGATTCGCG\n"); @@ -47,7 +47,7 @@ TEST_F(fastq_to_fasta, with_argument_verbose) TEST_F(fastq_to_fasta, with_out_file) { - app_test_result const result = execute_app("app-template", data("in.fastq"), "-o", "out.fasta"); + app_test_result const result = execute_app(data("in.fastq"), "-o", "out.fasta"); std::string const expected = string_from_file(data("out.fasta")); ASSERT_TRUE(std::filesystem::exists("out.fasta")); // check whether out.fasta exists std::string const actual = string_from_file("out.fasta"); @@ -60,7 +60,7 @@ TEST_F(fastq_to_fasta, with_out_file) TEST_F(fastq_to_fasta, missing_path) { - app_test_result const result = execute_app("app-template", data("in.fastq"), "-o", ""); + app_test_result const result = execute_app(data("in.fastq"), "-o", ""); EXPECT_FAILURE(result); EXPECT_EQ(result.out, ""); @@ -69,7 +69,7 @@ TEST_F(fastq_to_fasta, missing_path) TEST_F(fastq_to_fasta, invalid_path) { - app_test_result const result = execute_app("app-template", data("in.fastq"), "-o", "does_not_exist/out.fasta"); + app_test_result const result = execute_app(data("in.fastq"), "-o", "does_not_exist/out.fasta"); EXPECT_FAILURE(result); EXPECT_EQ(result.out, "");