> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/port/di-10-zhang-ce-shi-port/10.2-yun-hang-make-test.md).

# 10.2.运行 make test

即使 Port 构建正常，确保软件正确执行其预期功能也是一个好主意。如果原始上游项目随软件一起提供了测试，最好运行这些测试并检查一切是否按预期工作。

Port 可以通过使用 `TEST_TARGET` 变量自动启用测试。设置该变量时，它包含 Port 的测试目标名称。通常为 `test`，但也可以是其他名称，例如 `tests`、`check`，或者在特定情况下类似 `run_tests.py` 之类的名称。

除了 `TEST_TARGET` 变量，框架还提供了以下变量来控制测试的执行：

* `TEST_WRKSRC` 是进行测试的目录。
* `TEST_ENV` 包含在测试阶段传递的附加变量。
* `TEST_ARGS` 包含传递给测试阶段的任何额外参数。

这些变量的使用示例可以在 [cad/xyce](https://cgit.freebsd.org/ports/tree/cad/xyce/)、[www/libjwt](https://cgit.freebsd.org/ports/tree/www/libjwt/) 等 Port 中找到。

> **注意**
>
> 请确保在更新 Port 时测试不会出现故障。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/port/di-10-zhang-ce-shi-port/10.2-yun-hang-make-test.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
