fix missing newlines in compiler error

This commit is contained in:
David Lechner
2021-01-21 12:37:29 -06:00
parent 647985906d
commit 904de515c0
9 changed files with 22 additions and 12 deletions
-1
View File
@@ -111,7 +111,6 @@ SOFTWARE.`;
const licenseTextOverrides = {
'@pybricks/firmware': pybricksLicense,
'@pybricks/mpy-cross-v5': pybricksLicense,
'@shopify/dates': shopifyLicense,
'@shopify/decorators': shopifyLicense,
'@shopify/function-enhancers': shopifyLicense,
+1 -1
View File
@@ -11,7 +11,7 @@
"@blueprintjs/core": "^3.36.0",
"@craco/craco": "^6.0.0",
"@pybricks/firmware": "4.4.0",
"@pybricks/mpy-cross-v5": "^1.2.0",
"@pybricks/mpy-cross-v5": "^2.0.0",
"@shopify/react-i18n": "^5.2.0",
"@testing-library/dom": "^7.29.2",
"@testing-library/jest-dom": "^5.11.8",
+2 -2
View File
@@ -32,10 +32,10 @@ export function didCompile(data: Uint8Array): MpyDidCompileAction {
export type MpyDidFailToCompileAction = Action<MpyActionType.DidFailToCompile> & {
/** Error output. */
readonly err: string;
readonly err: string[];
};
export function didFailToCompile(err: string): MpyDidFailToCompileAction {
export function didFailToCompile(err: string[]): MpyDidFailToCompileAction {
return { type: MpyActionType.DidFailToCompile, err };
}
+9
View File
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`compiler error works 1`] = `
Array [
"Traceback (most recent call last):",
" File \\"main.py\\", line 1",
"SyntaxError: invalid syntax",
]
`;
+1 -1
View File
@@ -146,7 +146,7 @@ function* loadFirmware(
])) as [MpyDidCompileAction, MpyDidFailToCompileAction];
if (mpyFail) {
throw Error(mpyFail.err);
throw Error(mpyFail.err.join('\n'));
}
// compute offset for checksum - must be aligned to 4-byte boundary
+1 -1
View File
@@ -37,7 +37,7 @@ test('compiler error works', async () => {
const action = await saga.take();
expect(action.type).toBe(MpyActionType.DidFailToCompile);
const { err } = action as MpyDidFailToCompileAction;
expect(err).toContain('SyntaxError');
expect(err).toMatchSnapshot();
await saga.end();
});
+1 -1
View File
@@ -31,7 +31,7 @@ test.each([
bootloaderDidFailToConnect(BootloaderConnectionFailureReason.NoWebBluetooth),
bootloaderDidFailToConnect(BootloaderConnectionFailureReason.GattServiceNotFound),
storageChanged('test'),
didFailToCompile('reason'),
didFailToCompile(['reason']),
add('warning', 'message'),
add('error', 'message', 'url'),
didUpdate({} as ServiceWorkerRegistration),
+3 -1
View File
@@ -220,7 +220,9 @@ function* dismissCompilerError(): Generator {
}
function* showCompilerError(action: MpyDidFailToCompileAction): Generator {
yield* showSingleton(Level.Error, MessageId.MpyError, { errorMessage: action.err });
yield* showSingleton(Level.Error, MessageId.MpyError, {
errorMessage: React.createElement('pre', undefined, action.err.join('\n')),
});
}
function* addNotification(action: NotificationAddAction): Generator {
+4 -4
View File
@@ -1462,10 +1462,10 @@
dependencies:
jszip "^3.5.0"
"@pybricks/mpy-cross-v5@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@pybricks/mpy-cross-v5/-/mpy-cross-v5-1.2.0.tgz#29cbd949c579c0551792d2fd1cd777d193aa925c"
integrity sha512-A1FXGP0teuZa3tPBTz9niCdEol4Ld6jOABl9FkglmutGWO99eLwuyYibh8wQqHNKwXRHrzCJmo/W+/42HmSjog==
"@pybricks/mpy-cross-v5@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@pybricks/mpy-cross-v5/-/mpy-cross-v5-2.0.0.tgz#9d64e1dedda0a7a028117f510ce5365f504df400"
integrity sha512-s3B+0tsXRHF3Y+FfOeDkNLoM+dwwT8P05UowVYPQvTV/UjhBGwruUdEoG/cYz2cFrqx+VFF8gpgmpw+5aA7/hQ==
"@redux-saga/core@^1.1.3":
version "1.1.3"