chore(doclint): move doclint tests expectations into test folders (#932)
This makes for much easier work with doclint tests.
This commit is contained in:
parent
f9640a5498
commit
41fd4b529e
@ -85,6 +85,8 @@ function compareText(actual, expectedBuffer) {
|
|||||||
* @return {!{pass: boolean, message: (undefined|string)}}
|
* @return {!{pass: boolean, message: (undefined|string)}}
|
||||||
*/
|
*/
|
||||||
function compare(goldenPath, outputPath, actual, goldenName) {
|
function compare(goldenPath, outputPath, actual, goldenName) {
|
||||||
|
goldenPath = path.normalize(goldenPath);
|
||||||
|
outputPath = path.normalize(outputPath);
|
||||||
const expectedPath = path.join(goldenPath, goldenName);
|
const expectedPath = path.join(goldenPath, goldenName);
|
||||||
const actualPath = path.join(outputPath, goldenName);
|
const actualPath = path.join(outputPath, goldenName);
|
||||||
|
|
||||||
@ -110,9 +112,13 @@ function compare(goldenPath, outputPath, actual, goldenName) {
|
|||||||
if (!result)
|
if (!result)
|
||||||
return { pass: true };
|
return { pass: true };
|
||||||
ensureOutputDir();
|
ensureOutputDir();
|
||||||
fs.writeFileSync(actualPath, actual);
|
if (goldenPath === outputPath) {
|
||||||
// Copy expected to the output/ folder for convenience.
|
fs.writeFileSync(addSuffix(actualPath, '-actual'), actual);
|
||||||
fs.writeFileSync(addSuffix(actualPath, '-expected'), expected);
|
} else {
|
||||||
|
fs.writeFileSync(actualPath, actual);
|
||||||
|
// Copy expected to the output/ folder for convenience.
|
||||||
|
fs.writeFileSync(addSuffix(actualPath, '-expected'), expected);
|
||||||
|
}
|
||||||
if (result.diff) {
|
if (result.diff) {
|
||||||
const diffPath = addSuffix(actualPath, '-diff', result.diffExtension);
|
const diffPath = addSuffix(actualPath, '-diff', result.diffExtension);
|
||||||
fs.writeFileSync(diffPath, result.diff);
|
fs.writeFileSync(diffPath, result.diff);
|
||||||
|
2
utils/doclint/check_public_api/test/.gitignore
vendored
Normal file
2
utils/doclint/check_public_api/test/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
result-actual.txt
|
||||||
|
result-diff.html
|
@ -1,3 +0,0 @@
|
|||||||
[MarkDown] Non-existing class found: Bar
|
|
||||||
[MarkDown] Non-existing class found: Baz
|
|
||||||
[MarkDown] Class not found: Other
|
|
@ -44,10 +44,6 @@ afterAll(SX(async function() {
|
|||||||
await browser.close();
|
await browser.close();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(function() {
|
|
||||||
GoldenUtils.addMatchers(jasmine, GOLDEN_DIR, OUTPUT_DIR);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('checkPublicAPI', function() {
|
describe('checkPublicAPI', function() {
|
||||||
it('01-class-errors', SX(test));
|
it('01-class-errors', SX(test));
|
||||||
it('02-method-errors', SX(test));
|
it('02-method-errors', SX(test));
|
||||||
@ -61,12 +57,13 @@ describe('checkPublicAPI', function() {
|
|||||||
|
|
||||||
async function test() {
|
async function test() {
|
||||||
const dirPath = path.join(__dirname, specName);
|
const dirPath = path.join(__dirname, specName);
|
||||||
|
GoldenUtils.addMatchers(jasmine, dirPath, dirPath);
|
||||||
const factory = new SourceFactory();
|
const factory = new SourceFactory();
|
||||||
const mdSources = await factory.readdir(dirPath, '.md');
|
const mdSources = await factory.readdir(dirPath, '.md');
|
||||||
const jsSources = await factory.readdir(dirPath, '.js');
|
const jsSources = await factory.readdir(dirPath, '.js');
|
||||||
const messages = await checkPublicAPI(page, mdSources, jsSources);
|
const messages = await checkPublicAPI(page, mdSources, jsSources);
|
||||||
const errors = messages.map(message => message.text);
|
const errors = messages.map(message => message.text);
|
||||||
expect(errors.join('\n')).toBeGolden(specName + '.txt');
|
expect(errors.join('\n')).toBeGolden('result.txt');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since Jasmine doesn't like async functions, they should be wrapped
|
// Since Jasmine doesn't like async functions, they should be wrapped
|
||||||
|
Loading…
Reference in New Issue
Block a user