Skip to content

Commit

Permalink
tests for compiler flags
Browse files Browse the repository at this point in the history
  • Loading branch information
mtoy-googly-moogly committed Aug 10, 2023
1 parent 94c82a0 commit 879f7fc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
8 changes: 3 additions & 5 deletions packages/malloy/src/lang/ast/types/annotation-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import {Note} from '../../../model/malloy_types';
import {Tag} from '../../../tags';
import {MessageLogger} from '../../parse-log';
import {Document, DocStatement, MalloyElement} from './malloy-element';
import {QueryPropertyInterface} from './query-property-interface';

Expand All @@ -44,18 +45,15 @@ export class ObjectAnnotation
export class ModelAnnotation extends ObjectAnnotation implements DocStatement {
elementType = 'modelAnnotation';

getCompilerFlags(existing: Tag): Tag {
getCompilerFlags(existing: Tag, logTo: MessageLogger): Tag {
const tagParse = Tag.annotationToTag(
{notes: this.notes},
{
prefix: /^##! /,
extending: existing,
}
);
const logTo = this.logger();
if (logTo) {
tagParse.log.forEach(err => logTo.log(err));
}
tagParse.log.forEach(err => logTo.log(err));
return tagParse.tag;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/malloy/src/lang/malloy-to-ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1714,7 +1714,7 @@ export class MalloyToAST
};
});
const tags = new ast.ModelAnnotation(allNotes);
this.compilerFlags = tags.getCompilerFlags(this.compilerFlags);
this.compilerFlags = tags.getCompilerFlags(this.compilerFlags, this.msgLog);
return tags;
}

Expand Down
14 changes: 13 additions & 1 deletion packages/malloy/src/lang/test/annotation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

import {TestTranslator, getFieldDef} from './test-translator';
import {TestTranslator, getFieldDef, model} from './test-translator';
import './parse-expects';
import {diff} from 'jest-diff';
import {Annotation} from '../../model/malloy_types';
Expand Down Expand Up @@ -265,6 +265,18 @@ describe('document annotation', () => {
'Object annotation not connected to any object'
);
});
test('errors reported from compiler flags', () => {
expect(`
##! missingCloseQuote="...
`).translationToFailWith(/no viable alternative at input/);
});
test('checking compiler flags', () => {
const m = model`
##! flagThis
`;
expect(m).toTranslate();
expect(m.translator.compilerFlags.has('flagThis')).toBeTruthy();
});
});
describe('source definition annotations', () => {
test('turtle block annotation', () => {
Expand Down

0 comments on commit 879f7fc

Please sign in to comment.