-
Notifications
You must be signed in to change notification settings - Fork 28
How to test contributions #553
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
541be3d
Add "How to test contributions" in "How to contribute to Koma" docume…
Stockless 31050a1
Instructions less verbose
Stockless 8ac276e
How to add a new test
Stockless 77a596d
Redaction corrections
Stockless 9edc5fa
julia code block correction
Stockless 3584e18
Generate preview
Stockless 507b3d1
Corrected redaction according to review
Stockless 4465b11
Improve test-komamricore image resolution
Stockless a3e8c0f
Improved redaction based on review
Stockless 7144807
add space after images
Stockless 0d1f147
Remove unnecesary itemization
Stockless 3b6dc36
Remove CSS specification to generate space after image
Stockless 69cdfc3
Merge branch 'master' into docs-develop-env
cncastillo dc99907
Merge branch 'master' into docs-develop-env
cncastillo ae0bad1
fix tabulation errors
Stockless File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,6 +123,75 @@ Press Sync Changes to push your commit into your branch. | |
|
||
>💡 If you want to make sure if the commit was correctly done, check your GitHub repository and see if the changes you commited are present. | ||
|
||
## How to Test Your Contributions | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is capitalized, but other sections are not, please make consistent. |
||
|
||
In Koma, various tests are designed to verify the correctness of the current state of the code, including your contributions once incorporated. Depending on the package where you made your changes (`KomaMRIBase`, `KomaMRICore`, `KomaMRIFiles`, `KomaMRIPlots`) or directly to `KomaMRI`, you need to run the corresponding test as follows: | ||
cncastillo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
### Test `KomaMRI`: | ||
|
||
In the Julia REPL open the Julia package manager mode by pressing `]`, then run the following script: | ||
```julia | ||
activate .; test | ||
``` | ||
cncastillo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
### Test `KomaMRIBase`, `KomaMRIPlots`, `KomaMRIFiles`: | ||
|
||
There are two options to run the test: | ||
cncastillo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
- **Using VSCode**: On the activity bar, open the `Testing` extension, expand the available tests, and select the "▶" icon next to the respective package to run the test. The results will be displayed in the `Test Results` panel. | ||
|
||
>The `KomaMRI` test is not intended to be used this way, because the UI will not open correctly and the test will fail. | ||
cncastillo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
- **Using the Julia REPL**: Open the Julia package manager mode by pressing `]`, then run the following script: | ||
```julia | ||
activate .; test [package] | ||
``` | ||
with `[package]` being the selected package to be tested (`KomaMRIBase`, `KomaMRIPlots`, `KomaMRIFiles`). | ||
cncastillo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
### Test `KomaMRICore`: | ||
cncastillo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
In this package, you may want to test the use of GPU or multiple threads. For this reason, the recommended option to run the test is using the Julia REPL. However, if you want to run the test by default on the CPU with the number of threads set to `Threads.nthreads()`, you can also use VSCode. On the activity bar, open the `Testing` extension, expand the available tests, and select the "▶" icon next to the word `KomaMRICore` to run the test. The results will be displayed in the `Test Results` panel. | ||
cncastillo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
Using the Julia REPL, by default, tests are run on the CPU with the number of threads set to `Threads.nthreads()`. To run on a specific GPU backend, add the name of the backend package ("AMDGPU", "CUDA", "Metal", or "oneAPI") to the `test/Project.toml` file in `KomaMRICore` and pass the name as a test argument. | ||
cncastillo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
Example: | ||
```julia | ||
import Pkg | ||
Pkg.test("KomaMRICore"; test_args=["CUDA"]) | ||
``` | ||
To run on the CPU with a specific number of threads, pass the number of threads as a Julia argument. | ||
cncastillo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
Example: | ||
```julia | ||
import Pkg | ||
Pkg.test("KomaMRICore"; julia_args=`--threads=4`) | ||
``` | ||
cncastillo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
To change the default backend used for testing, modify the `[preferences.KomaMRICore]` section in the test/Project.toml file: | ||
|
||
```julia | ||
[preferences.KomaMRICore] | ||
test_backend = "CPU" | ||
``` | ||
cncastillo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
For the backend preference to take effect, you need to: | ||
|
||
- **REPL Testing**: No action needed. `] test` should pick up the preference immediately. | ||
- **VSCode Testing**: You need to restart VSCode. | ||
|
||
>Sadly, `LocalPreferences.toml` files are not picked up by VSCode (they could be `.gitignore`'d), so we put them into the `test/Project.toml` file instead. | ||
cncastillo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
If your contributions do not affect the correct execution of the code, the tests will return a message indicating that your changes have successfully passed. | ||
|
||
### Adding a new test | ||
|
||
In case your contribution generates a new function that is not currently tested, the code coverage will decrease when the pull request is analyzed, creating an automatic comment indicating the problem. To include this contribution in the tests, you must incorporate your function into the runtest.jl file corresponding to the package where you made your contribution. | ||
cncastillo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
To add this new test, you must follow these steps: | ||
|
||
1. In VSCode, press `Ctrl + p` to open the search bar and type `runtest.jl` to select the desired file according to the package. | ||
2. Once the file is selected, you will see the tests distributed in `@testitem` that contain `@testset`. Check if the contribution to test fulfills the conditions for an existing `@testitem`. If not, create a new `@testitem`. | ||
3. Open a `@testset` inside the `@testitem`, and create a small proof of concept that validates the contribution (use the surrounding `@testset` as a guide). | ||
4. To finish your test, add a `@test` macro followed by the verification of the proof of concept. This macro will pass the test if the boolean value of the result is true. | ||
cncastillo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
## How to create a pull request | ||
|
||
If you want to send your commited new version of the repository, you can create a pull request that will be reviewed by a Koma certified developer. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.