Skip to content

Commit

Permalink
fix(rosetta): extract ignores --compile option (#3193)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rix0rrr authored Nov 21, 2021
1 parent bd77abe commit 639c510
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/jsii-rosetta/lib/commands/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export async function extractSnippets(
}

const translatorOptions: RosettaTranslatorOptions = {
includeCompilerDiagnostics: options.includeCompilerDiagnostics,
assemblies: assemblies.map((a) => a.assembly),
};

Expand Down
14 changes: 14 additions & 0 deletions packages/jsii-rosetta/test/commands/extract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 639c510

Please sign in to comment.