Merge pull request #40 from OmarTawfik/fix-guid

Support parsing GUID ids from rawLogParser
This commit is contained in:
Pine 2019-03-14 08:26:25 -07:00 коммит произвёл GitHub
Родитель 853901033b 01a4bb2c8e
Коммит 9edb21a2db
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 97 добавлений и 20 удалений

Просмотреть файл

@ -83,10 +83,10 @@ function extractMsg(msg: string) {
const reSendNotification = /Sending notification '(.*)'/
const reRecvNotification = /Received notification '(.*)'/
const reSendRequest = /Sending request '(.*) - \((\d+)\)'/
const reRecvRequest = /Received request '(.*) - \((\d+)\)'/
const reSendResponse = /Sending response '(.*) - \((\d+)\)'.*took (\d+ms)/
const reRecvResponse = /Received response '(.*) - \((\d+)\)' in (\d+ms)/
const reSendRequest = /Sending request '(.*) - \(([0-9a-zA-Z-]+)\)'/
const reRecvRequest = /Received request '(.*) - \(([0-9a-zA-Z-]+)\)'/
const reSendResponse = /Sending response '(.*) - \(([0-9a-zA-Z-]+)\)'.*took (\d+ms)/
const reRecvResponse = /Received response '(.*) - \(([0-9a-zA-Z-]+)\)' in (\d+ms)/
let msgType, msgId, msgLatency
/* tslint:disable */

Просмотреть файл

@ -0,0 +1,48 @@
[
{
"time": "15:31:35",
"msg": "Received request 'window/showStatus - (90261e77-782b-4ac1-bd52-6abfA0f65A15)'.",
"msgId": "90261e77-782b-4ac1-bd52-6abfA0f65A15",
"msgKind": "recv-request",
"msgType": "window/showStatus",
"arg": {
"value": "Loading project...",
"enable": true
}
},
{
"time": "15:31:35",
"msg": "Sending response 'window/showStatus - (90261e77-782b-4ac1-bd52-6abfA0f65A15)' took 25ms",
"msgId": "90261e77-782b-4ac1-bd52-6abfA0f65A15",
"msgKind": "send-response",
"msgLatency": "25ms",
"msgType": "window/showStatus",
"arg": {
"value": "",
"enable": true
}
},
{
"time": "15:31:35",
"msg": "Sending request 'window/showStatus - (90261e77-782b-4ac1-bd52-6abfA0f65A15)'.",
"msgId": "90261e77-782b-4ac1-bd52-6abfA0f65A15",
"msgKind": "send-request",
"msgType": "window/showStatus",
"arg": {
"value": "Loading project...",
"enable": true
}
},
{
"time": "15:31:35",
"msg": "Received response 'window/showStatus - (90261e77-782b-4ac1-bd52-6abfA0f65A15)' in 25ms",
"msgId": "90261e77-782b-4ac1-bd52-6abfA0f65A15",
"msgKind": "recv-response",
"msgLatency": "25ms",
"msgType": "window/showStatus",
"arg": {
"value": "",
"enable": true
}
}
]

Просмотреть файл

@ -0,0 +1,28 @@
[Trace - 15:31:35] Received request 'window/showStatus - (90261e77-782b-4ac1-bd52-6abfA0f65A15)'.
Params: {
"value": "Loading project...",
"enable": true
}
[Trace - 15:31:35] Sending response 'window/showStatus - (90261e77-782b-4ac1-bd52-6abfA0f65A15)' took 25ms
Params: {
"value": "",
"enable": true
}
[Trace - 15:31:35] Sending request 'window/showStatus - (90261e77-782b-4ac1-bd52-6abfA0f65A15)'.
Params: {
"value": "Loading project...",
"enable": true
}
[Trace - 15:31:35] Received response 'window/showStatus - (90261e77-782b-4ac1-bd52-6abfA0f65A15)' in 25ms
Params: {
"value": "",
"enable": true
}

Просмотреть файл

@ -2,24 +2,25 @@ import * as fs from 'fs-extra'
import * as path from 'path'
import { parseLSPLog } from '@/logParser/rawLogParser'
describe('HelloWorld', () => {
it('parses raw log fine', async () => {
await testFixture('helloworld')
await testFixture('html')
await testFixture('10-tslint-dirty-trace')
await testFixture('11-crlf')
})
describe('Raw Log Parser Tests', () => {
testFixture('helloworld')
testFixture('html')
testFixture('10-tslint-dirty-trace')
testFixture('11-crlf')
testFixture('ids-with-guids')
})
async function testFixture(fixtureName: string) {
const log = await fs.readFile(path.resolve(__dirname, `fixture/${fixtureName}.log`), 'utf-8')
const expectedJson = await fs.readFile(
path.resolve(__dirname, `fixture/${fixtureName}.json`),
'utf-8'
)
const expected = JSON.parse(expectedJson)
function testFixture(fixtureName: string) {
it(`parses ${fixtureName} logs correctly`, async () => {
const log = await fs.readFile(path.resolve(__dirname, `fixture/${fixtureName}.log`), 'utf-8')
const expectedJson = await fs.readFile(
path.resolve(__dirname, `fixture/${fixtureName}.json`),
'utf-8'
)
const expected = JSON.parse(expectedJson)
const actual = parseLSPLog(log)
const actual = parseLSPLog(log)
expect(actual).toEqual(expected)
expect(actual).toEqual(expected)
})
}