Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ jobs:
check-path: "${{ matrix.path }}"
unit-tests:
name: "Build ${{ matrix.build_type }} with ${{ matrix.cxx }}"
needs: [ "codespell-check" , "format-check" ]
runs-on: ubuntu-22.04
strategy:
matrix:
Expand Down Expand Up @@ -112,8 +111,9 @@ jobs:
run: |
pip install --upgrade gcovr
gcovr \
--exclude-throw-branches \
--xml coverage.xml \
--exclude-throw-branches \
--exclude tests/ \
--xml coverage.xml \
--gcov-executable "${{ startsWith(matrix.cxx, 'clang-') && format('llvm-cov-{0} gcov', env.CXX_VERSION) || format('gcov-{0}', env.CXX_VERSION) }}" \
../build
- name: "Upload coverage report"
Expand All @@ -127,7 +127,7 @@ jobs:

upload-to-codecov:
name: "Codecov report upload"
needs: [ "unit-tests" ]
needs: [ "unit-tests" , "codespell-check" , "format-check" ]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand Down
26 changes: 22 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ if (NOT PROJECT_IS_TOP_LEVEL)
message(STATUS "CAPIO-CL included as subproject → tests disabled")
endif ()

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-O0 -g)
endif()
endif ()

if(ENABLE_COVERAGE)
if (ENABLE_COVERAGE)
message(STATUS "Building with code coverage instrumentation")
add_compile_options(--coverage -O0 -g)
add_link_options(--coverage)
endif()
endif ()

#####################################
# External projects
Expand Down Expand Up @@ -142,11 +142,29 @@ if (CAPIO_CL_BUILD_TESTS)
include(GoogleTest)
gtest_discover_tests(CAPIO_CL_tests)

#####################################
# Copy JSON test files
#####################################
set(TEST_JSON_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests/jsons")

add_custom_command(
TARGET CAPIO_CL_tests PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "/tmp/capio_cl_jsons"
COMMAND ${CMAKE_COMMAND} -E copy_directory ${TEST_JSON_DIR} "/tmp/capio_cl_jsons"
COMMENT "Copying JSON test files to build directory"
)

#####################################
# Install rules
#####################################
# Optionally install tests
install(TARGETS CAPIO_CL_tests
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Copy tests jsons
install(DIRECTORY ${TEST_JSON_DIR}
DESTINATION ${CMAKE_INSTALL_BINDIR}/jsons
FILES_MATCHING PATTERN "*.json"
)
endif ()
54 changes: 28 additions & 26 deletions capiocl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,13 @@ class Engine {
*
* @param str Input string.
* @param n Number of characters to keep from the end.
* @return Truncated string with optional "[..]" prefix.
* @return Truncated string with "[..]" prefix.
*/
static std::string truncateLastN(const std::string &str, const std::size_t n) {
return str.length() > n ? "[..] " + str.substr(str.length() - n) : str;
if (str.length() > n) {
return "[..] " + str.substr(str.length() - n);
}
return str;
}

protected:
Expand Down Expand Up @@ -320,7 +323,7 @@ class Engine {
std::vector<std::string> getConsumers(const std::string &path);

/// @brief Get the commit-on-close counter for a file.
long getCommitCloseCount(std::filesystem::path::iterator::reference path) const;
long getCommitCloseCount(std::filesystem::path::iterator::reference path);

/// @brief Get file dependencies.
std::vector<std::string> getCommitOnFileDependencies(const std::filesystem::path &path);
Expand Down Expand Up @@ -350,7 +353,7 @@ class Engine {
bool isConsumer(const std::string &path, const std::string &app_name);

/**
* @brief Check if a file is firable.
* @brief Check if a file is firable, that is fire rule is no_update.
*
* @param path File path.
* @return true if the file is firable, false otherwise.
Expand All @@ -371,7 +374,7 @@ class Engine {
* @param path File path.
* @return true if excluded, false otherwise.
*/
bool isExcluded(const std::string &path) const;
bool isExcluded(const std::string &path);

/**
* @brief Check if a path is a directory.
Expand All @@ -396,48 +399,47 @@ class Engine {
* @return
*/
bool isPermanent(const std::string &path);

bool operator==(const capiocl::Engine &other) const;
};

/**
* @brief Contains the code to parse a JSON based CAPIO-CL configuration file
*
*/
class Parser {
/**
* @brief Check if a string is a representation of a integer number
*
* @param s
* @return true
* @return false
*/
static bool isInteger(const std::string &s);

/**
* @brief compare two paths
*
* @param path
* @param base
* @return true if @p path is a subdirectory of base
* @return false otherwise
*/
static inline bool firstIsSubpathOfSecond(const std::filesystem::path &path,
const std::filesystem::path &base);
static std::filesystem::path resolve(std::filesystem::path path,
const std::filesystem::path &prefix);

public:
/**
* @brief Perform the parsing of the capio_server configuration file
*
* @param source
* @param resolve_prexix
* @param resolve_prefix
* @param store_only_in_memory Set to true to set all files to be stored in memory
* @return Tuple with workflow name and CapioCLEngine instance with the information provided by
* the config file
*/
static std::tuple<std::string, Engine *> parse(const std::filesystem::path &source,
std::filesystem::path &resolve_prexix,
const std::filesystem::path &resolve_prefix = "",
bool store_only_in_memory = false);
};

/**
* Custom exception for errors occurring within the Parser component
*/
class ParserException : public std::exception {
std::string message;

public:
explicit ParserException(const std::string &msg) : message(msg) {
print_message(CLI_LEVEL_ERROR, msg);
}
const char *what() const noexcept override { return message.c_str(); }
};

class Serializer {
public:
/**
Expand All @@ -447,7 +449,7 @@ class Serializer {
* @param workflow_name Name of the current workflow
* @param filename path of output file @param filename
*/
static void dump(const Engine &engine, const std::string workflow_name,
static void dump(const Engine &engine, const std::string &workflow_name,
const std::filesystem::path &filename);
};
} // namespace capiocl
Expand Down
Loading
Loading