Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to update expected folder for test sites #828

Merged
merged 4 commits into from
Apr 14, 2019

Conversation

marvinchin
Copy link
Contributor

What is the purpose of this pull request? (put "X" next to an item, remove the rest)

• [x] Other, please explain: workflow improvement

Resolves #761.

What is the rationale for this request?

Presently, developers have to update the expected output for the test sites by hand. As the number of test sites increase, rebuilding the test sites and updating the expected folders of each site becomes more unwieldy.

Being able to automatically updated the expected folders would help reduce the time spent on this process.

What changes did you make? (Give an overview)

  • Moved declaration of test site directory names to a separate file to reduce duplication
  • Add update.sh and update.bat which rebuilds all test sites and updates their expected folders.

Is there anything you'd like reviewers to focus on?

I don't have a Windows machine, so it would be great if a windows user can help to test both test.bat and update.bat to ensure they are behaving as expected 🙂

Testing instructions:

Run npm run updatetest or npm run updatetestwin. All test sites should be rebuilt, and the output in _site should be copied over to expected.

Proposed commit message: (wrap lines at 72 characters)

I've split the PR into 2 commits, each with their own commit message. Do let me know if I should change them!

Copy link
Member

@yamgent yamgent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it on Windows, works brilliantly. 👍

I got one request though, can update the maintainer's guide to mention about your new feature? Thanks! This part:


  1. Rebuild the test files.
# on Unix
$ npm run updatetest

# on Windows
> npm run updatetestwin

@luyangkenneth
Copy link
Contributor

luyangkenneth commented Apr 10, 2019

I got one request though, can update the maintainer's guide to mention about your new feature? Thanks! This part:

@yamgent Seems like you forgot to include a link :P
Also, I think the relevant docs to update should be this section in the developer guide (instead of the maintainer guide)? -> https://markbind.org/devGuide/index.html#updating-tests

EDIT: Ok wait I see what you did there 👍 You can ignore this comment haha

@@ -0,0 +1,2 @@
test_site
test_site_algolia_plugin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot of the current docs:
Screenshot 2019-04-10 at 11 32 31 PM

Given that we no longer have one ("the") test site, it would be great to also update the details of this new testing approach in our developer guide (in the Running tests and Updating tests sections). In particular, mentioning that whenever a new test site is added, its folder name will need to be added to this file.

@marvinchin marvinchin force-pushed the update-test-sites-script branch from 9f68a56 to 4756e49 Compare April 10, 2019 16:43
yamgent
yamgent previously approved these changes Apr 11, 2019
@yamgent yamgent added this to the v2.1.2 milestone Apr 11, 2019
@yamgent
Copy link
Member

yamgent commented Apr 11, 2019

I am foreseeing that the changes for the test.bat and test.sh is going to clash with #698 (specifically, in #698, one of the test sites actually builds a bit differently because we are testing the conversion feature).

Since #698 is a big PR (edit: big feature PR), could we wait for #698 to merge first before we come back to this PR? :)

@marvinchin
Copy link
Contributor Author

Sure, we can revisit this after #698 is merged!

@yamgent yamgent removed this from the v2.1.2 milestone Apr 12, 2019
@yamgent yamgent removed the s.OnHold label Apr 12, 2019
@yamgent
Copy link
Member

yamgent commented Apr 12, 2019

@marvinchin #698 is merged, you can continue with resolving conflict now.

@marvinchin
Copy link
Contributor Author

marvinchin commented Apr 12, 2019

I've updated the scripts after rebasing on top of master. If someone could re-test the windows implementation again to ensure that it still works, that would be great!

@amad-person I made some changes to the implementation of test.sh to match the implementation of test.bat (see 1aab519) - do you mind taking a look at it to ensure that the behaviour is still as you had intended?

Thanks everyone 🙂

Copy link
Contributor

@amad-person amad-person left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor nit. The site_convert testing behaviour is working as intended in test.sh! Thanks for this PR 😄

@marvinchin marvinchin force-pushed the update-test-sites-script branch from 9596ee0 to f5ae0d4 Compare April 12, 2019 09:44
amad-person
amad-person previously approved these changes Apr 12, 2019
luyangkenneth
luyangkenneth previously approved these changes Apr 12, 2019
Copy link
Contributor

@luyangkenneth luyangkenneth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; some ideas about phrasing and structure -

@@ -136,20 +136,41 @@ $ npm run test
For Windows users:

```
$ npm run testwin
> npm run testwin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💥
☁️
😮

> npm run updatetestwin
```
<box type="warning">
You should always check that the output generated is correct before committing your changes to the expected site.
Copy link
Contributor

