Skip to content

Commit

Permalink
Run examples in Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
gyeates committed Sep 29, 2014
1 parent 2b3adc9 commit e49d840
Show file tree
Hide file tree
Showing 19 changed files with 395 additions and 85 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.vagrant
doc
node_modules
*.out
*.log
21 changes: 20 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
language: node_js
node_js:
- "0.10"
addons:
firefox: "31.0" # 3.4->31.0
os:
- linux
before_install:
# node-canvas dependency
- sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
# ROS deps for examples
- sudo sh -c 'echo "deb http://packages.ros.org/ros-shadow-fixed/ubuntu precise main" > /etc/apt/sources.list.d/ros-latest.list'
- wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
- sudo apt-get update -qq
- sudo apt-get install ros-hydro-ros-base
- sudo apt-get install ros-hydro-rosbridge-server ros-hydro-tf2-web-republisher ros-hydro-common-tutorials ros-hydro-rospy-tutorials ros-hydro-actionlib-tutorials
- npm install -g grunt-cli karma-cli

# Set up Xfvb for Firefox headless testing
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
before_script:
- npm install -g grunt-cli
- source /opt/ros/hydro/setup.bash
- sh test/examples/setup_examples.sh
script:
- npm test
- npm run test-examples
17 changes: 10 additions & 7 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ module.exports = function(grunt) {
build: {
configFile: './test/karma.conf.js',
singleRun: true,
browsers: ['PhantomJS']
browsers: ['Firefox']
}
},
mochaTest: {
options: {
reporter: 'spec',
timeout: 5000
},
test: {
options: {
reporter: 'spec'
},
src: ['test/**/*.test.js']
src: ['test/*.test.js']
},
examples: {
src: ['test/examples/*.js']
}
},
uglify: {
Expand Down Expand Up @@ -95,9 +99,8 @@ module.exports = function(grunt) {


grunt.registerTask('dev', ['browserify', 'watch']);
grunt.registerTask('test', ['jshint', 'mochaTest', 'browserify', 'karma']);
grunt.registerTask('test', ['jshint', 'mochaTest:test', 'browserify', 'karma']);
grunt.registerTask('build', ['test', 'uglify']);
grunt.registerTask('build_and_watch', ['watch']);
grunt.registerTask('doc', ['clean', 'jsdoc']);
};

91 changes: 39 additions & 52 deletions build/roslib.js
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,8 @@ function Topic(options) {
this.queue_size = options.queue_size || 100;

// Check for valid compression types
if (this.compression && this.compression !== 'png' && this.compression !== 'none') {
if (this.compression && this.compression !== 'png' &&
this.compression !== 'none') {
this.emit('warning', this.compression +
' compression is not supported. No compression will be used.');
}
Expand All @@ -1138,44 +1139,34 @@ Topic.prototype.__proto__ = EventEmitter2.prototype;
*/
Topic.prototype.subscribe = function(callback) {
var that = this;

this.on('message', function(message) {
callback(message);
});

this.on('message', callback);
this.ros.on(this.name, function(data) {
var message = new Message(data);
that.emit('message', message);
});

this.ros.idCounter++;
var subscribeId = 'subscribe:' + this.name + ':' + this.ros.idCounter;
var call = {
op : 'subscribe',
id : subscribeId,
type : this.messageType,
topic : this.name,
compression : this.compression,
throttle_rate : this.throttle_rate
};

this.ros.callOnConnection(call);
this.subscribeId = 'subscribe:' + this.name + ':' + (++this.ros.idCounter);
this.ros.callOnConnection({
op: 'subscribe',
id: this.subscribeId,
type: this.messageType,
topic: this.name,
compression: this.compression,
throttle_rate: this.throttle_rate
});
};

/**
* Unregisters as a subscriber for the topic. Unsubscribing will remove
* all subscribe callbacks.
*/
Topic.prototype.unsubscribe = function() {
this.ros.removeAllListeners([ this.name ]);
this.ros.idCounter++;
var unsubscribeId = 'unsubscribe:' + this.name + ':' + this.ros.idCounter;
var call = {
op : 'unsubscribe',
id : unsubscribeId,
topic : this.name
};
this.ros.callOnConnection(call);
this.ros.removeAllListeners([this.name]);
this.ros.callOnConnection({
op: 'unsubscribe',
id: this.subscribeId,
topic: this.name
});
};

/**
Expand All @@ -1185,17 +1176,15 @@ Topic.prototype.advertise = function() {
if (this.isAdvertised) {
return;
}
this.ros.idCounter++;
this.advertiseId = 'advertise:' + this.name + ':' + this.ros.idCounter;
var call = {
op : 'advertise',
id : this.advertiseId,
type : this.messageType,
topic : this.name,
latch : this.latch,
queue_size : this.queue_size
};
this.ros.callOnConnection(call);
this.advertiseId = 'advertise:' + this.name + ':' + (++this.ros.idCounter);
this.ros.callOnConnection({
op: 'advertise',
id: this.advertiseId,
type: this.messageType,
topic: this.name,
latch: this.latch,
queue_size: this.queue_size
});
this.isAdvertised = true;
};

Expand All @@ -1206,13 +1195,11 @@ Topic.prototype.unadvertise = function() {
if (!this.isAdvertised) {
return;
}
var unadvertiseId = this.advertiseId;
var call = {
op : 'unadvertise',
id : unadvertiseId,
topic : this.name
};
this.ros.callOnConnection(call);
this.ros.callOnConnection({
op: 'unadvertise',
id: this.advertiseId,
topic: this.name
});
this.isAdvertised = false;
};

Expand All @@ -1223,22 +1210,22 @@ Topic.prototype.unadvertise = function() {
*/
Topic.prototype.publish = function(message) {
if (!this.isAdvertised) {
this.advertise();
this.advertise();
}

this.ros.idCounter++;
var publishId = 'publish:' + this.name + ':' + this.ros.idCounter;
var call = {
op : 'publish',
id : publishId,
topic : this.name,
msg : message,
latch : this.latch
op: 'publish',
id: 'publish:' + this.name + ':' + this.ros.idCounter,
topic: this.name,
msg: message,
latch: this.latch
};
this.ros.callOnConnection(call);
};

module.exports = Topic;

},{"./Message":7,"eventemitter2":30}],14:[function(require,module,exports){
/**
* @author David Gossow - dgossow@willowgarage.com
Expand Down
4 changes: 2 additions & 2 deletions examples/fibonacci.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<html>
<head>
<meta charset="utf-8" />
<script src="\\cdn.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>
<script src="\\cdn.robotwebtools.org/roslibjs/current/roslib.js"></script>
<script src="http://cdn.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>
<script src="../build/roslib.js"></script>

<script>
// Connecting to ROS
Expand Down
6 changes: 3 additions & 3 deletions examples/fibonacci_server.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<script src="http://cdn.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>
<script src="http://cdn.robotwebtools.org/roslibjs/current/roslib.js"></script>
<script src="../build/roslib.js"></script>

<script>
// Connecting to ROS
Expand Down Expand Up @@ -41,14 +41,14 @@

if (that.canceled === true ) {
console.log("Action server preempted");

that.fibonacciServer.setPreempted();
}
console.log(fibonacciSequence);
//send feedback
var feedback = { sequence: fibonacciSequence };
that.fibonacciServer.sendFeedback(fibonacciSequence);
}
}

//send result
var result = { sequence: fibonacciSequence};
Expand Down
2 changes: 1 addition & 1 deletion examples/math.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<script src="http://cdn.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>
<script src="http://cdn.robotwebtools.org/roslibjs/current/roslib.js"></script>
<script src="../build/roslib.js"></script>

<script>
// Let's start by adding some vectors.
Expand Down
8 changes: 4 additions & 4 deletions examples/simple.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<script src="http://cdn.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>
<script src="http://cdn.robotwebtools.org/roslibjs/current/roslib.js"></script>
<script src="../build/roslib.js"></script>

<script>
// Connecting to ROS
Expand Down Expand Up @@ -48,7 +48,7 @@
messageType : 'geometry_msgs/Twist'
});

// Then we create the payload to be published. The object we pass in to ros.Message matches the
// Then we create the payload to be published. The object we pass in to ros.Message matches the
// fields defined in the geometry_msgs/Twist.msg definition.
var twist = new ROSLIB.Message({
linear : {
Expand All @@ -69,7 +69,7 @@
//Subscribing to a Topic
//----------------------

// Like when publishing a topic, we first create a Topic object with details of the topic's name
// Like when publishing a topic, we first create a Topic object with details of the topic's name
// and message type. Note that we can call publish or subscribe on the same topic object.
var listener = new ROSLIB.Topic({
ros : ros,
Expand All @@ -95,7 +95,7 @@
serviceType : 'rospy_tutorials/AddTwoInts'
});

// Then we create a Service Request. The object we pass in to ROSLIB.ServiceRequest matches the
// Then we create a Service Request. The object we pass in to ROSLIB.ServiceRequest matches the
// fields defined in the rospy_tutorials AddTwoInts.srv file.
var request = new ROSLIB.ServiceRequest({
a : 1,
Expand Down
2 changes: 1 addition & 1 deletion examples/tf.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<script src="http://cdn.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>
<script src="http://cdn.robotwebtools.org/roslibjs/current/roslib.js"></script>
<script src="../build/roslib.js"></script>

<script>
// Connecting to ROS
Expand Down
12 changes: 6 additions & 6 deletions examples/urdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<head>
<meta charset="utf-8" />
<script src="http://cdn.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>
<script src="http://cdn.robotwebtools.org/roslibjs/current/roslib.js"></script>
<script src="../build/roslib.js"></script>

<script>
/**
* Setup all visualization elements when the page is loaded.
* Setup all visualization elements when the page is loaded.
*/
function init() {
// Connect to ROS.
Expand All @@ -20,13 +20,13 @@
ros : ros,
name : 'robot_description'
});

param.get(function(param) {
// Setup the loader for the URDF.
var urdfModel = new ROSLIB.UrdfModel({
string : param
});

console.log(urdfModel);
});
// If there is an error on the backend, an 'error' emit will be emitted.
Expand All @@ -37,7 +37,7 @@
document.getElementById('error').style.display = 'inline';
console.log(error);
});

