Skip to content
Closed
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
21 changes: 16 additions & 5 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
name: Check

on: [push, pull_request]
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
os: [ubuntu-22.04, windows-latest]
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Tests
run: make
Expand All @@ -27,7 +35,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
uses: actions/cache@v3
with:
Expand All @@ -43,5 +51,8 @@ jobs:
name: Install PlatformIO Core
run: pip install --upgrade platformio
-
name: Tests
name: Build example
run: pio test -d examples/wiring-blink/
-
name: Build Tests
run: pio test
18 changes: 9 additions & 9 deletions external/fakeit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
cmake_minimum_required(VERSION 3.2.2)
cmake_minimum_required(VERSION 3.14)
project(fakeit VERSION 2.4.0 LANGUAGES CXX)

include(git-download)
include(FetchContent)

set(REPO_DIR ${PROJECT_SOURCE_DIR}/${PROJECT_NAME}-repo)

download_repo(
URL "https://github.com/eranpeer/FakeIt.git"
TAG ${PROJECT_VERSION}
CLONE_DIR ${REPO_DIR}
FetchContent_Declare(
fakeit_repo
GIT_REPOSITORY https://github.com/eranpeer/FakeIt.git
GIT_TAG ${PROJECT_VERSION}
)

FetchContent_MakeAvailable(fakeit_repo)

add_library(${PROJECT_NAME} INTERFACE)

target_include_directories(${PROJECT_NAME} INTERFACE
${REPO_DIR}/single_header/standalone/
${fakeit_repo_SOURCE_DIR}/single_header/standalone/
)
19 changes: 9 additions & 10 deletions external/unity/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
cmake_minimum_required(VERSION 3.2.2)
cmake_minimum_required(VERSION 3.14)
project(unity VERSION 2.4.1 LANGUAGES C)

include(git-download)
include(FetchContent)

set(REPO_DIR ${PROJECT_SOURCE_DIR}/${PROJECT_NAME}-repo)

download_repo(
URL "https://github.com/ThrowTheSwitch/Unity.git"
TAG v${PROJECT_VERSION}
CLONE_DIR ${REPO_DIR}
FetchContent_Declare(
unity_repo
GIT_REPOSITORY https://github.com/ThrowTheSwitch/Unity.git
GIT_TAG v${PROJECT_VERSION}
)
FetchContent_MakeAvailable(unity_repo)

add_library(${PROJECT_NAME} STATIC
${REPO_DIR}/src/unity.c
${unity_repo_SOURCE_DIR}/src/unity.c
)

target_include_directories(${PROJECT_NAME} PUBLIC
${REPO_DIR}/src
${unity_repo_SOURCE_DIR}/src
)
4 changes: 3 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@

[env:native]
platform = native
build_flags = -std=gnu++17
build_flags =
-std=gnu++17
-Wa,-mbig-obj
test_build_src = yes
9 changes: 6 additions & 3 deletions test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ void setUp(void)
ArduinoFakeReset();
}

void tearDown(void)
{
// Nothing to do here
}

int main(int argc, char **argv)
{
UNITY_BEGIN();
Expand All @@ -46,9 +51,7 @@ int main(int argc, char **argv)
RUN_TEST_GROUP(ClientTest);
RUN_TEST_GROUP(IncludeTest);

UNITY_END();

return 0;
return UNITY_END();
}

#endif
Expand Down
21 changes: 20 additions & 1 deletion test/test_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,28 @@ namespace ArduinoContextTest
ArduinoFakeContext* context = getArduinoFakeContext();
ArduinoFakeInstances* instances = context->Instances;

// Broke pointers for testing purposes
context->Instances->Serial = nullptr;
context->Instances->SPI = nullptr;

TEST_ASSERT_NULL(context->Instances->Serial);
TEST_ASSERT_NULL(context->Instances->SPI);

ArduinoFakeReset();

TEST_ASSERT_NOT_EQUAL(context->Instances, instances);
// After reset, a new instance of ArduinoFakeInstances should be created
// and the previous instance should be deleted.
// The Serial and SPI instances should also be reset to nullptr.
TEST_ASSERT_NOT_NULL(context->Instances);
TEST_ASSERT_NOT_NULL(context->Instances->Serial);
TEST_ASSERT_NOT_NULL(context->Instances->SPI);

// A simple pointer comparison like TEST_ASSERT_NOT_EQUAL(context->Instances, instances);
// is not a reliable way to check if a new instance was created, because
// memory allocators can reuse the same address for new objects after deletion.
// This means a new instance could be created at the same memory location as the old one,
// causing the test to fail even though the instance is actually new.
// To properly verify a new instance, you should check object identity or state, not just pointer values.
}

void test_function_mock(void)
Expand Down
Loading