Skip to content

Commit cf7e909

Browse files
authored
refactor build configuration (production & test) (#128)
- resolves #108 - resolves #83
2 parents 3d35ee2 + 39a5245 commit cf7e909

File tree

4 files changed

+27
-87
lines changed

4 files changed

+27
-87
lines changed

.github/workflows/platformio.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,5 @@ jobs:
2727
run: platformio pkg install
2828
- name: Build default environment
2929
run: platformio run --verbose
30-
- name: On native platform run tests for 'tasks'
31-
run: platformio test --verbose --environment test_native_tasks
32-
- name: On native platform run tests for 'command line interpreter'
33-
run: platformio test --verbose --environment test_native_cli
34-
- name: On native platform run tests for 'string_helpers'
35-
run: platformio test --verbose --environment test_native_string_helpers
36-
- name: Run tests on the native platform for HMI layer
37-
run: platformio test --verbose --environment test_native_hmi
30+
- name: On native platform run tests
31+
run: platformio test --verbose --environment native

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ In case the serial interface input is not read by PlatformIO serial monitor one
120120

121121
This is especially useful when simulating the microcontroller or device.
122122

123+
### Unit testing
124+
125+
The project is setup for running unit tests:
126+
127+
platformio test --verbose --environment native
128+
123129
## Contribute
124130

125131
Please refer to [`CONTRIBUTING.md`](CONTRIBUTING.md).

lib/3rd_party_adapters/Arduino/serial_port.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ std::basic_ostream<CharType> &cout = std::cout;
1414

1515
void initialize()
1616
{
17-
Serial.begin(115200);
17+
Serial.begin(BAUD_RATE);
1818
delay(100);
1919
Serial.flush();
2020
delay(100);

platformio.ini

Lines changed: 18 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,47 @@
1-
; PlatformIO Project Configuration File
2-
;
3-
; Please visit documentation for the other options and examples
4-
; https://docs.platformio.org/page/projectconf.html
5-
6-
;-------------------------------------------------------
7-
; global PIO parameters |
8-
;-------------------------------------------------------
91
[platformio]
10-
;default build enfironment for PIO project
112
default_envs = esp32-s3-devkitc-1
123

13-
;Path to source files relative to PIO project
14-
; see https://docs.platformio.org/en/stable/projectconf/sections/platformio/options/directory/src_dir.html
15-
src_dir = src
16-
17-
;switch "include" path to be src as well, as we decide to have headers and sources in same directories
18-
; this prevents the build environment from complaining the path not existing
19-
include_dir = src
20-
21-
;-------------------------------------------------------
22-
; common parameters for all environments [env:...] |
23-
;-------------------------------------------------------
244
[env]
25-
;filter for source file directory when building
26-
; see https://docs.platformio.org/en/stable/projectconf/sections/env/options/build/build_src_filter.html
27-
build_src_filter = +<*> -<.git/> -<.svn/>
5+
build_flags =
6+
-std=gnu++17 ; necessary for using modern STL
7+
-Werror=return-type ; consider missing return information as fatal error
8+
-Werror=overflow
9+
build_unflags = -std=gnu++11 ; necessary to be able to specify a different language standard
2810

29-
;general dependencies
30-
; for version requirements see https://docs.platformio.org/en/stable/core/userguide/pkg/cmd_install.html#cmd-pkg-install-requirements
11+
[production]
12+
extends = env
3113
lib_deps =
3214
adafruit/Adafruit SSD1306@~2.5.3
3315
lvgl@^8.3
3416
johboh/nlohmann-json@^3.11.3
35-
; adding local library as dependency is necessary as it does not have any include files. This is because nothing should depend from this layer.
3617
3rd_party_adapters ; this is necessary as no source code dependency shall exist to that packet
3718
lib_ldf_mode = deep ; to automatically detect nested dependencies (for external libraries)
3819
build_flags =
20+
${env.build_flags}
3921
-DLV_CONF_PATH="${PROJECT_DIR}/lib/3rd_party_adapters/LVGL/lv_conf.h" ; lvgl: use this config file
40-
-std=gnu++17 ; necessary for using modern STL
41-
-Werror=return-type ; consider missing return information as fatal error
42-
build_unflags = -std=gnu++11 ; necessary to be able to specify a different language standard
22+
-DBAUD_RATE=${this.monitor_speed}
4323
monitor_speed = 115200
44-
monitor_filters = esp32_exception_decoder
45-
build_type = debug
4624

47-
; Template section for tests to be run on native platform.
48-
[test_native]
49-
build_type = debug
25+
[env:native]
5026
platform = native
5127
lib_deps =
5228
unity
53-
ArduinoFake
29+
ArduinoFake@^0.4.0
5430
enterprise_business_rules
55-
lib_ldf_mode = chain ; automatically detect dependencies but to not recurse into other components
31+
utilities
32+
lib_ldf_mode = chain ; to simplify mocking, do not use deep mode
5633
build_flags =
34+
${env.build_flags}
5735
-Wno-deprecated ; Workaround for https://github.com/FabioBatSilva/ArduinoFake/pull/41#issuecomment-1440550553
58-
-Werror=overflow
59-
-D unitTesting
6036
-lgcov
6137
--coverage
6238
-fprofile-abs-path
63-
-std=gnu++17 ; necessary for using modern STL
64-
-O0 -ggdb3
65-
build_unflags = -std=gnu++11
39+
-O0
40+
-ggdb3
6641

67-
;-------------------------------------------------------
68-
; ESP32 build environment |
69-
;-------------------------------------------------------
7042
[env:esp32-s3-devkitc-1]
7143
platform = espressif32
7244
board = esp32-s3-devkitc-1
7345
framework = arduino
74-
;;add dependencies to general dependencies from [env]
75-
; lib_deps =
76-
; ${env.lib_deps}
77-
78-
; We have individual test enviroments, as this allows us to define different
79-
; include paths (lib_deps) per test.
80-
; And this in turn allwos us to mock different parts of the software for each test.
81-
[env:test_native_tasks]
82-
extends = test_native
83-
test_filter = test_tasks
84-
lib_deps =
85-
${test_native.lib_deps}
86-
utilities
87-
88-
[env:test_native_cli]
89-
extends = test_native
90-
test_filter = test_cli
91-
debug_test = test_cli
92-
lib_deps =
93-
${test_native.lib_deps}
94-
95-
[env:test_native_string_helpers]
96-
extends = test_native
97-
test_filter = test_string_helpers
98-
debug_test = test_string_helpers
99-
100-
[env:test_native_hmi]
101-
extends = test_native
102-
test_filter = hmi/*
103-
lib_deps =
104-
${test_native.lib_deps}
105-
application_business_rules
106-
board_adapters
107-
utilities
46+
extends = production
47+
monitor_filters = esp32_exception_decoder

0 commit comments

Comments
 (0)