-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement SystemLogging_WriteMessageUTF8
- Loading branch information
Showing
6 changed files
with
183 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
node_modules/* | ||
node_modules | ||
dist/* | ||
make-it/objs/* | ||
env/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
define(MyVI dv(VirtualInstrument ( | ||
Locals: c( | ||
e(c( | ||
e(.Boolean status) | ||
e(.Int32 code) | ||
e(.String source) | ||
) error) | ||
e(.String ignored1) | ||
e(.String ignored2) | ||
e(.String message) | ||
e(.Int32 severity) | ||
) | ||
clump ( | ||
SystemLogging_WriteMessageUTF8(ignored1 ignored2 message severity error) | ||
) | ||
) ) ) | ||
|
||
enqueue(MyVI) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
describe('Performing a system log', function () { | ||
'use strict'; | ||
// Reference aliases | ||
const vireoHelpers = window.vireoHelpers; | ||
const vireoRunner = window.testHelpers.vireoRunner; | ||
const fixtures = window.testHelpers.fixtures; | ||
let vireo; | ||
|
||
const systemLoggingViaUrl = fixtures.convertToAbsoluteFromFixturesDir('systemlogging/SystemLogging.via'); | ||
|
||
beforeAll(function (done) { | ||
fixtures.preloadAbsoluteUrls([ | ||
systemLoggingViaUrl | ||
], done); | ||
}); | ||
|
||
beforeEach(async function () { | ||
// TODO mraj create shared vireo instances to improve test perf https://github.com/ni/VireoSDK/issues/163 | ||
vireo = await vireoHelpers.createInstance(); | ||
spyOn(console, 'error'); | ||
spyOn(console, 'warn'); | ||
spyOn(console, 'info'); | ||
spyOn(console, 'log'); | ||
}); | ||
|
||
it('with error severity calls console error', async function () { | ||
const runSlicesAsync = vireoRunner.rebootAndLoadVia(vireo, systemLoggingViaUrl); | ||
const viPathParser = vireoRunner.createVIPathParser(vireo, 'MyVI'); | ||
const viPathWriter = vireoRunner.createVIPathWriter(vireo, 'MyVI'); | ||
|
||
viPathWriter('message', 'this should be an error'); | ||
viPathWriter('severity', 0); | ||
const {rawPrint, rawPrintError} = await runSlicesAsync(); | ||
|
||
expect(console.error).toHaveBeenCalledTimes(1); | ||
expect(console.error).toHaveBeenCalledWith('this should be an error'); | ||
expect(console.warn).not.toHaveBeenCalled(); | ||
expect(console.info).not.toHaveBeenCalled(); | ||
expect(console.log).not.toHaveBeenCalled(); | ||
expect(rawPrint).toBeEmptyString(); | ||
expect(rawPrintError).toBeEmptyString(); | ||
expect(viPathParser('error.status')).toBeFalse(); | ||
expect(viPathParser('error.code')).toBe(0); | ||
expect(viPathParser('error.source')).toBeEmptyString(); | ||
}); | ||
|
||
it('with warn severity calls console warn', async function () { | ||
const runSlicesAsync = vireoRunner.rebootAndLoadVia(vireo, systemLoggingViaUrl); | ||
const viPathParser = vireoRunner.createVIPathParser(vireo, 'MyVI'); | ||
const viPathWriter = vireoRunner.createVIPathWriter(vireo, 'MyVI'); | ||
|
||
viPathWriter('message', 'this should be a warning'); | ||
viPathWriter('severity', 1); | ||
const {rawPrint, rawPrintError} = await runSlicesAsync(); | ||
|
||
expect(console.error).not.toHaveBeenCalled(); | ||
expect(console.warn).toHaveBeenCalledTimes(1); | ||
expect(console.warn).toHaveBeenCalledWith('this should be a warning'); | ||
expect(console.info).not.toHaveBeenCalled(); | ||
expect(console.log).not.toHaveBeenCalled(); | ||
expect(rawPrint).toBeEmptyString(); | ||
expect(rawPrintError).toBeEmptyString(); | ||
expect(viPathParser('error.status')).toBeFalse(); | ||
expect(viPathParser('error.code')).toBe(0); | ||
expect(viPathParser('error.source')).toBeEmptyString(); | ||
}); | ||
|
||
it('with info severity calls console info', async function () { | ||
const runSlicesAsync = vireoRunner.rebootAndLoadVia(vireo, systemLoggingViaUrl); | ||
const viPathParser = vireoRunner.createVIPathParser(vireo, 'MyVI'); | ||
const viPathWriter = vireoRunner.createVIPathWriter(vireo, 'MyVI'); | ||
|
||
viPathWriter('message', 'this should be an info'); | ||
viPathWriter('severity', 2); | ||
const {rawPrint, rawPrintError} = await runSlicesAsync(); | ||
|
||
expect(console.error).not.toHaveBeenCalled(); | ||
expect(console.warn).not.toHaveBeenCalled(); | ||
expect(console.info).toHaveBeenCalledTimes(1); | ||
expect(console.info).toHaveBeenCalledWith('this should be an info'); | ||
expect(console.log).not.toHaveBeenCalled(); | ||
expect(rawPrint).toBeEmptyString(); | ||
expect(rawPrintError).toBeEmptyString(); | ||
expect(viPathParser('error.status')).toBeFalse(); | ||
expect(viPathParser('error.code')).toBe(0); | ||
expect(viPathParser('error.source')).toBeEmptyString(); | ||
}); | ||
|
||
it('with invalid severity calls console log', async function () { | ||
const runSlicesAsync = vireoRunner.rebootAndLoadVia(vireo, systemLoggingViaUrl); | ||
const viPathParser = vireoRunner.createVIPathParser(vireo, 'MyVI'); | ||
const viPathWriter = vireoRunner.createVIPathWriter(vireo, 'MyVI'); | ||
|
||
viPathWriter('message', 'this should be a log'); | ||
viPathWriter('severity', 70); | ||
const {rawPrint, rawPrintError} = await runSlicesAsync(); | ||
|
||
expect(console.error).not.toHaveBeenCalled(); | ||
expect(console.warn).not.toHaveBeenCalled(); | ||
expect(console.info).not.toHaveBeenCalled(); | ||
expect(console.log).toHaveBeenCalledTimes(1); | ||
expect(console.log).toHaveBeenCalledWith('this should be a log'); | ||
expect(rawPrint).toBeEmptyString(); | ||
expect(rawPrintError).toBeEmptyString(); | ||
expect(viPathParser('error.status')).toBeFalse(); | ||
expect(viPathParser('error.code')).toBe(0); | ||
expect(viPathParser('error.source')).toBeEmptyString(); | ||
}); | ||
}); |