Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
monkbroc committed Jul 12, 2023
1 parent c461180 commit 8e2c6a2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 57 deletions.
24 changes: 16 additions & 8 deletions src/cmd/cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ module.exports = class CloudCommand extends CLICommandBase {
const deviceType = PLATFORMS_ID_TO_NAME[platformId];
const saveTo = temp.path({ suffix: '.zip' }); // compileCodeImpl will pick between .bin and .zip as appropriate

const compiledFilename = await this.compileCodeImpl({ target, followSymlinks, saveTo, deviceType, platformId, files });
const { filename } = await this.compileCodeImpl({ target, followSymlinks, saveTo, deviceType, platformId, files });

fileMapping = { map: { [compiledFilename]: compiledFilename } };
fileMapping = { map: { [filename]: filename } };
}

await this._doFlash({ product, deviceId: device, fileMapping });
Expand Down Expand Up @@ -276,9 +276,9 @@ module.exports = class CloudCommand extends CLICommandBase {

this.ui.stdout.write(`Compiling code for ${deviceType}${os.EOL}`);

const compiledFilename = await this.compileCodeImpl({ target, followSymlinks, saveTo, deviceType, platformId, files });
const { filename, isBundle } = await this.compileCodeImpl({ target, followSymlinks, saveTo, deviceType, platformId, files });

this.ui.stdout.write(`Saved firmware to: ${compiledFilename}${os.EOL}`);
this.ui.stdout.write(`Saved ${isBundle ? 'bundle' : 'firmware' } to: ${filename}${os.EOL}`);
} catch (error) {
const message = 'Compile failed';
throw createAPIErrorResult({ error, message });
Expand Down Expand Up @@ -378,12 +378,14 @@ module.exports = class CloudCommand extends CLICommandBase {
throw normalizedApiError(resp);
}

this.ui.stdout.write(`Compile succeeded.${os.EOL}${os.EOL}`);

let message = 'Compile succeeded.';
if (assets) {
bundle = await new BundleCommands()._generateBundle({ assetsList: assets, appBinary: filename, bundleFilename: bundleFilename });
message = 'Compile succeeded and bundle created.';
}

this.ui.stdout.write(`${message}${os.EOL}${os.EOL}`);

if (respSizeInfo){
this._showMemoryStats(respSizeInfo);
}
Expand All @@ -392,9 +394,15 @@ module.exports = class CloudCommand extends CLICommandBase {
if (await fs.exists(filename)){
await fs.unlink(filename);
}
return path.resolve(bundleFilename);
return {
isBundle: true,
filename: path.resolve(bundleFilename)
};
} else {
return path.resolve(filename);
return {
isBundle: false,
filename: path.resolve(filename)
};
}
}

