如何让Julia在我的项目目录中创建./test/runtests.jl
如何让Julia终端自动生成./test/runtests.jl (我目前正在MacOS上使用Julia v1.2.0) 我所尝试的:如何让Julia在我的项目目录中创建./test/runtests.jl,julia,Julia,如何让Julia终端自动生成./test/runtests.jl (我目前正在MacOS上使用Julia v1.2.0) 我所尝试的: shell> ls Manifest.toml Project.toml src NewtonRootFinding.ipynb SecantRootFinding.ipynb shell> cat test/runtest.jl cat: test/runtest.jl: No such file or director
shell> ls
Manifest.toml Project.toml src
NewtonRootFinding.ipynb SecantRootFinding.ipynb
shell> cat test/runtest.jl
cat: test/runtest.jl: No such file or directory
(v1.2) pkg> status
Status `~/.julia/environments/v1.2/Project.toml`
[7073ff75] IJulia v1.20.0
[438e738f] PyCall v1.91.2
[d330b81b] PyPlot v2.8.2
(Prob1) pkg> activate ./test
Activating new environment at `~/..../Prob1/test/Project.toml`
shell> ls
Manifest.toml Project.toml src
NewtonRootFinding.ipynb SecantRootFinding.ipynb
(test) pkg> status
Status `~/.../Prob1/test/Project.toml`
(empty environment)
(test) pkg> add Test
Resolving package versions...
Updating `~/.../Prob1/test/Project.toml`
[8dfed614] + Test
Updating `~/.../Prob1/test/Manifest.toml`
[2a0f44e3] + Base64
[8ba89e20] + Distributed
[b77e0a4c] + InteractiveUtils
[56ddb016] + Logging
[d6f4376e] + Markdown
[9a3f8284] + Random
[9e88b42a] + Serialization
[6462fe0b] + Sockets
[8dfed614] + Test
(test) pkg> status
Status `~/.../test/Project.toml`
[8dfed614] Test
(test) pkg> activate .
Activating environment at `~/.../Prob1/Project.toml`
(Prob1) pkg> status
Project Prob1 v0.1.0
Status `~/.../Prob1/Project.toml`
[7073ff75] IJulia v1.20.0
[438e738f] PyCall v1.91.2
[d330b81b] PyPlot v2.8.2
[8dfed614] Test
(Prob1) pkg> activate ./test
Activating environment at `~/.../Prob1/test/Project.toml`
shell> cat test/runtests.jl
cat: test/runtests.jl: No such file or directory
shell> tree .
.
├── Manifest.toml
├── NewtonRootFinding.ipynb
├── Project.toml
├── SecantRootFinding.ipynb
├── src
│ └── Prob1.jl
└── test
├── Manifest.toml
└── Project.toml
在shell脚本中键入tree时,./test目录中没有runtests.jl Julia文件
我不知道为什么
我继续学习Julia教程:
但它没有起作用。@furas是正确的。您需要自己创建
/test/runtests.jl
文件。在软件包管理器中使用generate
命令时,它不是自动创建的 使用
最新版本的
但适用于所有版本的Julia
注
该软件包提供了一种非常简单、可重复和可定制的方式来为新软件包生成文件。我们建议您使用PkgTemplates来创建新包,而不是使用下面介绍的最小的pkg>generate
功能
据我猜测,几乎只有Julia开发者没有使用它,
是那些不知道的人。(希望这篇文章能有所帮助)
下面是一个非常简单的示例,其中包含一个简单的模板
using PkgTemplates;
template = Template(; user="oxinabox", dir=".");
generate("MyNewPackage", template);
查看它是否创建了一个runtests.jl
文件:
shell> ls ./MyNewPackage/test/
runtests.jl
它还设置git远程设备
但它可以做得更多。
我至少会:
- 包括作者和李森斯
- 打开TravisCI进行自动测试运行
- 设置工作服以报告覆盖率指标
- 设置Documenter.jl文档的页面; 因此,我倾向于使用以下内容:
我不使用Julia,但我认为它不会生成测试。你必须手动创建它。哦,所以我必须在IJulia笔记本上编写我自己的runtests.jl文件?还有一个问题,Julia文件(.jl)和Ipython笔记本文件(.ipynb)之间有什么区别。当我在Jupyter笔记本上启动IJulia并创建一个Julia项目时,它保存为xxxxxxx.ipynb而不是xxxxxxx.jlOMG,谢谢你让我知道!现在我可以生成测试模板了。顺便说一句,编写runtests.jl文件的语法是否与Julia notebook相同?在堆栈溢出时表示感谢的方法是按下upvote(可能还有accept)按钮:-)我不确定我是否理解您关于笔记本的问题,但最好将其作为单独的问题而不是评论来提问,然后您可以给出完整的细节。你也可能会想julia the JuliaLang slack:好的,谢谢,我已经对你的答案投了更高的票,但是由于stackoverflow的规定:“那些声誉低于15的人投的票会被记录下来,但不会改变公开显示的帖子分数。”所以我的投票不会公开显示。哦,哇,我不知道这也适用于你问的问题。很公平。
template = Template(;
user="myusername",
license="MIT",
authors=["Lyndon White"],
dir=".",
julia_version=v"1.0",
plugins=[
TravisCI(),
Coveralls(),
GitHubPages(),
],
)