Repository navigation
do-anything v0.1.0
English
This project was originally named test-anything and its command was ta. It
does more than test: one case can call an API, run a command-line program,
observe a log file and read a database, so the project is now do-anything, the
command is da, and the version starts again at 0.1.0.
Features
http.requestcalls an HTTP or HTTPS API and returnsstatus,headersand
body, parsed when the response is JSON.cli.runruns a command-line program without a shell and returnsexit_code,
stdout,stderrandjson, with a timeout.db.queryruns one read-only statement against SQLite (sqlite:path) or
PostgreSQL (postgres://) and returnscolumns,rows,row_countand
truncatedforexpectandsave. Writes and statement lists are refused at
two layers, and the database is never created.observe:declares read-only observers that run around every step; their
results appear underobserved.<name>before the assertions run and in
failure bundles. The built-inlog.filereports the lines a step added to a
log file.- A case can hold long-lived resources through a session contract: a plugin
declares its own type, implementsSession, and stores it under a kind it
chooses. The resource belongs to one case, is created on first use and is
closed when the case ends, including on failure and under--jobs; the core
knows no concrete session type. vars,save,--var name=valueand--vars-filesupply values, referenced
as${name}.${env:NAME}reads the environment, and every value read that
way is replaced with***in text and JSON output, error messages and failure
bundles.--jobs Nruns up to N cases at once. Results, output order, failure bundles
and exit codes are the same as a serial run.- Cases may declare
project,suite,layerandtags;da runselects
them with repeatable--project,--suite,--layer,--tagand
--skip-tag. equals,not_equals,containsandexistsassert on any JSONPath, and a
structural mistake in a case names its line and column.da lintvalidates cases without running them and reports every problem at
once;da schemaprints a JSON Schema of the case format with every
registered step.--output jsonwrites exactly one JSON object. Every case that does not pass
leaves a failure bundle withcase.yaml,report.jsonandmeta.json
(written last).
Renamed
- The package is
do-anything, the library isdo_anything, and the binary is
da. meta.jsoncarriesda_versioninstead ofta_version, and the case schema
title isda case file.- Failure bundles go to
.da/failuresby default, and.da/is ignored by git. - The install scripts read
DA_VERSION,DA_INSTALL_DIR,DA_DOWNLOAD_URLand
DA_NO_MODIFY_PATH. - Release archives are named
da-v<version>-<platform>, and releases start
again at v0.1.0.
Notes
- Each capability is behind a cargo feature:
http,cli,loganddb, all
enabled by default. Build a smaller binary with--no-default-featuresand
the features you need.
Install
Linux and macOS:
curl -fsSL https://raw.githubusercontent.com/LnYo-Cly/do-anything/main/install.sh | shWindows:
irm https://raw.githubusercontent.com/LnYo-Cly/do-anything/main/install.ps1 | iexOr download the archive for your platform below, extract it, and put da on
your PATH. Verify the download with SHA256SUMS.
| Platform | Archive |
|---|---|
| Linux x86_64 | da-v0.1.0-x86_64-unknown-linux-musl.tar.gz |
| Linux arm64 | da-v0.1.0-aarch64-unknown-linux-musl.tar.gz |
| macOS Intel | da-v0.1.0-x86_64-apple-darwin.tar.gz |
| macOS Apple silicon | da-v0.1.0-aarch64-apple-darwin.tar.gz |
| Windows x86_64 | da-v0.1.0-x86_64-pc-windows-msvc.zip |
| Windows arm64 | da-v0.1.0-aarch64-pc-windows-msvc.zip |
The binaries are not code-signed. On macOS, run xattr -d com.apple.quarantine da
if the system blocks a manually downloaded binary.
中文
本项目原名 test-anything,命令原为 ta。它不只做测试:一个用例可以同时调用接口、
运行命令行程序、观察日志文件并读取数据库,所以项目现在叫 do-anything,命令是 da,
版本从 0.1.0 重新开始。
功能
http.request调用 HTTP 或 HTTPS 接口,返回status、headers和body,
响应是 JSON 时自动解析。cli.run不经 shell 运行命令行程序,返回exit_code、stdout、stderr和
json,并支持超时。db.query对 SQLite(sqlite:路径)或 PostgreSQL(postgres://)执行一条只读
语句,返回columns、rows、row_count和truncated,可用于expect与
save。写语句和多条语句在两层被拒绝,数据库文件不会被创建。observe:声明只读观察者,在每个步骤前后运行;结果在断言之前并入
observed.<名字>,也写入失败包。内置的log.file报告步骤期间日志文件新增的行。- 用例可以通过会话契约持有长期资源:插件声明自己的类型、实现
Session,并以自己
选择的名字存放。资源属于单个用例,首次使用时创建,用例结束时关闭,失败路径和
--jobs下也一样;核心不知道任何具体会话类型。 vars、save、--var name=value和--vars-file提供变量,以${name}引用。
${env:NAME}读取环境变量,这样读到的值在文本与 JSON 输出、错误信息和失败包中
都替换为***。--jobs N同时运行最多 N 个用例;结果、输出顺序、失败包与退出码和串行一致。- 用例可以声明
project、suite、layer和tags,da run用可重复的
--project、--suite、--layer、--tag和--skip-tag选择要运行的部分。 equals、not_equals、contains和exists可断言任意 JSONPath;用例的结构性
错误会给出行号和列号。da lint不执行用例就完成校验,并一次报出所有问题;da schema输出用例格式的
JSON Schema,包含所有已注册的步骤。--output json只输出一个 JSON 对象。每个未通过的用例都会留下失败包,含
case.yaml、report.json和meta.json(最后写入)。
改名
- 包名为
do-anything,库名为do_anything,命令为da。 meta.json的字段ta_version改为da_version,用例 schema 的标题改为
da case file。- 失败包默认写入
.da/failures,.da/已被 git 忽略。 - 安装脚本读取
DA_VERSION、DA_INSTALL_DIR、DA_DOWNLOAD_URL和
DA_NO_MODIFY_PATH。 - 发布压缩包命名为
da-v<版本>-<平台>,版本从 v0.1.0 重新开始。
说明
- 每项能力各在一个 cargo feature 后面:
http、cli、log、db,默认全部开启。
需要更小的二进制时,用--no-default-features加上所需 feature 自行构建。
安装
Linux 与 macOS:
curl -fsSL https://raw.githubusercontent.com/LnYo-Cly/do-anything/main/install.sh | shWindows:
irm https://raw.githubusercontent.com/LnYo-Cly/do-anything/main/install.ps1 | iex或下载对应平台的压缩包,解压后把 da 放到 PATH 中。可用 SHA256SUMS 校验下载
文件。
| 平台 | 压缩包 |
|---|---|
| Linux x86_64 | da-v0.1.0-x86_64-unknown-linux-musl.tar.gz |
| Linux arm64 | da-v0.1.0-aarch64-unknown-linux-musl.tar.gz |
| macOS Intel | da-v0.1.0-x86_64-apple-darwin.tar.gz |
| macOS Apple silicon | da-v0.1.0-aarch64-apple-darwin.tar.gz |
| Windows x86_64 | da-v0.1.0-x86_64-pc-windows-msvc.zip |
| Windows arm64 | da-v0.1.0-aarch64-pc-windows-msvc.zip |
二进制文件没有代码签名。手动下载的二进制在 macOS 上被拦截时,执行
xattr -d com.apple.quarantine da。