From 639c510ba6d07b26bf35d0c8d3c9cdcced6d916a Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Sun, 21 Nov 2021 15:34:45 +0100 Subject: [PATCH] fix(rosetta): `extract` ignores `--compile` option (#3193) In a recent refactor we failed to pass on the setting of the `--compile` flag, leading to non-exhaustive compilation checks and also resulting in a disclaimer being added to all translated snippets. --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0 --- packages/jsii-rosetta/lib/commands/extract.ts | 1 + .../jsii-rosetta/test/commands/extract.test.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/packages/jsii-rosetta/lib/commands/extract.ts b/packages/jsii-rosetta/lib/commands/extract.ts index 57234b9361..e2a4f90b1a 100644 --- a/packages/jsii-rosetta/lib/commands/extract.ts +++ b/packages/jsii-rosetta/lib/commands/extract.ts @@ -47,6 +47,7 @@ export async function extractSnippets( } const translatorOptions: RosettaTranslatorOptions = { + includeCompilerDiagnostics: options.includeCompilerDiagnostics, assemblies: assemblies.map((a) => a.assembly), }; diff --git a/packages/jsii-rosetta/test/commands/extract.test.ts b/packages/jsii-rosetta/test/commands/extract.test.ts index 3de081d7ed..dc8eb3cc14 100644 --- a/packages/jsii-rosetta/test/commands/extract.test.ts +++ b/packages/jsii-rosetta/test/commands/extract.test.ts @@ -96,6 +96,20 @@ describe('with cache file', () => { (TARGET_LANGUAGES.java as any).version = oldJavaVersion; } }); + + test('compiler diagnostics property is passed on', async () => { + const translationFunction = jest.fn().mockResolvedValue({ diagnostics: [], translatedSnippets: [] }); + + await extract.extractSnippets([assembly.moduleDirectory], { + outputFile: path.join(assembly.moduleDirectory, 'dummy.tabl.json'), + validateAssemblies: false, + includeCompilerDiagnostics: true, + translatorFactory: (o) => { + expect(o.includeCompilerDiagnostics).toEqual(true); + return new MockTranslator(o, translationFunction); + }, + }); + }); }); test('do not ignore example strings', async () => {