Skip to content

Commit

Permalink
add python warning to report
Browse files Browse the repository at this point in the history
  • Loading branch information
dmca-glasgow committed May 16, 2022
1 parent fc79b84 commit ba914f0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
7 changes: 6 additions & 1 deletion compiler/src/knitr/__test__/knitr.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Literal } from 'hast';

import { reportHasWarnings } from '../../linter/report';
import {
ignoreWhitespace,
testProcessor,
Expand Down Expand Up @@ -349,7 +350,7 @@ describe('knitr', () => {
}, 120000);

it('should remove python warnings from the top of knitr output', async () => {
const { md } = await testProcessor(`
const { md, messages } = await testProcessor(`
WARNING - All triples will be processed in the same batch (batches_count=1).
When processing large graphs it is recommended to batch the input knowledge
graph instead.
Expand All @@ -362,5 +363,9 @@ describe('knitr', () => {
`);

expect(md.trim().startsWith('WARNING')).toBe(false);

expect(messages[0].startsWith('All triples will be processed')).toBe(
true
);
});
});
14 changes: 13 additions & 1 deletion compiler/src/knitr/knitr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,20 @@ function getKnitrFileDir() {
}

function reportErrors(response: string, file: VFile) {
response.split('\n').forEach((line, idx) => {
response.split(EOL).forEach((line, idx) => {
const trimmed = line.trim();
if (trimmed.startsWith('WARNING -')) {
warnMessage(file, trimmed.replace('WARNING - ', ''), {
start: {
line: idx + 1,
column: 0,
},
end: {
line: idx + 1,
column: line.length,
},
});
}
if (trimmed.startsWith('## Error')) {
warnMessage(file, trimmed.replace('## ', ''), {
start: {
Expand Down

0 comments on commit ba914f0

Please sign in to comment.