# 3.4.测试 port

确保 Port 规则完全符合预期，包括打包 Port。需要验证以下几个重要点：

* **pkg-plist** 中不应包含任何未由 Port 安装的文件。
* **pkg-plist** 中应包含 Port 安装的所有文件。
* 可以使用 `install` 目标安装 Port。这验证了安装脚本是否正确工作。
* 可以使用 `deinstall` 目标正确卸载 Port。这验证了卸载脚本是否正确工作。
* Port 仅在 `fetch` 目标阶段才能访问网络资源。这对于包构建器非常重要，比如 [ports-mgmt/poudriere](https://cgit.freebsd.org/ports/tree/ports-mgmt/poudriere/)。
* 确保 `make package` 可以作为普通用户运行（即，不是作为 `root`）。如果失败，软件可能需要打补丁。另请参见 [`fakeroot`](https://docs.freebsd.org/en/books/porters-handbook/uses/#uses-fakeroot) 和 [`uidfix`](https://docs.freebsd.org/en/books/porters-handbook/uses/#uses-uidfix)。

推荐的测试顺序：

1. `make stage`
2. `make stage-qa`
3. `make package`
4. `make install`
5. `make deinstall`
6. `make package`（作为用户）

确保所有阶段没有警告。

可以通过 [ports-mgmt/poudriere](https://cgit.freebsd.org/ports/tree/ports-mgmt/poudriere/) 进行彻底的自动化测试，详细信息请参见 [poudriere](https://docs.freebsd.org/en/books/porters-handbook/testing/#testing-poudriere)。它维护了 `jails`，可以在不影响主机系统状态的情况下测试上述所有步骤。


---

# 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-3-zhang-jian-dan-de-port/3.4.-ce-shi-port.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.
