Skip to content

Commit

Permalink
Infrastructure: Fix failing npm run regression-report script (#2291)
Browse files Browse the repository at this point in the history
Changes the regression-report script to support the changes to file system structure made in  #2417. Changes include:
* Support for new content/patterns structure
* replaced spawnSync with cross-spawn's '.sync'
* Account for carriage return from Windows when ignoring files
* Additional path support for Windows
* Update cspell.json
  • Loading branch information
howard-e authored Dec 12, 2023
1 parent b2cae7f commit aa6307a
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 16 deletions.
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"dropup",
"Dubnium",
"Dušek",
"entrypoints",
"EXPANDO",
"Fairchild",
"Fancytree",
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@babel/eslint-parser": "^7.22.15",
"ava": "^5.3.1",
"cheerio": "^1.0.0-rc.12",
"cross-spawn": "^7.0.3",
"cspell": "^7.3.8",
"eslint": "^8.52.0",
"eslint-config-prettier": "^8.5.0",
Expand Down
26 changes: 14 additions & 12 deletions test/util/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const cheerio = require('cheerio');
const path = require('path');
const fs = require('fs');
const htmlparser2 = require('htmlparser2');
const { spawnSync } = require('child_process');
const spawn = require('cross-spawn');

const examplePath = path.resolve(__dirname, '..', '..', 'examples');
const examplePath = path.resolve(__dirname, '..', '..', 'content', 'patterns');
const testsPath = path.resolve(__dirname, '..', 'tests');
const ignoreExampleDirs = path.resolve(
__dirname,
Expand All @@ -25,13 +25,13 @@ const ignoreDirectories = fs
.readFileSync(ignoreExampleDirs)
.toString()
.trim()
.split('\n')
.split(/\r\n|\r|\n/)
.map((d) => path.resolve(examplePath, d));
const ignoreFiles = fs
.readFileSync(ignoreExampleFiles)
.toString()
.trim()
.split('\n')
.split(/\r\n|\r|\n/)
.map((f) => path.resolve(examplePath, f));

/**
Expand Down Expand Up @@ -175,17 +175,19 @@ const getRegressionTestCoverage = function (exampleCoverage) {
allTestFiles.push(path.join(testsPath, testFile));
});

const cmd = path.resolve(
const cmd = 'node';
const avaCmdPath = path.resolve(
__dirname,
'..',
'..',
'node_modules',
'ava',
'cli.js'
'entrypoints',
'cli.mjs'
);
const cmdArgs = [...allTestFiles, '--tap', '-c', '1'];
const cmdArgs = [avaCmdPath, ...allTestFiles, '--tap', '-c', '1'];

const output = spawnSync(cmd, cmdArgs);
const output = spawn.sync(cmd, cmdArgs);
const avaResults = output.stdout.toString();
const avaError = output.stderr.toString();

Expand All @@ -195,15 +197,15 @@ const getRegressionTestCoverage = function (exampleCoverage) {
process.exitCode = 1;
process.exit();
}

let testRegex = /^# (\S+) [>›] (\S+\.html) \[data-test-id="(\S+)"\]/gm;
let testRegex = /[>›] (\S+\.html) \[data-test-id="(\S+)"]/gm;
let matchResults;
while ((matchResults = testRegex.exec(avaResults))) {
let example = matchResults[2];
let example = matchResults[1];
example = path.normalize(example.replace('content/patterns/', ''));

// If the test file has a data-test-id, the data-test-id must exist on
// the test page.
exampleCoverage[example].missingTests.delete(matchResults[3]);
exampleCoverage[example].missingTests.delete(matchResults[2]);
}
};

Expand Down
36 changes: 33 additions & 3 deletions test/util/report_files/ignore_html_files
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
grid/advanced-data-grid.html
feed/feed-display.html
index.html
grid/examples/advanced-data-grid.html
feed/examples/feed-display.html
patterns.html

accordion/accordion-pattern.html
alert/alert-pattern.html
alertdialog/alertdialog-pattern.html
breadcrumb/breadcrumb-pattern.html
button/button-pattern.html
carousel/carousel-pattern.html
checkbox/checkbox-pattern.html
combobox/combobox-pattern.html
dialog-modal/dialog-modal-pattern.html
disclosure/disclosure-pattern.html
feed/feed-pattern.html
grid/grid-pattern.html
link/link-pattern.html
listbox/listbox-pattern.html
menu-button/menu-button-pattern.html
menubar/menu-and-menubar-pattern.html
meter/meter-pattern.html
radio/radio-group-pattern.html
slider/slider-pattern.html
slider-multithumb/slider-multithumb-pattern.html
spinbutton/spinbutton-pattern.html
switch/switch-pattern.html
table/table-pattern.html
tabs/tabs-pattern.html
toolbar/toolbar-pattern.html
tooltip/tooltip-pattern.html
treegrid/treegrid-pattern.html
treeview/treeview-pattern.html
windowsplitter/windowsplitter-pattern.html
1 change: 0 additions & 1 deletion test/util/report_files/ignore_test_directories
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
coding-template
landmarks

0 comments on commit aa6307a

Please sign in to comment.