Finish tests

This commit is contained in:
marcnjaramillo
2021-11-17 15:59:12 -08:00
parent a666619289
commit ca5e5e23e6
4 changed files with 42 additions and 5 deletions

View File

@@ -589,7 +589,7 @@ export class CodeQLCliServer implements Disposable {
const pipeline = chain([
fs.createReadStream(interpretedResultsPath),
p,
pick({filter: 'runs.0.results'}),
pick({filter: 'runs.0.results'})
]);
// Creates JavaScript objects from the token stream
@@ -597,8 +597,11 @@ export class CodeQLCliServer implements Disposable {
// Returns a constructed Log object with the results or an empty array if no results were found.
// If the parser fails for any reason, it will reject the promise.
return await new Promise((resolve) => {
return await new Promise((resolve, reject) => {
pipeline.on('error', (error) => {
reject(error);
});
asm.on('done', (asm) => {
const log : sarif.Log = {

View File

@@ -6,7 +6,9 @@ import { CodeQLCliServer } from '../../cli';
chai.use(chaiAsPromised);
const expect = chai.expect;
describe.only('cliServerTests', () => {
describe.only('cliServerTests', function() {
this.timeout(10000);
it('should parse a valid SARIF file', async () => {
const result = await CodeQLCliServer.parseSarif(__dirname + '/data/sarif/validSarif.sarif');
expect(result.runs.length).to.eq(1);

View File

@@ -29,7 +29,6 @@
}
],
"results": []
]
}
]
}

View File

@@ -0,0 +1,33 @@
{
"version": "2.1.0",
"$schema": "http://json.schemastore.org/sarif-2.1.0-rtm.4",
"runs": [
{
"tool": {
"driver": {
"name": "ESLint",
"informationUri": "https://eslint.org",
"rules": [
{
"id": "no-unused-vars",
"shortDescription": {
"text": "disallow unused variables"
},
"helpUri": "https://eslint.org/docs/rules/no-unused-vars",
"properties": {
"category": "Variables"
}
}
]
}
},
"artifacts": [
{
"location": {
"uri": "file:///C:/dev/sarif/sarif-tutorials/samples/Introduction/simple-example.js"
}
}
]
}
]
}