-
-
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
Add the ability to install test dependencies and run tests to Pkg #6191
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d42df63
Add the ability to install test dependencies and run tests to Pkg
burrowsa e06ad49
make test a named argument in Reqs.parse
burrowsa b1b5844
use test/REQUIRE and test/runtests.jl as discussed in pull request
burrowsa 90d4036
Update docs and clean up test dependencies after running tests
burrowsa 530e17a
Make sure tests will work after #6205
burrowsa 80cb5ee
replace tabs with spaces
burrowsa 21588c7
remove using Base.Test
burrowsa 7e6671d
move clean-up resolve() into test!
burrowsa 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
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
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
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 |
---|---|---|
@@ -1,15 +1,71 @@ | ||
ENV["JULIA_PKGDIR"] = string("tmp.",randstring()) | ||
@test !isdir(Pkg.dir()) | ||
try # ensure directory removal | ||
Pkg.init() | ||
@test isdir(Pkg.dir()) | ||
Pkg.resolve() | ||
function temp_pkg_dir(fn::Function) | ||
# Used in tests below to setup and teardown a sandboxed package directory | ||
const tmpdir = ENV["JULIA_PKGDIR"] = string("tmp.",randstring()) | ||
@test !isdir(Pkg.dir()) | ||
try | ||
Pkg.init() | ||
@test isdir(Pkg.dir()) | ||
Pkg.resolve() | ||
|
||
fn() | ||
finally | ||
run(`rm -rf $tmpdir`) | ||
end | ||
end | ||
|
||
# Test adding a removing a package | ||
temp_pkg_dir() do | ||
@test isempty(Pkg.installed()) | ||
Pkg.add("Example") | ||
@test [keys(Pkg.installed())...] == ["Example"] | ||
Pkg.rm("Example") | ||
@test isempty(Pkg.installed()) | ||
finally | ||
run(`rm -rf $(Pkg.dir())`) | ||
end | ||
|
||
# testing a package with @test dependencies causes them to be installed | ||
temp_pkg_dir() do | ||
Pkg.generate("PackageWithTestDependencies", "MIT") | ||
@test [keys(Pkg.installed())...] == ["PackageWithTestDependencies"] | ||
|
||
open(Pkg.dir("PackageWithTestDependencies","REQUIRE"),"a") do f | ||
println(f,"@test Example") | ||
end | ||
|
||
open(Pkg.dir("PackageWithTestDependencies","run_tests.jl"),"w") do f | ||
println(f,"") | ||
end | ||
|
||
Pkg.resolve() | ||
@test [keys(Pkg.installed())...] == ["PackageWithTestDependencies"] | ||
|
||
Pkg.test("PackageWithTestDependencies") | ||
@test sort([keys(Pkg.installed())...]) == sort(["PackageWithTestDependencies", "Example"]) | ||
end | ||
|
||
# testing a package with no run_test.jl errors | ||
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.
|
||
temp_pkg_dir() do | ||
Pkg.generate("PackageWithNoTests", "MIT") | ||
|
||
try | ||
Pkg.test("PackageWithNoTests") | ||
catch err | ||
@test err.msg == "PackageWithNoTests did not provide a run_test.jl file" | ||
end | ||
end | ||
|
||
# testing a package with failing tests errors | ||
temp_pkg_dir() do | ||
Pkg.generate("PackageWithFailingTests", "MIT") | ||
|
||
open(Pkg.dir("PackageWithFailingTests","run_tests.jl"),"w") do f | ||
println(f,"using Base.Test") | ||
println(f,"@test false") | ||
end | ||
|
||
try | ||
Pkg.test("PackageWithFailingTests") | ||
catch err | ||
@test err.msg == "PackageWithFailingTests had test errors" | ||
end | ||
end | ||
|
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 think this would do better as a keyword argument. It is not obvious what
parse(lines, true)
means, butparse(lines, test=true)
makes it obvious.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 agree and will change this