Skip to content

Commit

Permalink
Allow test modules to be specifed in the rakefile.defaults file
Browse files Browse the repository at this point in the history
Update Readme
  • Loading branch information
wolfmanjm committed Sep 13, 2015
1 parent 8329667 commit 80bbeba
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ end

if TESTING
# add modules to be tested here
TESTMODULES= %w(tools/temperatureswitch)
TESTMODULES= %w(tools/temperatureswitch) unless defined? EXCLUDE_MODULES
puts "Modules under test: #{TESTMODULES}"
excludes << %w(Kernel.cpp main.cpp) # we replace these with mock versions in testframework
testmodules= FileList['src/testframework/*.{c,cpp}', 'src/testframework/easyunit/*.{c,cpp}', 'src/modules/communication/SerialConsole.cpp', 'src/modules/communication/utils/Gcode.cpp'].include(TESTMODULES.collect { |e| "src/modules/#{e}/**/*.{c,cpp}"}).include(TESTMODULES.collect { |e| "src/testframework/unittests/#{e}/*.{c,cpp}"})
Expand Down
8 changes: 8 additions & 0 deletions rakefile.defaults.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# if regular build the modules to exclude from the build
NONETWORK = true
EXCLUDE_MODULES = %w(tools/touchprobe tools/laser tools/temperaturecontrol tools/extruder)

# if test framework build the modules to include in the test...
# here we enable unit tests for tools/temperatureswitch module and any unit tests in /src/testframework/unittests/tools/temperatureswitch/
# and any unittests in the src/testframework/unittests/libs folder
TESTMODULES= %w(tools/temperatureswitch libs)
19 changes: 18 additions & 1 deletion src/testframework/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This is a frame work for writing unit tests for modules or libs.
It compiles only src/libs/... and a few select needed modules by default.
It runs on the target and the output is written to the serial UART, it runs well with MRI so you can also debug with GDB.

You can edit the Rakefile to specify which module you are going to test the example has tools/temperaturecontrol selected.
You can edit a file to specify which module you are going to test by default the example has tools/temperaturecontrol selected.

The unit tests go in a directory named src/testframework/unittests/*XXXX*/*YYYY* where *XXXX* is the module subdirectory (tools,utils) and *YYYY* is the modulename

Expand Down Expand Up @@ -35,6 +35,23 @@ You compile a unit test and framework using [rake](http://rake.rubyforge.org/)..

The unit test will run, the results are printed to the serial uart port, and then it is left in DFU mode so `rake upload` can be run again for the next test.

You select which tests and modules you want to compile by creating a file called rakefile.defaults in the same directory as the Rakefile is found.

```shell
TESTMODULES= %w(tools/temperatureswitch libs)
```

Here we enable unit tests for the tools/temperatureswitch module and any unit tests in src/testframework/unittests/tools/temperatureswitch/.
Also any unittests in the src/testframework/unittests/libs folder will be included

In this case all files in src/libs/... are compiled anyway so we only need to enable unit tests in the src/testframework/unittests/libs folder.

the tools/temperatureswitch both compiles all files in the src/modules/tools/temperatureswitch/... directory and enables the
unit tests in src/testframework/unittests/tools/temperatureswitch/...

by default no other files in the src/modules/... directory tree are compiled unless specified above.





0 comments on commit 80bbeba

Please sign in to comment.