Expand Down
70 changes: 21 additions & 49 deletions test/e2e/compile.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ describe('Compile Commands', () => {
'',
'Including:',
` ${PATH_PROJ_STROBY_INO}`,
'attempting to compile firmware',
'', // don't assert against binary info since it's always unique: e.g. 'downloading binary from: /v1/binaries/5d38f108bc91fb000130a3f9'
`saving to: ${strobyBinPath}`,
'Memory use:',
'', // don't assert against memory stats since they may change based on current default Device OS version
'Compile succeeded.',
Expand All @@ -102,12 +100,10 @@ describe('Compile Commands', () => {
'',
'Including:',
` ${PATH_PROJ_STROBY_INO}`,
'attempting to compile firmware',
'', // don't assert against binary info since it's always unique: e.g. 'downloading binary from: /v1/binaries/5d38f108bc91fb000130a3f9'
`saving to: ${strobyBinPath}`,
'Memory use:',
' text\t data\t bss\t dec\t hex\tfilename',
' 8604\t 108\t 1136\t 9848\t 2678\t/workspace/target/workspace.elf',
' Flash RAM',
' 8712 1244',
'',
'Compile succeeded.',
`Saved firmware to: ${strobyBinPath}`
Expand All @@ -132,13 +128,11 @@ describe('Compile Commands', () => {
`Compiling code for ${platform}`,
'',
'Including:',
' helper.h',
' app.ino',
' helper.cpp',
' helper.h',
'',
'attempting to compile firmware',
'', // don't assert against memory stats since they may change based on current default Device OS version
`saving to: ${destination}`,
'Memory use:',
'', // don't assert against memory stats since they may change based on current default Device OS version
'Compile succeeded.',
Expand All @@ -164,15 +158,13 @@ describe('Compile Commands', () => {
`Compiling code for ${platform}`,
'',
'Including:',
' lib/helper/src/helper.h',
' src/app.ino',
' lib/helper/src/helper.cpp',
' project.properties',
' lib/helper/src/helper.def',
' lib/helper/src/helper.h',
' project.properties',
' src/app.ino',
'',
'attempting to compile firmware',
'', // don't assert against memory stats since they may change based on current default Device OS version
`saving to: ${destination}`,
'Memory use:',
'', // don't assert against memory stats since they may change based on current default Device OS version
'Compile succeeded.',
Expand All @@ -198,14 +190,12 @@ describe('Compile Commands', () => {
`Compiling code for ${platform}`,
'',
'Including:',
' lib/helper/src/helper.h',
' src/app.ino',
' lib/helper/src/helper.cpp',
' lib/helper/src/helper.h',
' project.properties',
' src/app.ino',
'',
'attempting to compile firmware',
'', // don't assert against memory stats since they may change based on current default Device OS version
`saving to: ${destination}`,
'Memory use:',
'', // don't assert against memory stats since they may change based on current default Device OS version
'Compile succeeded.',
Expand Down Expand Up @@ -235,9 +225,7 @@ describe('Compile Commands', () => {
' helper.cpp',
' helper.h',
'',
'attempting to compile firmware',
'', // don't assert against memory stats since they may change based on current default Device OS version
`saving to: ${destination}`,
'Memory use:',
'', // don't assert against memory stats since they may change based on current default Device OS version
'Compile succeeded.',
Expand Down Expand Up @@ -265,13 +253,11 @@ describe('Compile Commands', () => {
`Compiling code for ${platform}`,
'',
'Including:',
' helper.h',
' app.ino',
' helper.cpp',
' helper.h',
'',
'attempting to compile firmware',
'', // don't assert against memory stats since they may change based on current default Device OS version
`saving to: ${destination}`,
'Memory use:',
'', // don't assert against memory stats since they may change based on current default Device OS version
'Compile succeeded.',
Expand All @@ -298,19 +284,17 @@ describe('Compile Commands', () => {
'',
'Including:',
' project.properties',
' src/helper/h0.h',
' src/helper/h1.hpp',
' src/helper/h3.hh',
' src/helper/h2.hxx',
' src/app.ino',
' src/helper/h0.cpp',
' src/helper/h0.h',
' src/helper/h1.cpp',
' src/helper/h1.hpp',
' src/helper/h2.cpp',
' src/helper/h2.hxx',
' src/helper/h3.cpp',
' src/helper/h3.hh',
'',
'attempting to compile firmware',
'', // don't assert against memory stats since they may change based on current default Device OS version
`saving to: ${destination}`,
'Memory use:',
'', // don't assert against memory stats since they may change based on current default Device OS version
'Compile succeeded.',
Expand All @@ -335,10 +319,10 @@ describe('Compile Commands', () => {
const log = [
`Compiling code for ${platform}`,
'Including:',
' shared/sub_dir/helper.h',
' app.ino',
' shared/sub_dir/helper.cpp',
' project.properties',
' shared/sub_dir/helper.h',
' shared/sub_dir/helper.cpp',
];

expect(file.size).to.be.above(minBinSize);
Expand All @@ -360,13 +344,11 @@ describe('Compile Commands', () => {
`Compiling code for ${platform}`,
'',
'Including:',
' legacy-flat/helper.h',
' legacy-flat/app.ino',
' legacy-flat/helper.cpp',
' legacy-flat/helper.h',
'',
'attempting to compile firmware',
'', // don't assert against memory stats since they may change based on current default Device OS version
`saving to: ${destination}`,
'Memory use:',
'', // don't assert against memory stats since they may change based on current default Device OS version
'Compile succeeded.',
Expand All @@ -392,14 +374,12 @@ describe('Compile Commands', () => {
`Compiling code for ${platform}`,
'',
'Including:',
' src/helper/helper.h',
' src/app.ino',
' src/helper/helper.cpp',
' src/helper/helper.h',
' project.properties',
'',
'attempting to compile firmware',
'', // don't assert against memory stats since they may change based on current default Device OS version
`saving to: ${destination}`,
'Memory use:',
'', // don't assert against memory stats since they may change based on current default Device OS version
'Compile succeeded.',
Expand Down Expand Up @@ -432,9 +412,7 @@ describe('Compile Commands', () => {
' src/test-library-publish.h',
' src/uber-library-example/uber-library-example.h',
'',
'attempting to compile firmware',
'', // don't assert against memory stats since they may change based on current default Device OS version
`saving to: ${destination}`,
'Memory use:',
'', // don't assert against memory stats since they may change based on current default Device OS version
'Compile succeeded.',
Expand All @@ -457,9 +435,7 @@ describe('Compile Commands', () => {
'',
'Including:',
` ${PATH_PROJ_STROBY_INO}`,
'attempting to compile firmware',
'', // don't assert against binary info since it's always unique: e.g. 'downloading binary from: /v1/binaries/5d38f108bc91fb000130a3f9'
`saving to: ${strobyBinPath}`,
'Memory use:',
'', // don't assert against memory stats since they may change based on current default Device OS version
'Compile succeeded.',
Expand All @@ -479,8 +455,8 @@ describe('Compile Commands', () => {
const { stdout, stderr, exitCode } = await cli.run(args, { cwd });
const log = [
'Compile failed: Target device WATNOPE is not valid',
' eg. particle compile core xxx',
' eg. particle compile photon xxx'
' eg. particle compile boron xxx',
' eg. particle compile p2 xxx'
];

expect(stdout.split('\n')).to.include.members(log);
Expand Down Expand Up @@ -513,13 +489,11 @@ describe('Compile Commands', () => {
`Compiling code for ${platform}`,
'',
'Including:',
' helper.h',
' app.ino',
' helper.cpp',
' helper.h',
'',
'attempting to compile firmware',
'', // don't assert against memory stats since they may change based on current default Device OS version
`saving to: ${destination}`,
`Compile failed: ENOENT: no such file or directory, open '${destination}'`
];

Expand Down Expand Up @@ -583,7 +557,6 @@ describe('Compile Commands', () => {
' assets/house.txt',
' assets/water.txt',
'',
'attempting to compile firmware',
'', // don't assert against memory stats since they may change based on current default Device OS version
'Memory use:',
'', // don't assert against memory stats since they may change based on current default Device OS version
Expand Down Expand Up @@ -633,13 +606,12 @@ describe('Compile Commands', () => {
`Compiling code for ${platform}`,
'',
'Including:',
' src/stroby.ino',
' project.properties',
' src/stroby.ino',
' assets/cat.txt',
' assets/house.txt',
' assets/water.txt',
'',
'attempting to compile firmware',
'', // don't assert against memory stats since they may change based on current default Device OS version
'Memory use:',
'', // don't assert against memory stats since they may change based on current default Device OS version
Expand Down

0 comments on commit 8e2c6a2

Please sign in to comment.