-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compile tests for examples, prepare for unit tests
- Loading branch information
Showing
4 changed files
with
124 additions
and
17 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
; PlatformIO Project Configuration File | ||
; | ||
; Build options: build flags, source filter | ||
; Upload options: custom upload port, speed and extra flags | ||
; Library options: dependencies, extra library storages | ||
; Advanced options: extra scripting | ||
; | ||
; Please visit documentation for the other options and examples | ||
; https://docs.platformio.org/page/projectconf.html | ||
|
||
[env] | ||
lib_deps = thomasfredericks/Bounce2@^2.71 | ||
|
||
[extra] | ||
tytoolspath = C:/toolchain/TyTools | ||
|
||
[teensyBase] | ||
platform = teensy | ||
framework = arduino | ||
|
||
[env:Teensy 41] | ||
extends = teensyBase | ||
board = teensy41 | ||
upload_command = ${extra.tytoolsPath}/tycmd upload --board @usb-1-3-3 $SOURCE | ||
test_port = COM15 | ||
upload_port = COM15 | ||
|
||
[env:Teensy LC] | ||
extends = teensyBase | ||
board = teensylc | ||
upload_command = ${extra.tytoolsPath}/tycmd upload --board @usb-1-3-2 $SOURCE | ||
test_port = COM41 | ||
upload_port = COM41 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
|
||
libraryName = "TeensyTimerTool" | ||
|
||
boards = [ | ||
"teensylc", | ||
"teensy31", | ||
"teensy41", | ||
] | ||
|
||
examples = [ | ||
{"folder":"examples/01_basic/HelloPeriodic"}, | ||
{"folder":"examples/01_basic/HelloOneShot"}, | ||
{"folder":"examples/01_basic/ArrayOfTimers"}, | ||
{"folder":"examples/01_basic/MoreTimers", "exclude":["teensy31","teensylc"]}, | ||
{"folder":"examples/01_basic/RTC_Timer", "exclude":["teensy31","teensylc"]}, | ||
{"folder":"examples/01_basic/UsingChronoDurations1"}, | ||
{"folder":"examples/01_basic/UsingChronoDurations2"}, | ||
{"folder":"examples/02_Advanced/CallbackWithParams"}, | ||
{"folder":"examples/02_Advanced/UsingLambdas"}, | ||
{"folder":"examples/02_Advanced/CapturingLambdas"}, | ||
{"folder":"examples/03_Applications/DoubleExposure", "exclude":["teensylc","teensy41"]}, | ||
{"folder":"examples/99_Misc/PinInformation", "exclude":["teensy31"]}, | ||
] | ||
|
||
dependencies=[ | ||
] | ||
|
||
#************************************************************************************************* | ||
import subprocess | ||
import tempfile | ||
import os | ||
import distutils.dir_util | ||
|
||
print("\n================================ SETTING UP TEST PROJECT ================================") | ||
|
||
targetPrjFolder = os.path.join(tempfile.gettempdir(), libraryName) | ||
targetLibFolder = os.path.join(targetPrjFolder,"lib",libraryName) | ||
targetSrcFolder = os.path.join(targetPrjFolder,"src") | ||
|
||
if os.path.isdir(targetPrjFolder): # start with a fresh setup | ||
distutils.dir_util.remove_tree(targetPrjFolder) | ||
|
||
distutils.dir_util.mkpath(targetPrjFolder) | ||
|
||
initParams = ["pio","project", "init", "-s"] | ||
initParams.append("--project-dir=" + targetPrjFolder) | ||
for board in boards: | ||
initParams.append("--board=" + board) | ||
|
||
opt = "--project-option=lib_deps=" | ||
for dep in dependencies: | ||
opt += (dep + '\n') | ||
initParams.append(opt) | ||
|
||
result = subprocess.run(initParams) | ||
|
||
print("\n================================== COMPILING EXAMPLES ===================================") | ||
|
||
distutils.dir_util.copy_tree("./src",targetLibFolder+"/src") | ||
|
||
totalExamples = str(len(examples)*len(boards)) | ||
currentExample = 1 | ||
|
||
for board in boards: | ||
print('{:57}'.format("SKETCH") + '{:25}'.format("BOARD")+ " STATUS" ) | ||
for example in examples: | ||
exFolder = example['folder'] | ||
counter = (f"{currentExample}/{totalExamples}").center(8) | ||
currentExample += 1 | ||
print("- " + '{:55}'.format(exFolder) + '{:25}'.format(board) + counter, end="\r", flush=True) | ||
|
||
if os.path.isdir(targetSrcFolder): | ||
distutils.dir_util.remove_tree(targetSrcFolder) | ||
distutils.dir_util.copy_tree (exFolder,targetSrcFolder) | ||
|
||
print("- " + '{:55}'.format(exFolder) + '{:25}'.format(board), end='', flush=True) | ||
|
||
if not ("exclude" in example and (board in example['exclude'])): | ||
result = subprocess.run(["pio", "run", "-e"+board, "--project-dir=" + targetPrjFolder],capture_output=True) | ||
|
||
if result.returncode == 0: | ||
print("\033[92m[PASSED]\033[0m"+" ") | ||
else: | ||
print("\033[91m[FAILED]\033[0m"+" ") | ||
else: | ||
print("\033[93m[ N/A ]\033[0m"+" ") | ||
print(' ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import subprocess | ||
|
||
result = subprocess.run(["pio", "test", "-ctest/cfgRunUnitTests.ini"]) |