From a165cf67e9ca47a98f7bd383469dc7e78a09185a Mon Sep 17 00:00:00 2001 From: Lasse Lukkari Date: Sun, 12 Jan 2025 11:23:45 +0200 Subject: [PATCH] Cleanup extra comments and format files --- .arduino-ci.yml | 27 ------------- .gitattributes | 3 -- .github/workflows/CompileExamples.yml | 57 ++------------------------- .github/workflows/NativeUnitTests.yml | 57 ++++----------------------- .travis.yml | 4 -- Gemfile | 2 - test/CMakeLists.txt | 33 ---------------- test/unittest/ArduinoUnitTests.h | 25 ++---------- test/unittest/Assertion.h | 10 ----- test/unittest/Compare.h | 8 ---- test/unittest/OstreamHelpers.h | 1 - 11 files changed, 15 insertions(+), 212 deletions(-) delete mode 100644 .arduino-ci.yml delete mode 100644 .travis.yml delete mode 100644 Gemfile diff --git a/.arduino-ci.yml b/.arduino-ci.yml deleted file mode 100644 index 81738993..00000000 --- a/.arduino-ci.yml +++ /dev/null @@ -1,27 +0,0 @@ -platforms: - uno: - board: arduino:avr:uno - package: arduino:avr - due: - board: arduino:sam:arduino_due_x - package: arduino:sam - esp32: - board: esp32:esp32:esp32 - package: esp32:esp32 - mega2560: - board: arduino:avr:mega:cpu=atmega2560 - package: arduino:avr - gcc: - defines: - - __AVR_ATmega2560__ - -compile: - platforms: - - uno - - mega2560 - - due - - esp32 - -unittest: - platforms: - - mega2560 diff --git a/.gitattributes b/.gitattributes index ffcb1d88..652dff21 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,2 @@ -arduino-ci.yml export-ignore /test/ export-ignore .git* export-ignore -.travis.yml export-ignore -Gemfile export-ignore diff --git a/.github/workflows/CompileExamples.yml b/.github/workflows/CompileExamples.yml index 8816bd1d..79be0c63 100644 --- a/.github/workflows/CompileExamples.yml +++ b/.github/workflows/CompileExamples.yml @@ -1,109 +1,62 @@ - -# Description: 'Run the Arduino CLI to compile example sketches and check if they compile correctly for multiple boards' -# Author: 'Jorge Rivera' #url: 'https://github.com/latchdevel' - -# This is the name of the workflow, visible on GitHub UI. name: Compile examples - -# Controls when the action will run. -# Here we tell GitHub to run the workflow when a commit. on: - # Triggers the workflow on push or pull request events push: paths: - "src/**" - "examples/**" - ".github/workflows/CompileExamples.yml" - pull_request: paths: - "src/**" - "examples/**" - ".github/workflows/CompileExamples.yml" - - # Scheduled the first day of every month at 00:00h UTC schedule: - - cron: '0 0 1 * *' + - cron: "0 0 1 * *" - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: repository_dispatch: - -# This is the list of jobs that will be run concurrently. -# Since we use a build matrix, the actual number of jobs -# started depends on how many configurations the matrix -# will produce. jobs: boards: - # This is the name of the job name: "Compile for ${{ matrix.config.board }}" - - # This is the platform GitHub will use to run our workflow runs-on: ubuntu-latest - - # Here we tell GitHub that the jobs must be determined - # dynamically depending on a matrix configuration. strategy: - - # Set to false so that GitHub does not cancel all jobs - # in progress if any array job fails. fail-fast: false - - # The matrix will produce one job for each configuration: matrix: config: - board: "Arduino Uno" fqbn: "arduino:avr:uno" platform: "arduino:avr" - - board: "Arduino Leonardo" fqbn: "arduino:avr:leonardo" platform: "arduino:avr" - - board: "Arduino Mega2560" fqbn: "arduino:avr:mega" platform: "arduino:avr" - - board: "Arduino Due" fqbn: "arduino:sam:arduino_due_x" platform: "arduino:sam" - - board: "ESP32 NodeMCU-32S" fqbn: "esp32:esp32:nodemcu-32s" platform: "esp32:esp32" additional-url: "--additional-urls https://dl.espressif.com/dl/package_esp32_index.json" - - # This is the list of steps this job will run. steps: - # We use the "arduino/setup-arduino-cli" action to install and - # configure the Arduino CLI on the system. - name: Setup Arduino CLI uses: arduino/setup-arduino-cli@v2 - - # We then install the platform, which one will be determined - # dynamically by the build matrix. - - name: Install platform ${{ matrix.config.platform }} + - name: Install platform ${{ matrix.config.platform }} run: | arduino-cli config init -v ${{ matrix.config.additional-url }} arduino-cli core update-index -v arduino-cli core install -v ${{ matrix.config.platform }} --run-post-install - - # Install generic libraries from Arduino library manager. - name: Install Arduino libraries run: | arduino-cli lib update-index arduino-cli lib install Ethernet arduino-cli lib install LoRa - - # First of all, we clone the repo using the "checkout" action. - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Checkout uses: actions/checkout@v4 - - # Finally, we compile the sketches, using the FQBN that was set in the boards matrix. - name: Compile examples for ${{ matrix.config.board }} id: compile - env: + env: fqbn: ${{ matrix.config.fqbn }} run: | # Compile example sketches: @@ -121,11 +74,9 @@ jobs: ;} done echo "errors=${errors[@]}" >> $GITHUB_OUTPUT - - # Show errors - name: Show errors if: ${{ steps.compile.outputs.errors }} - env: + env: errors: ${{ steps.compile.outputs.errors }} run: | # Show errors diff --git a/.github/workflows/NativeUnitTests.yml b/.github/workflows/NativeUnitTests.yml index 8268acda..e24f0318 100644 --- a/.github/workflows/NativeUnitTests.yml +++ b/.github/workflows/NativeUnitTests.yml @@ -1,86 +1,45 @@ -# Run aWOT Unit Tests natively on MacOS and Linux systems. - -# This is the name of the workflow, visible on GitHub UI. name: Unit Tests - -# Controls when the action will run. -# Here we tell GitHub to run the workflow when a commit. on: - # Triggers the workflow on push or pull request events push: paths: - "src/**" - "test/**" - ".github/workflows/NativeUnitTests.yml" - pull_request: paths: - "src/**" - "test/**" - ".github/workflows/NativeUnitTests.yml" - - # Scheduled the first day of every month at 00:00h UTC schedule: - - cron: '0 0 1 * *' - - # Allows you to run this workflow manually from the Actions tab + - cron: "0 0 1 * *" workflow_dispatch: repository_dispatch: - -# This is the list of jobs that will be run concurrently. -# Since we use a build matrix, the actual number of jobs -# started depends on how many configurations the matrix -# will produce. jobs: build: - # This is the name of the job - name: 'Build for ${{ matrix.config.name }}' - - # The CMake configure and build commands are platform agnostic and should work equally - # well on Windows, Linux or Mac. + name: "Build for ${{ matrix.config.name }}" runs-on: ${{ matrix.config.os }} - - # Job env var for cmake build directory env: BUILD_DIR: ${{ github.workspace }}/test/build - - # Here we tell GitHub that the jobs must be determined - # dynamically depending on a matrix configuration. strategy: - - # Set to false so that GitHub does not cancel all jobs - # in progress if any array job fails. fail-fast: false - - # The matrix will produce one job for each configuration: matrix: config: - - name: 'Linux x86_64' - os: 'ubuntu-latest' - - - name: 'macOS Universal' - os: 'macos-latest' - - # This is the list of steps this job will run. + - name: "Linux x86_64" + os: "ubuntu-latest" + - name: "macOS Universal" + os: "macos-latest" steps: - # Clone repo using the checkout action. - name: Checkout uses: actions/checkout@v4 - - name: Create Build Environment - # Some projects don't allow in-source building, so create a separate build directory - # We'll use this as our working directory for all subsequent commands run: cmake -E make_directory ${{ env.BUILD_DIR }} - - - name: Running CMake + - name: Running CMake working-directory: ${{ env.BUILD_DIR }} run: cmake .. - - name: Build Unit Tests working-directory: ${{ env.BUILD_DIR }} run: cmake --build . - - name: Run Unit Tests if: ${{ success() }} working-directory: ${{ env.BUILD_DIR }} - run: ctest \ No newline at end of file + run: ctest diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 62fd5398..00000000 --- a/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: ruby -script: - - bundle install - - bundle exec arduino_ci_remote.rb diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 652ddfb6..00000000 --- a/Gemfile +++ /dev/null @@ -1,2 +0,0 @@ -source 'https://rubygems.org' -gem 'arduino_ci', github: 'lasselukkari/arduino_ci' diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b8054c62..dacad993 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,98 +1,65 @@ -# -# CMake file to build and run aWOT Unit Tests natively on MacOS or Linux systems. -# -# Arduino Unit Tests from https://github.com/Arduino-CI/arduino_ci Apache-2.0 license -# EpoxyDuino Core from https://github.com/bxparks/EpoxyDuino MIT License -# -# MIT License - cmake_minimum_required( VERSION 3.18 ) project( aWOT-test LANGUAGES CXX ) -# Set C++ standard set( CMAKE_CXX_STANDARD 11 ) set( CMAKE_CXX_STANDARD_REQUIRED TRUE ) -# Set compiler identification if( NOT BUILD_COMPILER ) set( BUILD_COMPILER "${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}" ) message( STATUS "C++ compiler: " ${BUILD_COMPILER} ) endif() -# If macOS builds a Mach-O universal binary with 2 architectures: x86_64 and arm64 for Apple M processors if ( APPLE ) set( CMAKE_OSX_ARCHITECTURES "x86_64;arm64" ) endif() -# Set build type to "Debug" set( CMAKE_BUILD_TYPE "Debug" ) -# Ensures all binaries are placed in the same output directory set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR} ) -# Setting build type to "debug" add only -g set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG" ) -# Set C++ compiler flags if ( CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-gnu-zero-variadic-macro-arguments" ) elseif ( CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4" ) endif() -# Enable testing enable_testing() -# Add EpoxyDuino Core source files aux_source_directory( epoxy EPOXY ) -# Compile EpoxyDuino Core as an object library add_library( ${PROJECT_NAME}-EpoxyDuino OBJECT ${EPOXY} ) -# Add include directory to use #include or "file.h" target_include_directories( ${PROJECT_NAME}-EpoxyDuino PUBLIC epoxy ) -# Defines EPOXY_CORE_ESP8266 macro for EpoxyDuino Core target_compile_definitions( ${PROJECT_NAME}-EpoxyDuino PRIVATE EPOXY_CORE_ESP8266 ) -# Add Arduino Unit Test source files aux_source_directory( unittest UNITTEST ) -# Compile Arduino Unit Test as an object library add_library( ${PROJECT_NAME}-unittest OBJECT ${UNITTEST} ) -# Add include directory to use #include or "file.h" target_include_directories( ${PROJECT_NAME}-unittest PUBLIC epoxy ) -# Add aWOT source files aux_source_directory( ../src aWOT ) -# Compile aWOT as an object library add_library( ${PROJECT_NAME}-aWOT OBJECT ${aWOT} ) -# Add include directory to use #include or "file.h" target_include_directories( ${PROJECT_NAME}-aWOT PUBLIC epoxy unittest ) -# List of test source files file( GLOB TEST_SOURCES *.cpp ) foreach( TEST_FILE ${TEST_SOURCES} ) - - # Get test name get_filename_component( TEST_NAME ${TEST_FILE} NAME_WE ) - # Compile test target add_executable( ${PROJECT_NAME}-${TEST_NAME} ${TEST_FILE} ) target_link_libraries( ${PROJECT_NAME}-${TEST_NAME} PRIVATE ${PROJECT_NAME}-aWOT ${PROJECT_NAME}-EpoxyDuino ${PROJECT_NAME}-unittest ) - # Add test add_test( NAME ${TEST_NAME} COMMAND $ ) - # Add test to dependency list list( APPEND TEST_LIST ${PROJECT_NAME}-${TEST_NAME} ) endforeach() -# Add optional target to run tests add_custom_target( run_tests COMMAND ${CMAKE_CTEST_COMMAND} --verbose DEPENDS ${TEST_LIST} ) diff --git a/test/unittest/ArduinoUnitTests.h b/test/unittest/ArduinoUnitTests.h index 3c34a786..d1d45622 100644 --- a/test/unittest/ArduinoUnitTests.h +++ b/test/unittest/ArduinoUnitTests.h @@ -8,7 +8,7 @@ using namespace std; struct Results { int passed; int failed; - int skipped; // TODO: not sure about this + int skipped; }; struct TestData { @@ -50,7 +50,7 @@ class Test void onTestRunInit(int numTests) { cerr << "TAP version 13" << endl; - cerr << 1 << ".." << numTests << endl; // we know how many tests, in advance + cerr << 1 << ".." << numTests << endl; mTestCounter = 0; } @@ -69,7 +69,6 @@ class Test } } - // non-comparative assert void onAssert( const char* file, int line, @@ -118,7 +117,6 @@ class Test ReporterTAP* mReporter; const char* mName; - // linked list structure for active tests static Test* sRoot; Test* mNext; @@ -142,7 +140,6 @@ class Test return i; } - // current test result int mResult; public: @@ -185,23 +182,17 @@ class Test return results; } - // TODO: figure out TAP output like - // https://api.travis-ci.org/v3/job/283745834/log.txt - // https://testanything.org/tap-specification.html - // parse input and decide how to report static int run_and_report(int argc, char *argv[]) { - // TODO: pick a reporter based on args ReporterTAP rep; Results results = run(&rep); return results.failed + results.skipped; } void prepare() { - mResult = RESULT_PASS; // not None, and not fail unless we hear otherwise + mResult = RESULT_PASS; } void test() { - // thin wrapper. nothing to do here for now task(); } @@ -259,11 +250,6 @@ class Test }; -/** - * Extend the class into a struct. - * The implementation of task() will follow the macro - * - */ #define unittest(name) \ struct test_##name : Test \ { \ @@ -272,11 +258,6 @@ class Test } test_##name##_instance; \ void test_##name ::task() -/** - * The unittest_setup and unittest_teardown functions are intended to be used - * to set up "external" dependencies that needs to present but are not directly - * related to the functionality that you are testing, for instance a LCD. - */ #define unittest_setup() \ class unittest_setup_class : public TestSetup { \ public: \ diff --git a/test/unittest/Assertion.h b/test/unittest/Assertion.h index 58dfb621..97edcd5f 100644 --- a/test/unittest/Assertion.h +++ b/test/unittest/Assertion.h @@ -29,17 +29,12 @@ } \ } while (0) - - -// helper define for the operators below #define arduinoCIAssertOp(desc, rel1, arg1, op, op_name, rel2, arg2) \ arduinoCITestBehaviorOp(false, "assert" desc, rel1, arg1, op, op_name, rel2, arg2) #define arduinoCIAssureOp(desc, rel1, arg1, op, op_name, rel2, arg2) \ arduinoCITestBehaviorOp(true, "assure" desc, rel1, arg1, op, op_name, rel2, arg2) - -/** macro generates optional output and calls fail() but does not return if false. */ #define assertTrue(arg) arduinoCITestBehaviorExp(false, "True " #arg, (arg)) #define assertFalse(arg) arduinoCITestBehaviorExp(false, "False " #arg, !(arg)) #define assertNull(arg) arduinoCITestBehaviorExp(false, "Null " #arg, ((void*)NULL == (void*)(arg))) @@ -52,16 +47,12 @@ #define assertMore(arg1,arg2) arduinoCIAssertOp("More","upperBound",arg1,compareMore,">","actual",arg2) #define assertLessOrEqual(arg1,arg2) arduinoCIAssertOp("LessOrEqual","lowerBound",arg1,compareLessOrEqual,"<=","actual",arg2) #define assertMoreOrEqual(arg1,arg2) arduinoCIAssertOp("MoreOrEqual","upperBound",arg1,compareMoreOrEqual,">=","actual",arg2) - #define assertEqualFloat(arg1, arg2, arg3) arduinoCIAssertOp("EqualFloat", "epsilon", arg3, compareMoreOrEqual, ">=", "actualDifference", fabs(arg1 - arg2)) #define assertNotEqualFloat(arg1, arg2, arg3) arduinoCIAssertOp("NotEqualFloat", "epsilon", arg3, compareLessOrEqual, "<=", "insufficientDifference", fabs(arg1 - arg2)) #define assertInfinity(arg) arduinoCITestBehaviorExp(false, "Infinity " #arg, isinf(arg)) #define assertNotInfinity(arg) arduinoCITestBehaviorExp(false, "NotInfinity " #arg, !isinf(arg)) #define assertNAN(arg) arduinoCITestBehaviorExp(false, "NAN " #arg, isnan(arg)) #define assertNotNAN(arg) arduinoCITestBehaviorExp(false, "NotNAN " #arg, !isnan(arg)) - - -/** macro generates optional output and calls fail() followed by a return if false. */ #define assureTrue(arg) arduinoCITestBehaviorExp(true, "True " #arg, (arg)) #define assureFalse(arg) arduinoCITestBehaviorExp(true, "False " #arg, !(arg)) #define assureNull(arg) arduinoCITestBehaviorExp(true, "Null " #arg, ((void*)NULL == (void*)(arg))) @@ -74,7 +65,6 @@ #define assureMore(arg1,arg2) arduinoCIAssureOp("More","upperBound",arg1,compareMore,">","actual",arg2) #define assureLessOrEqual(arg1,arg2) arduinoCIAssureOp("LessOrEqual","lowerBound",arg1,compareLessOrEqual,"<=","actual",arg2) #define assureMoreOrEqual(arg1,arg2) arduinoCIAssureOp("MoreOrEqual","upperBound",arg1,compareMoreOrEqual,">=","actual",arg2) - #define assureEqualFloat(arg1, arg2, arg3) arduinoCIAssureOp("EqualFloat", "epsilon", arg3, compareMoreOrEqual, ">=", "actualDifference", fabs(arg1 - arg2)) #define assureNotEqualFloat(arg1, arg2, arg3) arduinoCIAssureOp("NotEqualFloat", "epsilon", arg3, compareLessOrEqual, "<=", "insufficientDifference", fabs(arg1 - arg2)) #define assureInfinity(arg) arduinoCITestBehaviorExp(true, "Infinity " #arg, isinf(arg)) diff --git a/test/unittest/Compare.h b/test/unittest/Compare.h index cb4c9d16..d04f19ac 100644 --- a/test/unittest/Compare.h +++ b/test/unittest/Compare.h @@ -20,7 +20,6 @@ template < typename A, typename B > struct Compare inline static bool moreOrEqual(const A &a,const B &b) { return !(a struct Compare; \ template < __VA_ARGS__ > struct Compare \ @@ -103,11 +98,8 @@ eqComparisonTemplateMacro(char, [N], String, , eqComparisonTemplateMacro(char, [N], const char *, , strcmp(a,b), size_t N) eqComparisonTemplateMacro(char, [N], char *, , strcmp(a,b), size_t N) eqComparisonTemplateMacro(char, [N], char, [M], strcmp(a,b), size_t N, size_t M) - eqComparisonTemplateMacro(A, , std::nullptr_t, , a ? 1 : 0, typename A) eqComparisonTemplateMacro(std::nullptr_t, , B, , b ? -1 : 0, typename B) - -// super general comparisons template int compareBetween( const A &a, const B &b) { return Compare::between( a, b); } template bool compareEqual( const A &a, const B &b) { return Compare::equal( a, b); } template bool compareNotEqual( const A &a, const B &b) { return Compare::notEqual( a, b); } diff --git a/test/unittest/OstreamHelpers.h b/test/unittest/OstreamHelpers.h index 14280d3a..edff8f3f 100644 --- a/test/unittest/OstreamHelpers.h +++ b/test/unittest/OstreamHelpers.h @@ -3,7 +3,6 @@ #include #if (defined __apple_build_version__) && (__apple_build_version__ >= 12000000) -// defined in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ostream:223:20 #else inline std::ostream& operator << (std::ostream& out, const std::nullptr_t &np) { return out << "nullptr"; } #endif