-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Refine test specific dependencies #52477
Open
freemin7
wants to merge
5
commits into
JuliaLang:master
Choose a base branch
from
freemin7:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+24
−16
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c2189d1
Refine test specific dependencies
freemin7 652f8b0
Fix white spaces
freemin7 91f5f24
Update doc/src/tutorials/creating-packages.md
ViralBShah e27f6d8
Update doc/src/tutorials/creating-packages.md
ViralBShah b186ba1
Update doc/src/tutorials/creating-packages.md
ViralBShah 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 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 |
---|---|---|
|
@@ -275,13 +275,17 @@ test-specific dependencies, are available, see below. | |
|
||
### Test-specific dependencies | ||
|
||
There are two ways of adding test-specific dependencies (dependencies that are not dependencies of the package but will still be available to | ||
load when the package is tested). | ||
There are two ways of adding test-specific dependencies (dependencies that are not dependencies of the package but | ||
will still be available to load when the package is tested). If no `test/Project.toml` exists Pkg will default to | ||
using the `target` based test specific dependencies. | ||
|
||
#### `target` based test specific dependencies | ||
|
||
Using this method of adding test-specific dependencies, the packages are added under an `[extras]` section and to a test target, | ||
e.g. to add `Markdown` and `Test` as test dependencies, add the following to the `Project.toml` file: | ||
!!! compat | ||
This method of adding test-specific dependencies is supported for all Julia 1.x releases since v1.0. | ||
|
||
Using this method of adding test-specific dependencies, the packages are added under an `[extras]` section and to a test target. | ||
E.g. to add `Markdown` and `Test` as test dependencies, add the following to the projects `Project.toml` file: | ||
|
||
```toml | ||
[extras] | ||
|
@@ -292,22 +296,26 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | |
test = ["Markdown", "Test"] | ||
``` | ||
|
||
During testing the file `test/runtests.jl` will be executed with all dependencies from the `Project.toml` and the test dependencies | ||
loaded. This special dependency handling is done during a `Pkg.test` call and doesn't happen if `runtest.jl` is executed directly. | ||
|
||
Note that the only supported targets are `test` and `build`, the latter of which (not recommended) can be used | ||
for any `deps/build.jl` scripts. | ||
for any `deps/build.jl` scripts. This `target` based approach can't be used for other uses such as building | ||
documentation. | ||
|
||
#### Alternative approach: `test/Project.toml` file test specific dependencies | ||
|
||
!!! note | ||
The exact interaction between `Project.toml`, `test/Project.toml` and their corresponding | ||
`Manifest.toml`s are not fully worked out and may be subject to change in future versions. | ||
The older method of adding test-specific dependencies, described in the previous section, | ||
will therefore be supported throughout all Julia 1.X releases. | ||
|
||
In Julia 1.2 and later test dependencies can be declared in `test/Project.toml`. When running | ||
tests, Pkg will automatically merge this and the package Projects to create the test environment. | ||
!!! compat | ||
This method of adding test-specific dependencies is supported for all Julia 1.x releases since v1.2. | ||
|
||
Test dependencies can alternatively be declared in `test/Project.toml`. This is similar | ||
to `test/` being a project but when running tests, Pkg will automatically merge `test/Project.toml` | ||
and the `Project.toml` to create the test environment. | ||
|
||
!!! note | ||
If no `test/Project.toml` exists Pkg will use the `target` based test specific dependencies. | ||
!!! compat | ||
The exact interaction between `Project.toml`, `test/Project.toml` and their corresponding | ||
`Manifest.toml`s are not fully worked out and might not work as intended on older and | ||
especially unsupported Julia versions. | ||
|
||
To add a test-specific dependency, i.e. a dependency that is available only when testing, | ||
it is thus enough to add this dependency to the `test/Project.toml` project. This can be | ||
|
@@ -335,7 +343,7 @@ julia> write("test/runtests.jl", | |
@test 1 == 1 | ||
"""); | ||
|
||
(test) pkg> activate . | ||
(test) pkg> activate | ||
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. The removed does not appear to be "white spaces". |
||
|
||
(HelloWorld) pkg> test | ||
Testing HelloWorld | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect this
compat
notice after the explanation of what thetarget
method doesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is directly related to the decision what functionality to choose, i could see that compat block being useful before further explanations.
That said. I don't care.