Skip to content

Commit

Permalink
Merge branch 'feature/add_tests' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
pschillinger committed Nov 10, 2018
2 parents 945d5de + a1adf55 commit cfa1b74
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 252 deletions.
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
sudo: required
dist: trusty
language: generic

before_install:
- git clone https://github.com/FlexBE/flexbe_ci.git ~/flexbe_ci
- source ~/flexbe_ci/setup.bash
- ~/flexbe_ci/ci_scripts/before_install.bash

install:
- ~/flexbe_ci/ci_scripts/install.bash

before_script:
- ~/flexbe_ci/ci_scripts/before_script.bash

script:
- ~/flexbe_ci/ci_scripts/script.bash
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,9 @@ install(DIRECTORY
launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

# run tests
if(CATKIN_ENABLE_TESTING)
find_package(rostest REQUIRED)
add_rostest(launch/test_report.test)
endif()
20 changes: 20 additions & 0 deletions bin/test_report
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python
import yaml
import unittest

class TestReport(unittest.TestCase):

def test_report(self):
try:
with open("/tmp/flexbe_app_report.log", 'r') as f:
report = yaml.load(f)
except IOError:
return # skip test since there is no report to evaluate
for test_type, tests in report.items():
for test_name, test_data in tests.items():
if test_type == "assertTrue":
self.assertTrue(test_data, test_name)

if __name__ == '__main__':
import rosunit
rosunit.unitrun("flexbe_app", "test_report", TestReport)
7 changes: 7 additions & 0 deletions launch/test_report.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>

<launch>

<test test-name="flexbe_app" name="flexbe_app" pkg="flexbe_app" type="test_report" />

</launch>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "FlexBE App",
"version": "2.0.8",
"version": "2.0.9",
"main": "src/main.js",
"window": {
"icon": "src/img/icon-128.png",
Expand Down
4 changes: 3 additions & 1 deletion package.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<package>
<name>flexbe_app</name>
<version>2.0.8</version>
<version>2.0.9</version>
<description>
flexbe_app provides a user interface (editor + runtime control) for the FlexBE behavior engine.
</description>
Expand All @@ -17,4 +17,6 @@
<run_depend>actionlib</run_depend>
<run_depend>rospack</run_depend>

<test_depend>rosunit</test_depend>

</package>
File renamed without changes.
11 changes: 11 additions & 0 deletions src/_test/statelib.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
StatelibTest = new (function() {
var that = this;

this.testWaitStateAvailable = function(report, done) {
// flexbe_states/WaitState is found and properly imported
var result = WS.Statelib.getClassList().contains("WaitState");
report.assertTrue.test_statelib = result;
done();
}

})();
21 changes: 21 additions & 0 deletions src/_test/testreport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
TestReport = new (function() {
var that = this;

var report = {'assertTrue': {}};

this.runAllTests = function(callback) {
var testCases = [
StatelibTest.testWaitStateAvailable
];
var done = function(code) {
if (testCases.length == 0) {
IO.Filesystem.createFile('/tmp', "flexbe_app_report.log", JSON.stringify(report), callback);
} else {
var test = testCases.shift();
test(report, done);
}
}
done();
}

})();
248 changes: 0 additions & 248 deletions src/_testing/test.js

This file was deleted.

5 changes: 3 additions & 2 deletions src/window.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@
<script src="ws/ws_statemachinedefinition.js"></script>
<script src="ws/ws_statelib.js"></script>

<script src="_testing/scripts.js"></script>
<script src="_testing/test.js"></script>
<script src="_test/scripts.js"></script>
<script src="_test/testreport.js"></script>
<script src="_test/statelib.test.js"></script>

<link rel="stylesheet" href="style/main.css" type="text/css" />
<link rel="stylesheet" href="style/dashboard.css" type="text/css" />
Expand Down
6 changes: 6 additions & 0 deletions src/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ window.onload = function() {
UI.Settings.restoreSettings();

UI.Feed.initialize();

if (gui.App.argv.contains('--run-tests')) {
setTimeout(() => {
TestReport.runAllTests(status => gui.App.quit());
}, 5 * 1000);
}
}

0 comments on commit cfa1b74

Please sign in to comment.