在我的货物项目中,我定义了两个二进制目标。如何从集成测试中访问在二进制文件中定义的函数?
我尝试使用
[package]
name = "passman"
version = "0.1.0"
edition = "2018"
[[bin]]
name = "passmand"
path = "src/daemon/main.rs"
[[bin]]
name = "passman"
path = "src/cli/main.rs"
.
├── Cargo.lock
├── Cargo.toml
├── README.md
├── src
│ ├── cli
│ │ ├── argument
│ │ │ └── mod.rs
│ │ └── main.rs
│ └── daemon
│ ├── entry_value.rs
│ ├── main.rs
│ ├── passman_crypto.rs
│ ├── passman.service
│ └── password_file.rs <- i want to access functions defined in this
└── tests
├── password_file_tests.rs <- this is my integration test
└── test.py
我尝试使用
extern crate passmand;
访问文件,但Cargo只是抱怨: --> tests/password_file_tests.rs:6:1
|
6 | extern crate passmand;
| ^^^^^^^^^^^^^^^^^^^^^^ can't find crate
passmand
不是一个crate,它是你的crate中的一个二进制文件。此外,你无论如何都不能将仅限于二进制的crate用作库。 - undefined[lib]
部分,并在那里定义常用函数。 - undefinedpassmand
是一个 crate,但它是一个二进制 crate,所以不能使用extern crate
导入。 - undefined