Run test on fresh github downloaded package

I am trying to learn how to run tests. I was able to create MyProject, activate it, and run tests per the documentation. Now I would like to I download and test a package, like the DataFrames package.

First I git clone

Then I go to that directory and run julia repl. I enter package mode, ‘]’ and then activate .. My attempts to test DataFrames, test DataFrames.jl, test . all fail. Am I missing a build step?

I was able to add /Users/dbdavidson/dev/open_source/DataFrames.jl/ to an existing package, then import DataFrames, then test DataFrames but this requires creation of an additional package so I think there is likely an easier/better way.

What is the easiest way to download and then test github code package?

Can it all be done from the command line, with a one-liner, without entering julia repl?

In repl, after entering package mode via ]:

pkg> add DataFrames # check out and installs the latest version of Dataframes
# or
pkg> dev DataFrames # if you want to modify the code of DataFrames

pkg> test DataFrames # this builds and runs the tests

More on this here:

Ahh, so add . from within DataFrames.jl directory is not same as add DataFrames I guess. That worked, thanks.

Can this be scripted somehow? What I’m really wondering is how to write a script that uses code from the same module. The closest I’ve found is the suggestion to put scripts in the test folder. So if there is test/my_script.jl and there is library code in src/my_code.jl that it needs, how can I run my_script.jl with julia executable without entering the repl such that it finds the code? Ideally, there are any github examples of such a package would be great.

You can call functions of Pkg module, like Pkg.add() or Pkg.activate(). It is quite well documented here and here

If both src/my_code.jl and test/my_script.jl belong to the same package, and that package has the appropriate environment specification (Project.toml and Manifest.toml), then you could simply put Pkg.activate("..") at the top of test/my_script.jl. Or, if you don’t want to pollute the test code, you could just go pkg> dev path/to/my_my_module once.

In either case, at the top of test/my_script.jl you need to add the using my_module line. Again, it it all there in the docs.