Skip to content

Commit

Permalink
Add script to update expected files for test sites
Browse files Browse the repository at this point in the history
Developers have to update the expected folder for test sites by hand.
Updating the expected folders for each site manually becomes especially
unwieldy as the number of test sites increase.

Let's have a script which automates the updating of expected folders in
all of the test sites.
  • Loading branch information
Marvin Chin committed Apr 12, 2019
1 parent 1aab519 commit 45cc920
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 2 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@
"url": "https://github.com/MarkBind/markbind.git"
},
"scripts": {
"jest": "jest",
"lint": "./node_modules/.bin/eslint .",
"pretest": "npm run lint",
"pretestwin": "npm run lint",
"testwin": "jest && cd test/functional && test.bat",
"test": "jest && cd test/functional && ./test.sh",
"jest": "jest"
"testwin": "jest && cd test/functional && test.bat",
"updatetest": "cd test/functional && ./update.sh",
"updatetestwin": "cd test/functional && update.bat"
},
"jest": {
"testPathIgnorePatterns": [
Expand Down
33 changes: 33 additions & 0 deletions test/functional/update.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@ECHO off

for /f "tokens=* delims=" %%a in (test_sites) do (

echo(
echo Updating %%a

node ../../index.js build %%a

rmdir /s /q %%a\expected
xcopy /e /y /i /q %%a\_site %%a\expected
)

for /f "tokens=* delims=" %%a in (test_convert_sites) do (

echo(
echo Updating %%a

node ../../index.js init %%a\non_markbind_site -c

node ../../index.js build %%a\non_markbind_site

rmdir /s /q %%a\expected
xcopy /e /y /i /q %%a\non_markbind_site\_site %%a\expected

rmdir /s /q %%a\_site
rmdir /q %%a\non_markbind_site\_markbind
rmdir /s /q %%a\non_markbind_site\_site
del %%a\non_markbind_site\about.md %%a\non_markbind_site\index.md %%a\non_markbind_site\site.json
)

echo Updated all test sites
exit /b %errorlevel%
49 changes: 49 additions & 0 deletions test/functional/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

for site in $(cat test_sites);
do
# print site name
echo "Updating $site"

# build site
node ../../index.js build "$site"

# replace the expected folder with the newly generated files
rm -rf $site/expected
cp -r $site/_site $site/expected
done

function cleanup_convert {
# delete generated files
rm -rf $site_convert/_site
rm -rf $site_convert/non_markbind_site/_markbind $site_convert/non_markbind_site/_site
rm -f $site_convert/non_markbind_site/about.md $site_convert/non_markbind_site/index.md "$site_convert"/non_markbind_site/site.json
}

for site_convert in $(cat test_convert_sites);
do
# print site name
echo "Updating $site_convert test"

# set cleanup trap
trap cleanup_convert EXIT

# convert site
node ../../index.js init $site_convert/non_markbind_site -c

# build site
node ../../index.js build $site_convert/non_markbind_site

# replace the expected folder with the newly generated files
rm -rf $site_convert/expected
cp -r $site_convert/non_markbind_site/_site $site_convert/expected

# cleanup generated files
cleanup_convert

# remove trap
trap - EXIT
done

echo "Updated all test sites"
exit 0

0 comments on commit 45cc920

Please sign in to comment.