# 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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