@luyangkenneth luyangkenneth Apr 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's standardize on "expected files" and "test sites"? :D So if you were to use both terms together, you would phrase it as Update the expected files in all the test sites.

For this sentence, it might become something like: You should always check that the generated output is correct before committing any changes to the test sites.


##### New features

Add new site content into the `test/test_site/` folder to demonstrate the new feature. Ensure that the new content is included in the test site so that your feature will be tested when `markbind build` is run on the test site. Remember to update the expected HTML files in `test/test_site/expected/`.
Add new site content into an existing test site or create a new test site to demonstrate the new feature. Ensure that the new content is included in the test site so that your feature will be tested when `markbind build` is run on the test site. Remember to update the expected HTML files for the test site.
Copy link
Contributor

@luyangkenneth luyangkenneth Apr 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like there's some repetition here. The special case of adding new site content / creating a new test site only applies when adding a new feature.

So maybe we can remove the Changes to existing features section, and combine Simply / Remember to update the expected files... with L144-146.

Say, something like:

#### Updating tests

Whether you are adding a new feature, updating existing features or fixing bugs, make sure to update the test sites to reflect the changes. You may use the following scripts to do this automatically:

[...]

#### When adding new features

Add new site content into an existing test site or create a new test site to demonstrate the new feature. This is to ensure that your feature can be tested by building that test site.

<box type"info">
  When creating a new test site...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, dropping the HTML here because sometimes the non-HTML files get modified too

yamgent
yamgent previously approved these changes Apr 13, 2019
Copy link
Member

@yamgent yamgent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the documentation change suggestions by Kenneth, I got nothing else to add.

Marvin Chin added 2 commits April 13, 2019 23:52
Declaration of test site directories are replicated across test.bat and
test.sh.

Let's move the declaration to a separate file and have the scripts
obtain the directory names from the file instead.
The implementation of the bash and batch test script differs slightly.
The batch script implementation allows multiple test convert sites, but
the bash script implementation only allows a single test convert site.

Let's update the bash script to allow it to be extensible to multiple
test convert sites.
@marvinchin marvinchin dismissed stale reviews from yamgent, luyangkenneth, and amad-person via 2689339 April 13, 2019 15:53
@marvinchin marvinchin force-pushed the update-test-sites-script branch 2 times, most recently from 2689339 to d5d4839 Compare April 13, 2019 15:58
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.
@marvinchin marvinchin force-pushed the update-test-sites-script branch from d5d4839 to b01d932 Compare April 13, 2019 16:00
@marvinchin
Copy link
Contributor Author

Updated the documentation as per the comments. Thanks again for looking at it!

@marvinchin
Copy link
Contributor Author

Sorry, not sure what happened but the previous reviews seem to have been dismissed 🙁

@marvinchin marvinchin force-pushed the update-test-sites-script branch from b01d932 to 80f059b Compare April 13, 2019 16:17
@acjh
Copy link
Contributor

acjh commented Apr 13, 2019

Sorry, not sure what happened but the previous reviews seem to have been dismissed

Automatic dismissal of reviews via push is misrepresented in UI: isaacs/github#1157

$ npm run updatetest
```

For Windows users:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe standardize to "On Unix" and "On Windows" like you mentioned in the maintainer guide?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

The updatetest and updatetestwin scripts have been added for developers
to update the expected output for all test sites.

Also, testing instructions for the developer and maintainer guides
assume that there is only one test site.

Let's update the developer and maintainer guides to include usage
instructions for the test site update scripts. Let's also generalize
the testing instructions for multiple test sites.
@marvinchin marvinchin force-pushed the update-test-sites-script branch from 80f059b to 329b333 Compare April 13, 2019 17:16
@yamgent
Copy link
Member

yamgent commented Apr 14, 2019

Sorry, not sure what happened but the previous reviews seem to have been dismissed 🙁

Automatic dismissal of reviews via push is misrepresented in UI: isaacs/github#1157

Understood the distress caused by this feature; I have disabled it, sorry!

@yamgent yamgent added this to the v2.1.2 milestone Apr 14, 2019
@yamgent yamgent merged commit fe42fe1 into MarkBind:master Apr 14, 2019
@yamgent
Copy link
Member

yamgent commented Apr 15, 2019

There was a bug in update.bat, but I fixed it in 9c7438d.

Otherwise, this PR has improved my quality of life when doing releases, and even indirectly spotted a bug, so nice job. 👍

@luyangkenneth
Copy link
Contributor

Woohoo impacc 🎉 @marvinchin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NPM script to replace expected output for test site
5 participants