test(docs-infra): run tests in random order (and make them pass) (#31527)
This commit updates the necessary config files to run the angular.io and docs tooling unit tests in random order (and fixes the tests that were failing due to their dependence on the previous ordered execution). Besides being a good idea anyway, running tests in random order is the new [default behavior in jasmine@3.0.0][1], so this commit is in preparation of upgrading jasmine to the latest version. [1]: https://github.com/jasmine/jasmine/blob/v3.0.0/release_notes/3.0.md#breaking-changes PR Close #31527
This commit is contained in:

committed by
Miško Hevery

parent
e8ae3c5f2e
commit
d7ca263cc4
@ -7,113 +7,113 @@ const DEFAULT_PLASTER = '. . .';
|
||||
const {mapObject} = require('../../helpers/utils');
|
||||
|
||||
module.exports = function regionParser() {
|
||||
regionParserImpl.regionMatchers = {
|
||||
ts: inlineC,
|
||||
js: inlineC,
|
||||
es6: inlineC,
|
||||
dart: inlineC,
|
||||
html: html,
|
||||
svg: html,
|
||||
css: blockC,
|
||||
yaml: inlineHash,
|
||||
yml: inlineHash,
|
||||
jade: inlineCOnly,
|
||||
pug: inlineCOnly,
|
||||
json: inlineC,
|
||||
'json.annotated': inlineC
|
||||
};
|
||||
|
||||
return regionParserImpl;
|
||||
};
|
||||
|
||||
regionParserImpl.regionMatchers = {
|
||||
ts: inlineC,
|
||||
js: inlineC,
|
||||
es6: inlineC,
|
||||
dart: inlineC,
|
||||
html: html,
|
||||
svg: html,
|
||||
css: blockC,
|
||||
yaml: inlineHash,
|
||||
yml: inlineHash,
|
||||
jade: inlineCOnly,
|
||||
pug: inlineCOnly,
|
||||
json: inlineC,
|
||||
'json.annotated': inlineC
|
||||
};
|
||||
/**
|
||||
* @param contents string
|
||||
* @param fileType string
|
||||
* @returns {contents: string, regions: {[regionName: string]: string}}
|
||||
*/
|
||||
function regionParserImpl(contents, fileType) {
|
||||
const regionMatcher = regionParserImpl.regionMatchers[fileType];
|
||||
const openRegions = [];
|
||||
const regionMap = {};
|
||||
|
||||
/**
|
||||
* @param contents string
|
||||
* @param fileType string
|
||||
* @returns {contents: string, regions: {[regionName: string]: string}}
|
||||
*/
|
||||
function regionParserImpl(contents, fileType) {
|
||||
const regionMatcher = regionParserImpl.regionMatchers[fileType];
|
||||
const openRegions = [];
|
||||
const regionMap = {};
|
||||
if (regionMatcher) {
|
||||
let plaster = regionMatcher.createPlasterComment(DEFAULT_PLASTER);
|
||||
const lines = contents.split(/\r?\n/).filter((line, index) => {
|
||||
const startRegion = line.match(regionMatcher.regionStartMatcher);
|
||||
const endRegion = line.match(regionMatcher.regionEndMatcher);
|
||||
const updatePlaster = line.match(regionMatcher.plasterMatcher);
|
||||
|
||||
if (regionMatcher) {
|
||||
let plaster = regionMatcher.createPlasterComment(DEFAULT_PLASTER);
|
||||
const lines = contents.split(/\r?\n/).filter((line, index) => {
|
||||
const startRegion = line.match(regionMatcher.regionStartMatcher);
|
||||
const endRegion = line.match(regionMatcher.regionEndMatcher);
|
||||
const updatePlaster = line.match(regionMatcher.plasterMatcher);
|
||||
// start region processing
|
||||
if (startRegion) {
|
||||
// open up the specified region
|
||||
const regionNames = getRegionNames(startRegion[1]);
|
||||
if (regionNames.length === 0) {
|
||||
regionNames.push('');
|
||||
}
|
||||
regionNames.forEach(regionName => {
|
||||
const region = regionMap[regionName];
|
||||
if (region) {
|
||||
if (region.open) {
|
||||
throw new RegionParserError(
|
||||
`Tried to open a region, named "${regionName}", that is already open`, index);
|
||||
}
|
||||
region.open = true;
|
||||
if (plaster) {
|
||||
region.lines.push(plaster);
|
||||
}
|
||||
} else {
|
||||
regionMap[regionName] = {lines: [], open: true};
|
||||
}
|
||||
openRegions.push(regionName);
|
||||
});
|
||||
|
||||
// start region processing
|
||||
if (startRegion) {
|
||||
// open up the specified region
|
||||
const regionNames = getRegionNames(startRegion[1]);
|
||||
if (regionNames.length === 0) {
|
||||
regionNames.push('');
|
||||
}
|
||||
regionNames.forEach(regionName => {
|
||||
const region = regionMap[regionName];
|
||||
if (region) {
|
||||
if (region.open) {
|
||||
// end region processing
|
||||
} else if (endRegion) {
|
||||
if (openRegions.length === 0) {
|
||||
throw new RegionParserError('Tried to close a region when none are open', index);
|
||||
}
|
||||
// close down the specified region (or most recent if no name is given)
|
||||
const regionNames = getRegionNames(endRegion[1]);
|
||||
if (regionNames.length === 0) {
|
||||
regionNames.push(openRegions[openRegions.length - 1]);
|
||||
}
|
||||
|
||||
regionNames.forEach(regionName => {
|
||||
const region = regionMap[regionName];
|
||||
if (!region || !region.open) {
|
||||
throw new RegionParserError(
|
||||
`Tried to open a region, named "${regionName}", that is already open`, index);
|
||||
`Tried to close a region, named "${regionName}", that is not open`, index);
|
||||
}
|
||||
region.open = true;
|
||||
if (plaster) {
|
||||
region.lines.push(plaster);
|
||||
}
|
||||
} else {
|
||||
regionMap[regionName] = {lines: [], open: true};
|
||||
}
|
||||
openRegions.push(regionName);
|
||||
});
|
||||
region.open = false;
|
||||
removeLast(openRegions, regionName);
|
||||
});
|
||||
|
||||
// end region processing
|
||||
} else if (endRegion) {
|
||||
if (openRegions.length === 0) {
|
||||
throw new RegionParserError('Tried to close a region when none are open', index);
|
||||
}
|
||||
// close down the specified region (or most recent if no name is given)
|
||||
const regionNames = getRegionNames(endRegion[1]);
|
||||
if (regionNames.length === 0) {
|
||||
regionNames.push(openRegions[openRegions.length - 1]);
|
||||
// doc plaster processing
|
||||
} else if (updatePlaster) {
|
||||
const plasterString = updatePlaster[1].trim();
|
||||
plaster = plasterString ? regionMatcher.createPlasterComment(plasterString) : '';
|
||||
|
||||
// simple line of content processing
|
||||
} else {
|
||||
openRegions.forEach(regionName => regionMap[regionName].lines.push(line));
|
||||
// do not filter out this line from the content
|
||||
return true;
|
||||
}
|
||||
|
||||
regionNames.forEach(regionName => {
|
||||
const region = regionMap[regionName];
|
||||
if (!region || !region.open) {
|
||||
throw new RegionParserError(
|
||||
`Tried to close a region, named "${regionName}", that is not open`, index);
|
||||
}
|
||||
region.open = false;
|
||||
removeLast(openRegions, regionName);
|
||||
});
|
||||
|
||||
// doc plaster processing
|
||||
} else if (updatePlaster) {
|
||||
const plasterString = updatePlaster[1].trim();
|
||||
plaster = plasterString ? regionMatcher.createPlasterComment(plasterString) : '';
|
||||
|
||||
// simple line of content processing
|
||||
} else {
|
||||
openRegions.forEach(regionName => regionMap[regionName].lines.push(line));
|
||||
// do not filter out this line from the content
|
||||
return true;
|
||||
// this line contained an annotation so let's filter it out
|
||||
return false;
|
||||
});
|
||||
if (!regionMap['']) {
|
||||
regionMap[''] = {lines};
|
||||
}
|
||||
|
||||
// this line contained an annotation so let's filter it out
|
||||
return false;
|
||||
});
|
||||
if (!regionMap['']) {
|
||||
regionMap[''] = {lines};
|
||||
return {
|
||||
contents: lines.join('\n'),
|
||||
regions: mapObject(regionMap, (regionName, region) => leftAlign(region.lines).join('\n'))
|
||||
};
|
||||
} else {
|
||||
return {contents, regions: {}};
|
||||
}
|
||||
return {
|
||||
contents: lines.join('\n'),
|
||||
regions: mapObject(regionMap, (regionName, region) => leftAlign(region.lines).join('\n'))
|
||||
};
|
||||
} else {
|
||||
return {contents, regions: {}};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function getRegionNames(input) {
|
||||
return (input.trim() === '') ? [] : input.split(',').map(name => name.trim());
|
||||
|
Reference in New Issue
Block a user