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

feat: add mdbook plugin for testing mun code in book #263

Merged
merged 1 commit into from
Oct 4, 2020

Conversation

legendiguess
Copy link
Contributor

This pull request add mdbook plugin that's test all mun code(indicated by keyword mun before code block).

Also, plugin allows to specify "testing method" for each code block by using keywords no_run, compile_fail and skip.
Example: mun,no_run, mun,compile_fail and etc

With this pull request, plugin already setted as dependency for mun book, so before building new version of book by mdbook build one need to compile mdbook-mun-examples-test crate and add it's executable file to environment variables.

closes #209

@legendiguess
Copy link
Contributor Author

Also need to mention that this pr skip testing one code from chapter 2.2 Functions because it's have a bug right now - #262

@Wodann Wodann self-requested a review September 1, 2020 12:49
@Wodann Wodann added the type: feat New feature or request label Sep 1, 2020
@codecov
Copy link

codecov bot commented Sep 1, 2020

Codecov Report

Merging #263 into master will decrease coverage by 0.27%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #263      +/-   ##
==========================================
- Coverage   79.10%   78.82%   -0.28%     
==========================================
  Files         219      220       +1     
  Lines       13024    13070      +46     
==========================================
  Hits        10303    10303              
- Misses       2721     2767      +46     
Impacted Files Coverage Δ
crates/mun_mdbook_test_plugin/src/main.rs 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 720bdae...6fd66d1. Read the comment docs.

Copy link
Collaborator

@Wodann Wodann left a comment

Choose a reason for hiding this comment

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

Nice work @legendiguess. Very happy with this addition. I've added some minor remarks, but mostly it looks good to go.

Could you also remove book/listings/ch03-structs/mun.exe? It's not necessary to have that committed 🙂

book/book.toml Outdated Show resolved Hide resolved
crates/mdbook-mun-examples-test/Cargo.toml Outdated Show resolved Hide resolved
crates/mdbook-mun-examples-test/src/main.rs Outdated Show resolved Hide resolved
crates/mdbook-mun-examples-test/src/main.rs Outdated Show resolved Hide resolved
crates/mdbook-mun-examples-test/src/main.rs Outdated Show resolved Hide resolved
crates/mdbook-mun-examples-test/Cargo.toml Outdated Show resolved Hide resolved
@Wodann
Copy link
Collaborator

Wodann commented Sep 3, 2020

@legendiguess I see that you performed a merge. In the future, please do "rebase merges" instead. If you are unfamiliar with rebase merges, our contributing guidelines explain it in more detail here.

@legendiguess
Copy link
Contributor Author

legendiguess commented Sep 3, 2020

@legendiguess I see that you performed a merge. In the future, please do "rebase merges" instead. If you are unfamiliar with rebase merges, our contributing guidelines explain it in more detail here.

Oh, sorry, it's was just due to my inexperience, i removed merge 👍

book/src/ch02-02-functions.md Outdated Show resolved Hide resolved
crates/mdbook-mun-examples-test/src/main.rs Outdated Show resolved Hide resolved
crates/mdbook-mun-examples-test/src/main.rs Outdated Show resolved Hide resolved
@Wodann
Copy link
Collaborator

Wodann commented Sep 23, 2020

@legendiguess Do you need any help to fix the last couple of issues?

Copy link
Collaborator

@Wodann Wodann left a comment

Choose a reason for hiding this comment

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

That looks a lot better. I recommended a few changes, because:

  • I think we should use no_run instead of run. I explained why in one of the comments in main.rs
    This means that by default, we always run the Mun source code, unless you specify no_run.
  • After looking at our CLI source code, it seems that just using pub fn main as the entry point for Mun source is the best option. That's the same for our mdbook plugin and the Mun CLI then.
  • I think we don't need skip anymore, now that the compiler bug is fixed.
  • I think compile_fail should always mean that nothing will run.

book/listings/ch01-getting-started/listing01.mun Outdated Show resolved Hide resolved
book/listings/ch01-getting-started/listing02.mun Outdated Show resolved Hide resolved
book/src/ch01-02-hello-fibonacci.md Outdated Show resolved Hide resolved
book/src/ch01-03-hello-hot-reloading.md Outdated Show resolved Hide resolved
book/src/ch02-01-values-and-types.md Outdated Show resolved Hide resolved
crates/mun_mdbook_test_plugin/src/main.rs Outdated Show resolved Hide resolved
crates/mun_mdbook_test_plugin/src/main.rs Outdated Show resolved Hide resolved
crates/mun_mdbook_test_plugin/src/main.rs Outdated Show resolved Hide resolved
crates/mun_mdbook_test_plugin/src/main.rs Outdated Show resolved Hide resolved
crates/mun_mdbook_test_plugin/src/main.rs Outdated Show resolved Hide resolved
book/src/ch01-02-hello-fibonacci.md Outdated Show resolved Hide resolved
@@ -144,7 +150,10 @@ is specified too, as `-> i32`.
Whereas the last expression in a block implicitly becomes that blocks return
value, explicit `return` statements always return from the entire function:

```mun
```mun,ignore
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
```mun,ignore
```mun

Copy link
Collaborator

Choose a reason for hiding this comment

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

This should compile if you convert return bar + 3; into return 3;, I think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't it be a separate pr?

crates/mun_mdbook_test_plugin/src/main.rs Outdated Show resolved Hide resolved
crates/mun_mdbook_test_plugin/src/main.rs Outdated Show resolved Hide resolved
@Wodann Wodann merged commit 1c3b90e into mun-lang:master Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feat New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test Mun examples in the book
3 participants