diff --git a/.travis.yml b/.travis.yml index d940bb5526..8f37b38661 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,14 +31,7 @@ jobs: - stage: Test name: AVA Regression Tests - before_install: - - | - if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qE '(test/|examples/)' - then - echo "Examples files were not updated, not running example regression tests." - exit - fi - script: ava -c 1 test/tests + script: scripts/regression-tests.sh env: TEST_WAIT_TIME=1000 - stage: Test name: Regression Tests Coverage Report diff --git a/scripts/regression-tests.sh b/scripts/regression-tests.sh new file mode 100755 index 0000000000..02aa4140a0 --- /dev/null +++ b/scripts/regression-tests.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qP '(test/|examples/|package\.json)' +then + echo "Examples files were not updated, not running example regression tests." + exit +fi + +TEST_DIRS=$(git diff --name-only $TRAVIS_COMMIT_RANGE | grep -oP 'test/tests/\K[\w-]+(?=_)' | uniq) +EXAMPLE_DIRS=$(git diff --name-only $TRAVIS_COMMIT_RANGE | grep -oP 'examples/\K[\w-]+(?=/)' | uniq) + +# Only add match args if the example/js or example/css directories or test/index.hs +# or the test/utils.js directories have not been edited + +TEST_INFRA=$(git diff --name-only $TRAVIS_COMMIT_RANGE | grep -oP 'test/(util|index)') +EXAMPLE_INFRA=$(echo "$EXAMPLE_DIRS" | grep -P '^(js|css)$') + +ARGS='' + +if [ -z $TEST_INFRA ] && [ -z $EXAMPLE_INFRA ] +then + for D in $EXAMPLE_DIRS + do + ARGS="${ARGS} --match ${D}/*" + done + + for F in $TEST_DIRS + do + ARGS="${ARGS} --match ${F}/*" + done +fi + +AVACMD="npm run regression -- -t -c 1 test/tests ${ARGS}" +echo "$ $AVACMD" + +$AVACMD diff --git a/test/tests/accordion.js b/test/tests/accordion_accordion.js similarity index 100% rename from test/tests/accordion.js rename to test/tests/accordion_accordion.js diff --git a/test/tests/alert.js b/test/tests/alert_alert.js similarity index 100% rename from test/tests/alert.js rename to test/tests/alert_alert.js diff --git a/test/tests/breadcrumb.js b/test/tests/breadcrumb_index.js similarity index 100% rename from test/tests/breadcrumb.js rename to test/tests/breadcrumb_index.js diff --git a/test/tests/button.js b/test/tests/button_button.js similarity index 100% rename from test/tests/button.js rename to test/tests/button_button.js diff --git a/test/tests/carousel-1.js b/test/tests/carousel_carousel-1.js similarity index 100% rename from test/tests/carousel-1.js rename to test/tests/carousel_carousel-1.js diff --git a/test/tests/checkbox-1.js b/test/tests/checkbox_checkbox-1.js similarity index 100% rename from test/tests/checkbox-1.js rename to test/tests/checkbox_checkbox-1.js diff --git a/test/tests/checkbox-2.js b/test/tests/checkbox_checkbox-2.js similarity index 100% rename from test/tests/checkbox-2.js rename to test/tests/checkbox_checkbox-2.js diff --git a/test/tests/combo-10-autocomplete-both.js b/test/tests/combobox_autocomplete-both.js similarity index 100% rename from test/tests/combo-10-autocomplete-both.js rename to test/tests/combobox_autocomplete-both.js diff --git a/test/tests/combo-10-autocomplete-list.js b/test/tests/combobox_autocomplete-list.js similarity index 100% rename from test/tests/combo-10-autocomplete-list.js rename to test/tests/combobox_autocomplete-list.js diff --git a/test/tests/combo-10-autocomplete-none.js b/test/tests/combobox_autocomplete-none.js similarity index 100% rename from test/tests/combo-10-autocomplete-none.js rename to test/tests/combobox_autocomplete-none.js diff --git a/test/tests/combo-11-grid.js b/test/tests/combobox_grid-combo.js similarity index 100% rename from test/tests/combo-11-grid.js rename to test/tests/combobox_grid-combo.js diff --git a/test/tests/combo-11-listbox.js b/test/tests/combobox_listbox-combo.js similarity index 100% rename from test/tests/combo-11-listbox.js rename to test/tests/combobox_listbox-combo.js diff --git a/test/tests/datepicker-dialog.js b/test/tests/dialog-modal_datepicker.js similarity index 100% rename from test/tests/datepicker-dialog.js rename to test/tests/dialog-modal_datepicker.js diff --git a/test/tests/dialog.js b/test/tests/dialog-modal_dialog.js similarity index 100% rename from test/tests/dialog.js rename to test/tests/dialog-modal_dialog.js diff --git a/test/tests/disclosure-faq.js b/test/tests/disclosure_faq.js similarity index 100% rename from test/tests/disclosure-faq.js rename to test/tests/disclosure_faq.js diff --git a/test/tests/disclosure-img-long-description.js b/test/tests/disclosure_img-long-description.js similarity index 100% rename from test/tests/disclosure-img-long-description.js rename to test/tests/disclosure_img-long-description.js diff --git a/test/tests/disclosure-navigation.js b/test/tests/disclosure_navigation.js similarity index 100% rename from test/tests/disclosure-navigation.js rename to test/tests/disclosure_navigation.js diff --git a/test/tests/feed.js b/test/tests/feed_feed.js similarity index 100% rename from test/tests/feed.js rename to test/tests/feed_feed.js diff --git a/test/tests/LayoutGrids.js b/test/tests/grid_LayoutGrids.js similarity index 100% rename from test/tests/LayoutGrids.js rename to test/tests/grid_LayoutGrids.js diff --git a/test/tests/dataGrids.js b/test/tests/grid_dataGrids.js similarity index 100% rename from test/tests/dataGrids.js rename to test/tests/grid_dataGrids.js diff --git a/test/tests/link.js b/test/tests/link_link.js similarity index 100% rename from test/tests/link.js rename to test/tests/link_link.js diff --git a/test/tests/listbox-collapsible.js b/test/tests/listbox_collapsible.js similarity index 100% rename from test/tests/listbox-collapsible.js rename to test/tests/listbox_collapsible.js diff --git a/test/tests/listbox-rearrangeable.js b/test/tests/listbox_rearrangeable.js similarity index 100% rename from test/tests/listbox-rearrangeable.js rename to test/tests/listbox_rearrangeable.js diff --git a/test/tests/listbox-scrollable.js b/test/tests/listbox_scrollable.js similarity index 100% rename from test/tests/listbox-scrollable.js rename to test/tests/listbox_scrollable.js diff --git a/test/tests/menu-button-actions-active-descendant.js b/test/tests/menu-button_actions-active-descendant.js similarity index 100% rename from test/tests/menu-button-actions-active-descendant.js rename to test/tests/menu-button_actions-active-descendant.js diff --git a/test/tests/menu-button-actions.js b/test/tests/menu-button_actions.js similarity index 100% rename from test/tests/menu-button-actions.js rename to test/tests/menu-button_actions.js diff --git a/test/tests/menu-button-links.js b/test/tests/menu-button_links.js similarity index 100% rename from test/tests/menu-button-links.js rename to test/tests/menu-button_links.js diff --git a/test/tests/menubar-1.js b/test/tests/menubar_menubar-1.js similarity index 100% rename from test/tests/menubar-1.js rename to test/tests/menubar_menubar-1.js diff --git a/test/tests/menubar-2.js b/test/tests/menubar_menubar-2.js similarity index 100% rename from test/tests/menubar-2.js rename to test/tests/menubar_menubar-2.js diff --git a/test/tests/radio-1.js b/test/tests/radio_radio-1.js similarity index 100% rename from test/tests/radio-1.js rename to test/tests/radio_radio-1.js diff --git a/test/tests/radio-2.js b/test/tests/radio_radio-2.js similarity index 100% rename from test/tests/radio-2.js rename to test/tests/radio_radio-2.js diff --git a/test/tests/multithumb-slider.js b/test/tests/slider_multithumb.js similarity index 100% rename from test/tests/multithumb-slider.js rename to test/tests/slider_multithumb.js diff --git a/test/tests/slider-1.js b/test/tests/slider_slider-1.js similarity index 100% rename from test/tests/slider-1.js rename to test/tests/slider_slider-1.js diff --git a/test/tests/slider-2.js b/test/tests/slider_slider-2.js similarity index 100% rename from test/tests/slider-2.js rename to test/tests/slider_slider-2.js diff --git a/test/tests/datepicker-spinbuttons.js b/test/tests/spinbutton_datepicker.js similarity index 100% rename from test/tests/datepicker-spinbuttons.js rename to test/tests/spinbutton_datepicker.js diff --git a/test/tests/table.js b/test/tests/table_table.js similarity index 100% rename from test/tests/table.js rename to test/tests/table_table.js diff --git a/test/tests/tabs.js b/test/tests/tabs_tabs-1.js similarity index 100% rename from test/tests/tabs.js rename to test/tests/tabs_tabs-1.js diff --git a/test/tests/tabs-2.js b/test/tests/tabs_tabs-2.js similarity index 100% rename from test/tests/tabs-2.js rename to test/tests/tabs_tabs-2.js diff --git a/test/tests/toolbar.js b/test/tests/toolbar_toolbar.js similarity index 100% rename from test/tests/toolbar.js rename to test/tests/toolbar_toolbar.js diff --git a/test/tests/treegrid-1.js b/test/tests/treegrid_treegrid-1.js similarity index 100% rename from test/tests/treegrid-1.js rename to test/tests/treegrid_treegrid-1.js diff --git a/test/tests/treeview-1a.js b/test/tests/treeview_treeview-1a.js similarity index 100% rename from test/tests/treeview-1a.js rename to test/tests/treeview_treeview-1a.js diff --git a/test/tests/treeview-1b.js b/test/tests/treeview_treeview-1b.js similarity index 100% rename from test/tests/treeview-1b.js rename to test/tests/treeview_treeview-1b.js diff --git a/test/tests/treeview-2a.js b/test/tests/treeview_treeview-2a.js similarity index 100% rename from test/tests/treeview-2a.js rename to test/tests/treeview_treeview-2a.js diff --git a/test/tests/treeview-2b.js b/test/tests/treeview_treeview-2b.js similarity index 100% rename from test/tests/treeview-2b.js rename to test/tests/treeview_treeview-2b.js diff --git a/test/util/report.js b/test/util/report.js index d917079c81..ac08f1fd88 100644 --- a/test/util/report.js +++ b/test/util/report.js @@ -26,7 +26,7 @@ const ignoreFiles = fs.readFileSync(ignoreExampleFiles) /** * Recursively find all example pages, saves to exampleFiles global - * obect. + * object. * * @param {String} currentDirPath - root example directory */ @@ -234,6 +234,18 @@ for (let example in exampleCoverage) { } } + +let badFileNames = []; +fs.readdirSync(testsPath).forEach(function (testFile) { + + let dirName = testFile.split('_')[0]; + let dir = path.join(examplePath, dirName); + + if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) { + badFileNames.push([testFile, dir]); + } +}); + console.log('\nExamples without regression tests:\n'); console.log(examplesWithNoTestsReport || 'None found.\n'); console.log('\nExamples missing regression tests:\n'); @@ -248,7 +260,16 @@ console.log(' ' + examplesMissingSomeTests + ' example pages are missing approx missingTestIds + ' out of approximately ' + totalTestIds + ' tests.\n'); if (examplesMissingSomeTests) { - console.log('ERROR:\n\n Please write missing tests for this report to pass.\n'); + console.log('ERROR - missing tests:\n\n Please write missing tests for this report to pass.\n'); + process.exitCode = 1; +} +if (badFileNames.length) { + console.log('ERROR - bad file names:\n\n Some test files do not follow the correct naming convention. Test file names should begin with the root parent directory of example being tested followed by an underscore (\'_\'). Please correct the following bad test file(s):\n'); + + for (let file of badFileNames) { + console.log(' ' + file[0]); + } + console.log('\n'); process.exitCode = 1; }