Allow test modules to be specifed in the rakefile.defaults file
authorJim Morris <morris@wolfman.com>
Sat, 12 Sep 2015 23:28:21 +0000 (16:28 -0700)
committerJim Morris <morris@wolfman.com>
Sat, 12 Sep 2015 23:28:21 +0000 (16:28 -0700)
Update Readme

Rakefile
rakefile.defaults.example [new file with mode: 0644]
src/testframework/Readme.md

index 105e13c..060147d 100644 (file)
--- a/Rakefile
+++ b/Rakefile
@@ -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}"})
diff --git a/rakefile.defaults.example b/rakefile.defaults.example
new file mode 100644 (file)
index 0000000..3026938
--- /dev/null
@@ -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)
index 241d245..defffe5 100644 (file)
@@ -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
 
@@ -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.
+
+