Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Action workflow to build and run Unit Tests #160

Merged
merged 7 commits into from
Jan 12, 2025

Conversation

latchdevel
Copy link
Contributor

Hi,

I have added a Github Actions workflow to compile and run the unit tests on the native system (Linux or MacOS).

It is based on Arduino Unit Tests library from Arduino-CI, and EpoxyDuino for native build.

You can see how it works in my repo:

Unit Test workflow

Test project /Users/runner/work/aWOT/aWOT/test/build
      Start  1: buffered-read
 1/13 Test  #1: buffered-read ....................   Passed    0.00 sec
      Start  2: form-params
 2/13 Test  #2: form-params ......................   Passed    0.00 sec
      Start  3: headers-reading
 3/13 Test  #3: headers-reading ..................   Passed    0.00 sec
      Start  4: headers-writing
 4/13 Test  #4: headers-writing ..................   Passed    0.00 sec
      Start  5: http-methods
 5/13 Test  #5: http-methods .....................   Passed    0.00 sec
      Start  6: not-found
 6/13 Test  #6: not-found ........................   Passed    0.00 sec
      Start  7: query-params
 7/13 Test  #7: query-params .....................   Passed    0.00 sec
      Start  8: route-params
 8/13 Test  #8: route-params .....................   Passed    0.00 sec
      Start  9: route-root
 9/13 Test  #9: route-root .......................   Passed    0.00 sec
      Start 10: routing
10/13 Test #10: routing ..........................   Passed    0.00 sec
      Start 11: statuses
11/13 Test #11: statuses .........................   Passed    0.00 sec
      Start 12: stream
12/13 Test #12: stream ...........................   Passed    1.00 sec
      Start 13: timeouts
13/13 Test #13: timeouts .........................   Passed  133.00 sec

100% tests passed, 0 tests failed out of 13

Total Test time (real) = 134.03 sec

I hope it can be useful.

Best regards.

@lasselukkari lasselukkari merged commit 27a2cd7 into lasselukkari:master Jan 12, 2025
@lasselukkari
Copy link
Owner

Would you mind updating the readme about how to run the tests locally. Also if possible it would be nice if all the temporary files could be put one dir that could be ignored from git.

@lasselukkari
Copy link
Owner

Also do you know if it's possible to advance the result of the millis() in tests so that the timeout tests would run faster?

@latchdevel
Copy link
Contributor Author

Would you mind updating the readme about how to run the tests locally. Also if possible it would be nice if all the temporary files could be put one dir that could be ignored from git.

Sure, I'm working on it, I'll do some PRs soon.

Also do you know if it's possible to advance the result of the millis() in tests so that the timeout tests would run faster?

Yes, it is possible to modify millis(), in fact I recently implemented it for a library that required it for testing: Arduino Uptime

But in this case I don't think it is advisable, since the "timeout" test is only slow due to its own operation, and it should be so to be able to check its real operation.

For quick testing, the best option would be to exclude it from execution: ctest -E timeout

root@host:~/aWOT/test/build# ctest -E timeout
Test project /root/aWOT/test/build
      Start  1: buffered-read
 1/12 Test  #1: buffered-read ....................   Passed    0.01 sec
      Start  2: form-params
 2/12 Test  #2: form-params ......................   Passed    0.01 sec
      Start  3: headers-reading
 3/12 Test  #3: headers-reading ..................   Passed    0.01 sec
      Start  4: headers-writing
 4/12 Test  #4: headers-writing ..................   Passed    0.01 sec
      Start  5: http-methods
 5/12 Test  #5: http-methods .....................   Passed    0.02 sec
      Start  6: not-found
 6/12 Test  #6: not-found ........................   Passed    0.01 sec
      Start  7: query-params
 7/12 Test  #7: query-params .....................   Passed    0.01 sec
      Start  8: route-params
 8/12 Test  #8: route-params .....................   Passed    0.01 sec
      Start  9: route-root
 9/12 Test  #9: route-root .......................   Passed    0.01 sec
      Start 10: routing
10/12 Test #10: routing ..........................   Passed    0.01 sec
      Start 11: statuses
11/12 Test #11: statuses .........................   Passed    0.01 sec
      Start 12: stream
12/12 Test #12: stream ...........................   Passed    1.01 sec

100% tests passed, 0 tests failed out of 12

Total Test time (real) =   1.18 sec

@lasselukkari
Copy link
Owner

My initial idea would have been to make the call to millis() run faster. That is what I did before but they are fast enough with this change:
#165

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants