-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from bvandercar-vt/output-file-compact-logs-c…
…onfig add outputCompactLogs option to allow for overriding compactLogs for output file specifically
- Loading branch information
Showing
9 changed files
with
134 additions
and
8 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,12 @@ | ||
/// <reference types="cypress" /> | ||
|
||
describe('Output compact logs', ()=>{ | ||
// create logs to check that using outputCompactLogs overrides compactLogs for output file | ||
it('Output compact logs', ()=>{ | ||
for (let i = 0; i <20 ; i++) { | ||
expect(1).to.equal(1) | ||
} | ||
|
||
expect(1).to.equal(0) | ||
}) | ||
}) |
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,62 @@ | ||
import { runTest, commandBase, logLastRun, clean } from "../utils"; | ||
|
||
const {expect} = require('chai'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
function getOutputFileContents() { | ||
const outputFile = path.join(__dirname, '../output/out.txt'); | ||
expect(fs.existsSync(outputFile), `Expected output file ${outputFile} to exist.`).to.be.true; | ||
const valueBuffer = fs.readFileSync(outputFile); | ||
return clean(valueBuffer.toString()); | ||
} | ||
|
||
describe('Output compact logs.', () => { | ||
|
||
afterEach(function () { | ||
if (this.currentTest.state == 'failed') { | ||
logLastRun(); | ||
} | ||
}); | ||
|
||
it('Should compact logs to length specified by compactLogs and outputCompactLogs - compactLogs=1, outputCompactLogs=5', async () => { | ||
await runTest(commandBase(['outputCompactLogs=1'], ['outputCompactLogs.spec.js']), (error, stdout, stderr) => { | ||
// failure occurs on 21st log, compactLogs=1, outputCompactLogs=5 | ||
|
||
// test terminal is correct | ||
expect(stdout, 'compactLogs compacts terminal logs to correct val (1)' ).to.contain( `[ ... 19 omitted logs ... ]`); | ||
expect(stdout, 'compactLogs does not compact terminal to outputCompactLogs val (5)' ).to.not.contain(`[ ... 15 omitted logs ... ]`); | ||
|
||
// test output log is correct | ||
const fileContents = getOutputFileContents(); | ||
expect(fileContents, 'outputCompactLogs compacts output file logs to correct val (5)').to.contain( `[ ... 15 omitted logs ... ]` ); | ||
expect(fileContents, 'outputCompactLogs does not compact output file logs to compactLogs val (1)').to.not.contain(`[ ... 19 omitted logs ... ]`); | ||
}); | ||
}).timeout(60000); | ||
|
||
it('Should compact logs to length specified by compactLogs and outputCompactLogs - compactLogs=unspecified, outputCompactLogs=5', async () => { | ||
await runTest(commandBase(['outputCompactLogs=2'], ['outputCompactLogs.spec.js']), (error, stdout, stderr) => { | ||
// failure occurs on 21st log, compactLogs=unspecified (default), outputCompactLogs=5 | ||
|
||
// test terminal is correct | ||
expect(stdout, 'not specifying compactLogs results in uncompacted terminal output even if outputCompactLogs>=0 specified' ).to.not.contain(`omitted logs`); | ||
|
||
// test output log is correct | ||
const fileContents = getOutputFileContents(); | ||
expect(fileContents, 'outputCompactLogs>=0 compacts terminal even if compactLogs not specified' ).to.contain(`[ ... 15 omitted logs ... ]`); | ||
}); | ||
}).timeout(60000); | ||
|
||
it('Should compact logs to length specified by compactLogs and outputCompactLogs - compactLogs=5, outputCompactLogs=-1', async () => { | ||
await runTest(commandBase(['outputCompactLogs=3'], ['outputCompactLogs.spec.js']), (error, stdout, stderr) => { | ||
// failure occurs on 21st log, compactLogs=5, outputCompactLogs=-1 | ||
|
||
// test terminal is correct | ||
expect(stdout, 'compactLogs compacts terminal logs to correct val (5)').to.contain( `[ ... 15 omitted logs ... ]`); | ||
|
||
// test output log is correct | ||
const fileContents = getOutputFileContents(); | ||
expect(fileContents, 'outputCompactLogs=-1 causes terminal to not compact even if compactLogs specified' ).to.not.contain(`omitted logs`); | ||
}); | ||
}).timeout(60000); | ||
}); |