Skip to content

Commit

Permalink
t2 run/push: provide firmware node.js version to pre-compiled module …
Browse files Browse the repository at this point in the history
…resolution. Fixes gh-843

Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed Sep 12, 2016
1 parent 945eebb commit 1c7fbe2
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/tessel/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ exportables.sendBundle = function(tessel, opts) {
return exportables.findProject(opts).then((project) => {
opts.target = path.resolve(process.cwd(), project.pushdir);
opts.resolvedEntryPoint = project.entryPoint;
opts.tessel = tessel;

return opts.lang.preBundle(opts).then(() => {
return opts.lang.tarBundle(opts).then((bundle) => {
Expand Down
5 changes: 4 additions & 1 deletion lib/tessel/deployment/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,10 @@ exportables.injectBinaryModules = function(globRoot, tempBundlePath, options) {
};

exportables.preBundle = function(options) {
return exportables.resolveBinaryModules(options);
return options.tessel.fetchCurrentNodeVersion().then(version => {
options.version = version;
return exportables.resolveBinaryModules(options);
});
};

exportables.tarBundle = function(options) {
Expand Down
1 change: 1 addition & 0 deletions test/unit/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ exports['Tessel.prototype.deploy'] = {

this.tessel = TesselSimulator();
this.end = sandbox.spy(this.tessel._rps.stdin, 'end');
this.fetchCurrentNodeVersion = sandbox.stub(this.tessel, 'fetchCurrentNodeVersion').returns(Promise.resolve('v4.4.3'));

this.pWrite = sandbox.stub(Preferences, 'write').returns(Promise.resolve());

Expand Down
58 changes: 58 additions & 0 deletions test/unit/deployment/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ exports['Deployment: JavaScript'] = {

this.tessel = TesselSimulator();
this.end = sandbox.spy(this.tessel._rps.stdin, 'end');
this.fetchCurrentNodeVersion = sandbox.stub(this.tessel, 'fetchCurrentNodeVersion').returns(Promise.resolve('v4.4.3'));

this.pWrite = sandbox.stub(Preferences, 'write').returns(Promise.resolve());

Expand Down Expand Up @@ -1800,6 +1801,7 @@ exports['deploy.findProject'] = {
exports['deploy.sendBundle, error handling'] = {
setUp: function(done) {
this.tessel = TesselSimulator();
this.fetchCurrentNodeVersion = sandbox.stub(this.tessel, 'fetchCurrentNodeVersion').returns(Promise.resolve('v4.4.3'));
this.pathResolve = sandbox.stub(path, 'resolve');
this.failure = 'FAIL';
done();
Expand Down Expand Up @@ -1863,6 +1865,62 @@ exports['deploy.sendBundle, error handling'] = {
},
};


exports['deployment.js.preBundle'] = {
setUp: function(done) {
this.tessel = TesselSimulator();

this.info = sandbox.stub(log, 'info');
this.exec = sandbox.stub(this.tessel.connection, 'exec', (command, callback) => {
callback(null, this.tessel._rps);
});

this.receive = sandbox.stub(this.tessel, 'receive', (rps, callback) => {
rps.emit('close');
callback();
});

this.fetchCurrentNodeVersion = sandbox.stub(this.tessel, 'fetchCurrentNodeVersion').returns(Promise.resolve('v4.4.3'));
this.findProject = sandbox.stub(deploy, 'findProject').returns(Promise.resolve({
pushdir: '',
entryPoint: ''
}));
this.resolveBinaryModules = sandbox.stub(deployment.js, 'resolveBinaryModules').returns(Promise.resolve());
this.tarBundle = sandbox.stub(deployment.js, 'tarBundle').returns(Promise.resolve(new Buffer([0x00])));
this.pathResolve = sandbox.stub(path, 'resolve');


this.preBundle = sandbox.spy(deployment.js, 'preBundle');
done();
},

tearDown: function(done) {
this.tessel.mockClose();
sandbox.restore();
done();
},

preBundleReceivesTessel: function(test) {
test.expect(4);

deploy.sendBundle(this.tessel, {
target: '/',
entryPoint: 'foo.js',
lang: deployment.js
}).then(() => {

test.equal(this.fetchCurrentNodeVersion.callCount, 1);
test.equal(this.resolveBinaryModules.callCount, 1);
test.equal(this.preBundle.callCount, 1);

var preBundleArgs = this.preBundle.lastCall.args[0];

test.equal(preBundleArgs.tessel, this.tessel);
test.done();
});
},
};

exports['deployment.js.resolveBinaryModules'] = {
setUp: function(done) {

Expand Down

0 comments on commit 1c7fbe2

Please sign in to comment.