bash - 锻炼 Bash Track
问题描述
我正在 exercism.io 上尝试 bash 课程 https://exercism.io/my/solutions/8d68ead0c1ad4caabf25410806ade766
我已经安装了练习文件,安装了 bats,当我运行测试时:bats hello_world_test.sh
它输出和错误:
$ bats hello_world_test.sh
✗ Say Hi!
(in test file hello_world_test.sh, line 6)
`[ "$status" -eq 0 ]' failed
bats hello_world_test.sh 的代码是:
#!/usr/bin/env bash
@test "Say Hi!" {
run bash hello_world.sh
[ "$status" -eq 0 ]
[ "$output" = "Hello, World!" ]
}
解决方案
这一行告诉我们我们需要知道的一切:
run bash hello_world.sh
...您的hello_world_test.sh
脚本正在尝试执行名为hello_world.sh
. 该[ "$status" -eq 0 ]
行失败是因为 bash 返回了错误代码(很可能是因为hello_world.sh
脚本不存在)。您将需要创建此文件。
但是,仅仅创建脚本不足以使测试用例通过;它还期望输出“Hello, World!” 从这个脚本。我不会告诉你如何做到这一点,因为那样会破坏目标,但我会向你推荐一个应该让你启动并运行的HOW TO 。我鼓励您阅读整个指南,其中有很多很好的信息可供刚入门的人使用。这可能需要你尝试几次,但你会明白的:-)
推荐阅读
- deep-learning - 如何加载数据以及如何使用 pytorch 进行数据扩充
- sql - SQL语句如何将所有相关行(A,B)和(B,A)一起计算
- python - 使用 random.choice(range(128)) 找到一个创建特定数字序列的种子?
- c# - 命令 Console.Clear() 可以只清除控制台的特定部分
- javascript - 使用自定义数据自动填充 HTML 表单
- typo3 - 如何在 Typo3 9.5 上获取新闻的口语 URL
- docker - 未应用 ASPNETCORE_URLS(部署在 docker 容器中)
- excel - 在personal.xlsb中存储代码以从封闭的WB复制工作簿
- angular - [ng update]:错误 - 无法从工作区根目录解析“@angular-devkit/schematics”包
- reactjs - React-csv 在 react-bootstrap 下拉列表中不起作用