Skip to content

Commit

Permalink
Add a test for newlyTranslatedDependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherswenson committed Jan 13, 2025
1 parent 7e34e83 commit 382eecb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/malloy/src/lang/parse-malloy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,10 @@ export abstract class MalloyTranslation {
}
const newModels: {url: string; modelDef: ModelDef}[] = [];
for (const [url, child] of this.childTranslators) {
const pretranslated = this.root.pretranslatedModels.get(url);
if (pretranslated !== undefined) {
continue;
}
const result = child.translate();
if (result.modelDef) {
newModels.push({url, modelDef: result.modelDef});
Expand Down
10 changes: 8 additions & 2 deletions packages/malloy/src/lang/test/imports.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,23 @@ source: botProjQSrc is botProjQ
urls: {'internal://test/langtests/grandChild': '// empty file'},
});
expect(docParse).toTranslate();
const sources = docParse.translate().fromSources;
const translated = docParse.translate();
const sources = translated.fromSources;
expect(sources).toEqual([
'internal://test/langtests/root.malloy',
'internal://test/langtests/child',
'internal://test/langtests/grandChild',
]);
expect(docParse.translate().modelDef?.dependencies).toMatchObject({
expect(translated.modelDef?.dependencies).toMatchObject({
'internal://test/langtests/child': {
'internal://test/langtests/grandChild': {},
},
});
const newDependencies = docParse.newlyTranslatedDependencies();
expect(newDependencies).toMatchObject([
{url: 'internal://test/langtests/child', modelDef: {}},
{url: 'internal://test/langtests/grandChild', modelDef: {}},
]);
const child = docParse.translatorForDependency(
'internal://test/langtests/child'
);
Expand Down
2 changes: 2 additions & 0 deletions packages/malloy/src/lang/test/pretranslate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ describe('pretranslated models', () => {
},
},
});
const newDependencies = docParse.newlyTranslatedDependencies();
expect(newDependencies).toMatchObject([]);
expect(translated.fromSources).toEqual([
'internal://test/langtests/root.malloy',
'internal://test/langtests/child',
Expand Down

0 comments on commit 382eecb

Please sign in to comment.