Skip to content

Commit

Permalink
allow plantUml images to be ignored for all test_sites when running n…
Browse files Browse the repository at this point in the history
…pm test
  • Loading branch information
yucheng11122017 committed Apr 5, 2024
1 parent 6cc2461 commit c6bf4b3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 23 deletions.
27 changes: 17 additions & 10 deletions packages/cli/test/functional/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const {
testSites,
testConvertSites,
testTemplateSites,
plantumlGeneratedFiles,
plantumlGeneratedFilesForTestSites,
plantumlGeneratedFilesForConvertSites,
plantumlGeneratedFilesForTemplateSites,
} = require('./testSites');

/* eslint-disable no-console */
Expand All @@ -31,38 +33,43 @@ testSites.forEach((siteName) => {
console.log(`Running ${siteName} tests`);
try {
execSync(`node ../../index.js build ${siteName}`, execOptions);
compare(siteName, 'expected', '_site', siteName === 'test_site' ? plantumlGeneratedFiles : []);
const siteIgnoredFiles = plantumlGeneratedFilesForTestSites[siteName];
compare(siteName, 'expected', '_site', siteIgnoredFiles);
} catch (err) {
printFailedMessage(err, siteName);
process.exit(1);
}
});

testConvertSites.forEach((siteName) => {
console.log(`Running ${siteName} tests`);
const nonMarkBindSitePath = path.join(siteName, 'non_markbind_site');
testConvertSites.forEach((sitePath) => {
console.log(`Running ${sitePath} tests`);
const nonMarkBindSitePath = path.join(sitePath, 'non_markbind_site');
const siteName = sitePath.split('/')[1];
try {
execSync(`node ../../index.js init ${nonMarkBindSitePath} -c`, execOptions);
execSync(`node ../../index.js build ${nonMarkBindSitePath}`, execOptions);
compare(siteName, 'expected', 'non_markbind_site/_site');
const siteIgnoredFiles = plantumlGeneratedFilesForConvertSites[siteName];
compare(sitePath, 'expected', 'non_markbind_site/_site', siteIgnoredFiles);
} catch (err) {
printFailedMessage(err, siteName);
cleanupConvert(path.resolve(__dirname, siteName));
printFailedMessage(err, sitePath);
cleanupConvert(path.resolve(__dirname, sitePath));
process.exit(1);
}
cleanupConvert(path.resolve(__dirname, siteName));
cleanupConvert(path.resolve(__dirname, sitePath));
});

testTemplateSites.forEach((templateAndSitePath) => {
const flag = templateAndSitePath.split(',')[0];
const sitePath = templateAndSitePath.split(',')[1];
const siteCreationTempPath = path.join(sitePath, 'tmp');
const siteName = sitePath.split('/')[1];

console.log(`Running ${sitePath} tests`);
try {
execSync(`node ../../index.js init ${siteCreationTempPath} --template ${flag}`, execOptions);
execSync(`node ../../index.js build ${siteCreationTempPath}`, execOptions);
compare(sitePath, 'expected', 'tmp/_site');
const siteIgnoredFiles = plantumlGeneratedFilesForTemplateSites[siteName];
compare(sitePath, 'expected', 'tmp/_site', siteIgnoredFiles);
} catch (err) {
printFailedMessage(err, sitePath);
fs.removeSync(path.resolve(__dirname, siteCreationTempPath));
Expand Down
36 changes: 23 additions & 13 deletions packages/cli/test/functional/testSites.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,32 @@ const testTemplateSites = [
// these files create git diffs every time they are generated,
// we decided to not commit them to the repository.
// However, we still want to verify that they are present.
const plantumlGeneratedFiles = [
'9c9e77fc0a983cb6b592e65733787bec.png',
'inline-output.png',
'diagrams/activity.png',
'diagrams/class.png',
'diagrams/component.png',
'diagrams/object.png',
'diagrams/sequence.png',
'diagrams/state.png',
'diagrams/usecase.png',
'sub_site/inline-output/inline-puml-image.png',
];
const plantumlGeneratedFilesForTestSites = {
test_site: [
'9c9e77fc0a983cb6b592e65733787bec.png',
'inline-output.png',
'diagrams/activity.png',
'diagrams/class.png',
'diagrams/component.png',
'diagrams/object.png',
'diagrams/sequence.png',
'diagrams/state.png',
'diagrams/usecase.png',
'sub_site/inline-output/inline-puml-image.png',
],
};

const plantumlGeneratedFilesForConvertSites = {};

const plantumlGeneratedFilesForTemplateSites = {
test_project: ['diagrams/example.png'],
};

module.exports = {
testSites,
testConvertSites,
testTemplateSites,
plantumlGeneratedFiles,
plantumlGeneratedFilesForTestSites,
plantumlGeneratedFilesForConvertSites,
plantumlGeneratedFilesForTemplateSites,
};
Binary file not shown.

0 comments on commit c6bf4b3

Please sign in to comment.