Skip to content

Commit

Permalink
Make code compression optional, default to —compress=true. Fixes tess…
Browse files Browse the repository at this point in the history
…elgh-776

- `t2 run <index.js> --compress=false` will skip the code compression step

Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed Jul 18, 2016
1 parent bfdeadf commit a6bfe29
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
5 changes: 5 additions & 0 deletions bin/tessel-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ makeCommand('run')
default: false,
help: 'Deploy a project containing all files within, including those not used by the program, excluding any files matched by non-negated rules in .tesselignore and including any files matched by rules in .tesselinclude. Program is started from specified file.'
})
.option('compress', {
flag: true,
default: true,
help: 'Compression steps during deployment. To skip compression, use --compress=false.'
})
.option('rustcc', {
default: 'http://192.241.138.79:49160',
help: 'Specify the location and port of the Rust cross-compilation server.'
Expand Down
2 changes: 1 addition & 1 deletion lib/tessel/deployment/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ exportables.tarBundle = function(options) {
return;
}

if (isJS) {
if (options.compress && isJS) {
try {
source = exportables.compress(source, compressionOptions);
} catch (error) {
Expand Down
54 changes: 52 additions & 2 deletions test/unit/deployment/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ exports['Deployment: JavaScript'] = {
// Actually deploy the script
this.tessel.deploy({
entryPoint: path.relative(process.cwd(), DEPLOY_FILE_JS),
compress: true,
push: false,
single: false
})
Expand Down Expand Up @@ -542,6 +543,7 @@ exports['deployment.js.tarBundle'] = {

deployment.js.tarBundle({
target: path.normalize(target),
compress: true,
full: true,
}).then(bundle => {

Expand Down Expand Up @@ -612,6 +614,7 @@ exports['deployment.js.tarBundle'] = {
deployment.js.tarBundle({
target: path.normalize(target),
resolvedEntryPoint: entryPoint,
compress: true,
slim: true,
}).then(bundle => {
// These things happen in the --slim path
Expand Down Expand Up @@ -670,6 +673,7 @@ exports['deployment.js.tarBundle'] = {
deployment.js.tarBundle({
target: path.normalize(target),
resolvedEntryPoint: entryPoint,
compress: true,
slim: true,
}).then(bundle => {
extract(bundle, (error, entries) => {
Expand All @@ -690,6 +694,34 @@ exports['deployment.js.tarBundle'] = {
});
},

compressionIsSkipped: function(test) {
test.expect(1);

var entryPoint = 'index.js';
var target = 'test/unit/fixtures/syntax-error';

deployment.js.tarBundle({
target: path.normalize(target),
resolvedEntryPoint: entryPoint,
compress: false,
slim: true,
}).then(bundle => {
extract(bundle, (error, entries) => {
if (error) {
test.ok(false, error.toString());
test.done();
}

// compression mechanism is never called when --compress=false
test.equal(this.compress.callCount, 0);
test.done();
});
}).catch(() => {
test.ok(false, 'Compression should not produce errors');
test.done();
});
},

slimTesselInit: function(test) {
test.expect(5);

Expand All @@ -707,6 +739,7 @@ exports['deployment.js.tarBundle'] = {
deployment.js.tarBundle({
target: path.normalize(target),
resolvedEntryPoint: entryPoint,
compress: true,
slim: true,
}).then(bundle => {
test.equal(this.project.callCount, 1);
Expand Down Expand Up @@ -739,6 +772,7 @@ exports['deployment.js.tarBundle'] = {
deployment.js.tarBundle({
target: path.normalize(target),
entryPoint: entryPoint,
compress: true,
resolvedEntryPoint: entryPoint,
single: true,
slim: true,
Expand Down Expand Up @@ -768,6 +802,7 @@ exports['deployment.js.tarBundle'] = {
deployment.js.tarBundle({
target: path.normalize(target),
entryPoint: entryPoint,
compress: true,
resolvedEntryPoint: path.join('nested', entryPoint),
single: true,
slim: true,
Expand Down Expand Up @@ -798,6 +833,7 @@ exports['deployment.js.tarBundle'] = {
deployment.js.tarBundle({
target: path.normalize(target),
entryPoint: entryPoint,
compress: true,
resolvedEntryPoint: entryPoint,
single: true,
full: true,
Expand Down Expand Up @@ -826,6 +862,7 @@ exports['deployment.js.tarBundle'] = {
deployment.js.tarBundle({
target: path.normalize(target),
entryPoint: entryPoint,
compress: true,
resolvedEntryPoint: path.join('nested', entryPoint),
single: true,
full: true,
Expand Down Expand Up @@ -872,6 +909,7 @@ exports['deployment.js.tarBundle'] = {
deployment.js.tarBundle({
target: path.normalize(target),
resolvedEntryPoint: entryPoint,
compress: true,
slim: true,
}).then(bundle => {
test.equal(this.globSync.callCount, 8 + listRuleLength);
Expand Down Expand Up @@ -954,6 +992,7 @@ exports['deployment.js.tarBundle'] = {

deployment.js.tarBundle({
target: path.normalize(target),
compress: true,
full: true,
}).then(bundle => {
test.equal(this.globSync.callCount, 8 + listRuleLength);
Expand Down Expand Up @@ -1032,6 +1071,7 @@ exports['deployment.js.tarBundle'] = {
deployment.js.tarBundle({
target: path.normalize(target),
resolvedEntryPoint: entryPoint,
compress: true,
slim: true,
}).then(bundle => {
test.equal(this.globSync.callCount, 5 + listRuleLength);
Expand Down Expand Up @@ -1118,6 +1158,7 @@ exports['deployment.js.tarBundle'] = {

deployment.js.tarBundle({
target: path.normalize(target),
compress: true,
full: true,
}).then(bundle => {
test.equal(this.globSync.callCount, 5 + listRuleLength);
Expand Down Expand Up @@ -1205,6 +1246,7 @@ exports['deployment.js.tarBundle'] = {
deployment.js.tarBundle({
target: path.normalize(target),
resolvedEntryPoint: entryPoint,
compress: true,
slim: true,
}).then(bundle => {
test.equal(this.globSync.callCount, 6 + listRuleLength);
Expand Down Expand Up @@ -1289,6 +1331,7 @@ exports['deployment.js.tarBundle'] = {

deployment.js.tarBundle({
target: path.normalize(target),
compress: true,
full: true,
}).then(bundle => {
test.equal(this.globSync.callCount, 6 + listRuleLength);
Expand Down Expand Up @@ -1381,6 +1424,7 @@ exports['deployment.js.tarBundle'] = {
deployment.js.tarBundle({
target: path.normalize(target),
resolvedEntryPoint: entryPoint,
compress: true,
slim: true,
single: true,
}).then(bundle => {
Expand Down Expand Up @@ -1435,6 +1479,7 @@ exports['deployment.js.tarBundle'] = {
deployment.js.tarBundle({
target: path.normalize(target),
resolvedEntryPoint: entryPoint,
compress: true,
slim: true,
}).then(() => {

Expand Down Expand Up @@ -1472,6 +1517,7 @@ exports['deployment.js.tarBundle'] = {
deployment.js.tarBundle({
target: path.normalize(target),
resolvedEntryPoint: entryPoint,
compress: true,
slim: true,
}).then(() => {
test.equal(this.readdirSync.callCount, 1);
Expand All @@ -1493,6 +1539,7 @@ exports['deployment.js.tarBundle'] = {
deployment.js.tarBundle({
target: path.normalize(target),
resolvedEntryPoint: entryPoint,
compress: true,
slim: true,
}).then(() => {
test.deepEqual(this.project.lastCall.args[0], {
Expand Down Expand Up @@ -1525,6 +1572,7 @@ exports['deployment.js.tarBundle'] = {
deployment.js.tarBundle({
target: path.normalize(target),
resolvedEntryPoint: entryPoint,
compress: true,
slim: true,
}).then((bundle) => {
// Extract and inspect the bundle...
Expand Down Expand Up @@ -1583,7 +1631,8 @@ exports['deploy.findProject'] = {

deploy.findProject({
lang: deployment.js,
entryPoint: '~/foo/'
entryPoint: '~/foo/',
compress: true,
});
},

Expand All @@ -1593,7 +1642,8 @@ exports['deploy.findProject'] = {

deploy.findProject({
lang: deployment.js,
entryPoint: target
entryPoint: target,
compress: true,
}).then(project => {
test.deepEqual(project, {
pushdir: fixtures.project,
Expand Down

0 comments on commit a6bfe29

Please sign in to comment.