// Find out exactly when we made a connection.
ros.on('connection', function() {
console.log('Connection made!');
Expand All @@ -46,7 +46,7 @@
document.getElementById('closed').style.display = 'none';
document.getElementById('connected').style.display = 'inline';
});

ros.on('close', function() {
console.log('Connection closed.');
document.getElementById('connecting').style.display = 'none';
Expand Down
27 changes: 27 additions & 0 deletions npm-debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'test-examples' ]
2 info using npm@1.4.28
3 info using node@v0.10.32
4 verbose node symlink /usr/bin/node
5 verbose run-script [ 'pretest-examples', 'test-examples', 'posttest-examples' ]
6 info pretest-examples roslibjs@0.9.0
7 info test-examples roslibjs@0.9.0
8 verbose unsafe-perm in lifecycle true
9 info roslibjs@0.9.0 Failed to exec test-examples script
10 error roslibjs@0.9.0 test-examples: `grunt mochaTest:examples`
10 error Exit status 3
11 error Failed at the roslibjs@0.9.0 test-examples script.
11 error This is most likely a problem with the roslibjs package,
11 error not with npm itself.
11 error Tell the author that this fails on your system:
11 error grunt mochaTest:examples
11 error You can get their info via:
11 error npm owner ls roslibjs
11 error There is likely additional logging output above.
12 error System Linux 3.13.0-34-generic
13 error command "/usr/bin/node" "/usr/bin/npm" "run" "test-examples"
14 error cwd /home/graeme/Dropbox/clearpath/roslibjs
15 error node -v v0.10.32
16 error npm -v 1.4.28
17 error code ELIFECYCLE
18 verbose exit [ 1, true ]
Loading

0 comments on commit e49d840

Please sign in to comment.