| 1 |
//! To speed up the tests, they are tests all collected in a single module |
| 2 |
|
| 3 |
use common::{ |
| 4 |
develop, errors, handle_result, integration, other, test_python_implementation, |
| 5 |
TestInstallBackend, |
| 6 |
}; |
| 7 |
use expect_test::expect; |
| 8 |
use maturin::pyproject_toml::SdistGenerator; |
| 9 |
use rstest::rstest; |
| 10 |
use std::env; |
| 11 |
use std::path::Path; |
| 12 |
use std::time::Duration; |
| 13 |
use time::macros::datetime; |
| 14 |
use which::which; |
| 15 |
|
| 16 |
mod common; |
| 17 |
|
| 18 |
#[test] |
| 19 |
fn develop_pyo3_pure() { |
| 20 |
handle_result(develop::test_develop( |
| 21 |
"test-crates/pyo3-pure", |
| 22 |
None, |
| 23 |
"develop-pyo3-pure", |
| 24 |
false, |
| 25 |
TestInstallBackend::Pip, |
| 26 |
)); |
| 27 |
} |
| 28 |
|
| 29 |
#[test] |
| 30 |
fn develop_pyo3_pure_conda() { |
| 31 |
if which("conda").is_ok() { |
| 32 |
handle_result(develop::test_develop( |
| 33 |
"test-crates/pyo3-pure", |
| 34 |
None, |
| 35 |
"develop-pyo3-pure-conda", |
| 36 |
true, |
| 37 |
TestInstallBackend::Pip, |
| 38 |
)); |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
#[test] |
| 43 |
fn develop_pyo3_mixed() { |
| 44 |
handle_result(develop::test_develop( |
| 45 |
"test-crates/pyo3-mixed", |
| 46 |
None, |
| 47 |
"develop-pyo3-mixed", |
| 48 |
false, |
| 49 |
TestInstallBackend::Pip, |
| 50 |
)); |
| 51 |
} |
| 52 |
|
| 53 |
#[test] |
| 54 |
fn develop_pyo3_mixed_include_exclude() { |
| 55 |
handle_result(develop::test_develop( |
| 56 |
"test-crates/pyo3-mixed-include-exclude", |
| 57 |
None, |
| 58 |
"develop-pyo3-mixed-include-exclude", |
| 59 |
false, |
| 60 |
TestInstallBackend::Pip, |
| 61 |
)); |
| 62 |
} |
| 63 |
|
| 64 |
#[test] |
| 65 |
fn develop_pyo3_mixed_submodule() { |
| 66 |
handle_result(develop::test_develop( |
| 67 |
"test-crates/pyo3-mixed-submodule", |
| 68 |
None, |
| 69 |
"develop-pyo3-mixed-submodule", |
| 70 |
false, |
| 71 |
TestInstallBackend::Pip, |
| 72 |
)); |
| 73 |
} |
| 74 |
|
| 75 |
#[test] |
| 76 |
fn develop_pyo3_mixed_with_path_dep() { |
| 77 |
handle_result(develop::test_develop( |
| 78 |
"test-crates/pyo3-mixed-with-path-dep", |
| 79 |
None, |
| 80 |
"develop-pyo3-mixed-with-path-dep", |
| 81 |
false, |
| 82 |
TestInstallBackend::Pip, |
| 83 |
)); |
| 84 |
} |
| 85 |
|
| 86 |
#[test] |
| 87 |
fn develop_pyo3_mixed_implicit() { |
| 88 |
handle_result(develop::test_develop( |
| 89 |
"test-crates/pyo3-mixed-implicit", |
| 90 |
None, |
| 91 |
"develop-pyo3-mixed-implicit", |
| 92 |
false, |
| 93 |
TestInstallBackend::Pip, |
| 94 |
)); |
| 95 |
} |
| 96 |
|
| 97 |
#[test] |
| 98 |
fn develop_pyo3_mixed_py_subdir() { |
| 99 |
handle_result(develop::test_develop( |
| 100 |
"test-crates/pyo3-mixed-py-subdir", |
| 101 |
None, |
| 102 |
"develop-pyo3-mixed-py-subdir", |
| 103 |
false, |
| 104 |
TestInstallBackend::Pip, |
| 105 |
)); |
| 106 |
} |
| 107 |
|
| 108 |
#[test] |
| 109 |
fn develop_pyo3_mixed_src_layout() { |
| 110 |
handle_result(develop::test_develop( |
| 111 |
"test-crates/pyo3-mixed-src/rust", |
| 112 |
None, |
| 113 |
"develop-pyo3-mixed-src", |
| 114 |
false, |
| 115 |
TestInstallBackend::Pip, |
| 116 |
)); |
| 117 |
} |
| 118 |
|
| 119 |
#[test] |
| 120 |
fn develop_cffi_pure() { |
| 121 |
let python_implementation = test_python_implementation().unwrap(); |
| 122 |
if env::var("GITHUB_ACTIONS").is_ok() && python_implementation == "pypy" { |
| 123 |
// TODO: PyPy hangs on cffi test sometimes |
| 124 |
return; |
| 125 |
} |
| 126 |
handle_result(develop::test_develop( |
| 127 |
"test-crates/cffi-pure", |
| 128 |
None, |
| 129 |
"develop-cffi-pure", |
| 130 |
false, |
| 131 |
TestInstallBackend::Pip, |
| 132 |
)); |
| 133 |
} |
| 134 |
|
| 135 |
#[test] |
| 136 |
fn develop_cffi_mixed() { |
| 137 |
let python_implementation = test_python_implementation().unwrap(); |
| 138 |
if env::var("GITHUB_ACTIONS").is_ok() && python_implementation == "pypy" { |
| 139 |
// PyPy hangs on cffi test sometimes |
| 140 |
return; |
| 141 |
} |
| 142 |
handle_result(develop::test_develop( |
| 143 |
"test-crates/cffi-mixed", |
| 144 |
None, |
| 145 |
"develop-cffi-mixed", |
| 146 |
false, |
| 147 |
TestInstallBackend::Pip, |
| 148 |
)); |
| 149 |
} |
| 150 |
|
| 151 |
#[test] |
| 152 |
fn develop_uniffi_pure() { |
| 153 |
if env::var("GITHUB_ACTIONS").is_ok() || which("uniffi-bindgen").is_ok() { |
| 154 |
handle_result(develop::test_develop( |
| 155 |
"test-crates/uniffi-pure", |
| 156 |
None, |
| 157 |
"develop-uniffi-pure", |
| 158 |
false, |
| 159 |
TestInstallBackend::Pip, |
| 160 |
)); |
| 161 |
} |
| 162 |
} |
| 163 |
|
| 164 |
#[test] |
| 165 |
fn develop_uniffi_pure_proc_macro() { |
| 166 |
handle_result(develop::test_develop( |
| 167 |
"test-crates/uniffi-pure-proc-macro", |
| 168 |
None, |
| 169 |
"develop-uniffi-pure-proc-macro", |
| 170 |
false, |
| 171 |
TestInstallBackend::Pip, |
| 172 |
)); |
| 173 |
} |
| 174 |
|
| 175 |
#[test] |
| 176 |
fn develop_uniffi_mixed() { |
| 177 |
if env::var("GITHUB_ACTIONS").is_ok() || which("uniffi-bindgen").is_ok() { |
| 178 |
handle_result(develop::test_develop( |
| 179 |
"test-crates/uniffi-mixed", |
| 180 |
None, |
| 181 |
"develop-uniffi-mixed", |
| 182 |
false, |
| 183 |
TestInstallBackend::Pip, |
| 184 |
)); |
| 185 |
} |
| 186 |
} |
| 187 |
|
| 188 |
#[test] |
| 189 |
fn develop_uniffi_multiple_binding_files() { |
| 190 |
if env::var("GITHUB_ACTIONS").is_ok() || which("uniffi-bindgen").is_ok() { |
| 191 |
handle_result(develop::test_develop( |
| 192 |
"test-crates/uniffi-multiple-binding-files", |
| 193 |
None, |
| 194 |
"develop-uniffi-multiple-binding-files", |
| 195 |
false, |
| 196 |
TestInstallBackend::Pip, |
| 197 |
)); |
| 198 |
} |
| 199 |
} |
| 200 |
|
| 201 |
#[rstest] |
| 202 |
#[timeout(Duration::from_secs(60))] |
| 203 |
#[case(TestInstallBackend::Pip, "pip")] |
| 204 |
#[case(TestInstallBackend::Uv, "uv")] |
| 205 |
#[test] |
| 206 |
fn develop_hello_world(#[case] backend: TestInstallBackend, #[case] name: &str) { |
| 207 |
// Only run uv tests on platforms that has wheel on PyPI or when uv binary is found |
| 208 |
if matches!(backend, TestInstallBackend::Uv) |
| 209 |
&& !cfg!(any( |
| 210 |
target_os = "linux", |
| 211 |
target_os = "macos", |
| 212 |
target_os = "windows" |
| 213 |
)) |
| 214 |
&& which("uv").is_err() |
| 215 |
{ |
| 216 |
return; |
| 217 |
} |
| 218 |
|
| 219 |
handle_result(develop::test_develop( |
| 220 |
"test-crates/hello-world", |
| 221 |
None, |
| 222 |
format!("develop-hello-world-{name}").as_str(), |
| 223 |
false, |
| 224 |
backend, |
| 225 |
)); |
| 226 |
} |
| 227 |
|
| 228 |
#[rstest] |
| 229 |
#[timeout(Duration::from_secs(120))] |
| 230 |
#[case(TestInstallBackend::Pip, "pip")] |
| 231 |
#[case(TestInstallBackend::Uv, "uv")] |
| 232 |
#[test] |
| 233 |
fn develop_pyo3_ffi_pure(#[case] backend: TestInstallBackend, #[case] name: &str) { |
| 234 |
// Only run uv tests on platforms that has wheel on PyPI or when uv binary is found |
| 235 |
if matches!(backend, TestInstallBackend::Uv) |
| 236 |
&& !cfg!(any( |
| 237 |
target_os = "linux", |
| 238 |
target_os = "macos", |
| 239 |
target_os = "windows" |
| 240 |
)) |
| 241 |
&& which("uv").is_err() |
| 242 |
{ |
| 243 |
return; |
| 244 |
} |
| 245 |
|
| 246 |
handle_result(develop::test_develop( |
| 247 |
"test-crates/pyo3-ffi-pure", |
| 248 |
None, |
| 249 |
format!("develop-pyo3-ffi-pure-{name}").as_str(), |
| 250 |
false, |
| 251 |
backend, |
| 252 |
)); |
| 253 |
} |
| 254 |
|
| 255 |
#[test] |
| 256 |
fn integration_pyo3_bin() { |
| 257 |
let python_implementation = test_python_implementation().unwrap(); |
| 258 |
if python_implementation == "pypy" || python_implementation == "graalpy" { |
| 259 |
// PyPy & GraalPy do not support the 'auto-initialize' feature of pyo3 |
| 260 |
return; |
| 261 |
} |
| 262 |
|
| 263 |
handle_result(integration::test_integration( |
| 264 |
"test-crates/pyo3-bin", |
| 265 |
None, |
| 266 |
"integration-pyo3-bin", |
| 267 |
false, |
| 268 |
None, |
| 269 |
)); |
| 270 |
} |
| 271 |
|
| 272 |
#[test] |
| 273 |
fn integration_pyo3_pure() { |
| 274 |
handle_result(integration::test_integration( |
| 275 |
"test-crates/pyo3-pure", |
| 276 |
None, |
| 277 |
"integration-pyo3-pure", |
| 278 |
false, |
| 279 |
None, |
| 280 |
)); |
| 281 |
} |
| 282 |
|
| 283 |
#[test] |
| 284 |
fn integration_pyo3_mixed() { |
| 285 |
handle_result(integration::test_integration( |
| 286 |
"test-crates/pyo3-mixed", |
| 287 |
None, |
| 288 |
"integration-pyo3-mixed", |
| 289 |
false, |
| 290 |
None, |
| 291 |
)); |
| 292 |
} |
| 293 |
|
| 294 |
#[test] |
| 295 |
fn integration_pyo3_mixed_include_exclude() { |
| 296 |
handle_result(integration::test_integration( |
| 297 |
"test-crates/pyo3-mixed-include-exclude", |
| 298 |
None, |
| 299 |
"integration-pyo3-mixed-include-exclude", |
| 300 |
false, |
| 301 |
None, |
| 302 |
)); |
| 303 |
} |
| 304 |
|
| 305 |
#[test] |
| 306 |
fn integration_pyo3_mixed_submodule() { |
| 307 |
handle_result(integration::test_integration( |
| 308 |
"test-crates/pyo3-mixed-submodule", |
| 309 |
None, |
| 310 |
"integration-pyo3-mixed-submodule", |
| 311 |
false, |
| 312 |
None, |
| 313 |
)); |
| 314 |
} |
| 315 |
|
| 316 |
#[test] |
| 317 |
fn integration_pyo3_mixed_with_path_dep() { |
| 318 |
handle_result(integration::test_integration( |
| 319 |
"test-crates/pyo3-mixed-with-path-dep", |
| 320 |
None, |
| 321 |
"integration-pyo3-mixed-with-path-dep", |
| 322 |
false, |
| 323 |
None, |
| 324 |
)); |
| 325 |
} |
| 326 |
|
| 327 |
#[test] |
| 328 |
fn integration_pyo3_mixed_implicit() { |
| 329 |
handle_result(integration::test_integration( |
| 330 |
"test-crates/pyo3-mixed-implicit", |
| 331 |
None, |
| 332 |
"integration-pyo3-mixed-implicit", |
| 333 |
false, |
| 334 |
None, |
| 335 |
)); |
| 336 |
} |
| 337 |
|
| 338 |
#[test] |
| 339 |
fn integration_pyo3_mixed_py_subdir() { |
| 340 |
handle_result(integration::test_integration( |
| 341 |
"test-crates/pyo3-mixed-py-subdir", |
| 342 |
None, |
| 343 |
"integration-pyo3-mixed-py-subdir", |
| 344 |
cfg!(unix), |
| 345 |
None, |
| 346 |
)); |
| 347 |
} |
| 348 |
|
| 349 |
#[test] |
| 350 |
fn integration_pyo3_mixed_src_layout() { |
| 351 |
handle_result(integration::test_integration( |
| 352 |
"test-crates/pyo3-mixed-src/rust", |
| 353 |
None, |
| 354 |
"integration-pyo3-mixed-src", |
| 355 |
false, |
| 356 |
None, |
| 357 |
)); |
| 358 |
} |
| 359 |
|
| 360 |
#[test] |
| 361 |
#[cfg_attr(target_os = "macos", ignore)] // Don't run it on macOS, too slow |
| 362 |
fn integration_pyo3_pure_conda() { |
| 363 |
if which("conda").is_ok() { |
| 364 |
handle_result(integration::test_integration_conda( |
| 365 |
"test-crates/pyo3-mixed", |
| 366 |
None, |
| 367 |
)); |
| 368 |
} |
| 369 |
} |
| 370 |
|
| 371 |
#[test] |
| 372 |
fn integration_cffi_pure() { |
| 373 |
let python_implementation = test_python_implementation().unwrap(); |
| 374 |
if env::var("GITHUB_ACTIONS").is_ok() && python_implementation == "pypy" { |
| 375 |
// PyPy hangs on cffi test sometimes |
| 376 |
return; |
| 377 |
} |
| 378 |
handle_result(integration::test_integration( |
| 379 |
"test-crates/cffi-pure", |
| 380 |
None, |
| 381 |
"integration-cffi-pure", |
| 382 |
false, |
| 383 |
None, |
| 384 |
)); |
| 385 |
} |
| 386 |
|
| 387 |
#[test] |
| 388 |
fn integration_cffi_mixed() { |
| 389 |
let python_implementation = test_python_implementation().unwrap(); |
| 390 |
if env::var("GITHUB_ACTIONS").is_ok() && python_implementation == "pypy" { |
| 391 |
// PyPy hangs on cffi test sometimes |
| 392 |
return; |
| 393 |
} |
| 394 |
handle_result(integration::test_integration( |
| 395 |
"test-crates/cffi-mixed", |
| 396 |
None, |
| 397 |
"integration-cffi-mixed", |
| 398 |
false, |
| 399 |
None, |
| 400 |
)); |
| 401 |
} |
| 402 |
|
| 403 |
#[test] |
| 404 |
fn integration_uniffi_pure() { |
| 405 |
if env::var("GITHUB_ACTIONS").is_ok() || which("uniffi-bindgen").is_ok() { |
| 406 |
handle_result(integration::test_integration( |
| 407 |
"test-crates/uniffi-pure", |
| 408 |
None, |
| 409 |
"integration-uniffi-pure", |
| 410 |
false, |
| 411 |
None, |
| 412 |
)); |
| 413 |
} |
| 414 |
} |
| 415 |
|
| 416 |
#[test] |
| 417 |
fn integration_uniffi_pure_proc_macro() { |
| 418 |
handle_result(integration::test_integration( |
| 419 |
"test-crates/uniffi-pure-proc-macro", |
| 420 |
None, |
| 421 |
"integration-uniffi-pure-proc-macro", |
| 422 |
false, |
| 423 |
None, |
| 424 |
)); |
| 425 |
} |
| 426 |
|
| 427 |
#[test] |
| 428 |
fn integration_uniffi_mixed() { |
| 429 |
if env::var("GITHUB_ACTIONS").is_ok() || which("uniffi-bindgen").is_ok() { |
| 430 |
handle_result(integration::test_integration( |
| 431 |
"test-crates/uniffi-mixed", |
| 432 |
None, |
| 433 |
"integration-uniffi-mixed", |
| 434 |
false, |
| 435 |
None, |
| 436 |
)); |
| 437 |
} |
| 438 |
} |
| 439 |
|
| 440 |
#[test] |
| 441 |
fn integration_hello_world() { |
| 442 |
handle_result(integration::test_integration( |
| 443 |
"test-crates/hello-world", |
| 444 |
None, |
| 445 |
"integration-hello-world", |
| 446 |
false, |
| 447 |
None, |
| 448 |
)); |
| 449 |
} |
| 450 |
|
| 451 |
#[test] |
| 452 |
fn integration_pyo3_ffi_pure() { |
| 453 |
handle_result(integration::test_integration( |
| 454 |
"test-crates/pyo3-ffi-pure", |
| 455 |
None, |
| 456 |
"integration-pyo3-ffi-pure", |
| 457 |
false, |
| 458 |
None, |
| 459 |
)); |
| 460 |
} |
| 461 |
|
| 462 |
#[test] |
| 463 |
fn integration_with_data() { |
| 464 |
handle_result(integration::test_integration( |
| 465 |
"test-crates/with-data", |
| 466 |
None, |
| 467 |
"integration-with-data", |
| 468 |
false, |
| 469 |
None, |
| 470 |
)); |
| 471 |
} |
| 472 |
|
| 473 |
#[test] |
| 474 |
fn integration_readme_duplication() { |
| 475 |
handle_result(integration::test_integration( |
| 476 |
"test-crates/readme-duplication/readme-py", |
| 477 |
None, |
| 478 |
"integration-readme-duplication", |
| 479 |
false, |
| 480 |
None, |
| 481 |
)); |
| 482 |
} |
| 483 |
|
| 484 |
#[test] |
| 485 |
fn integration_workspace_inverted_order() { |
| 486 |
handle_result(integration::test_integration( |
| 487 |
"test-crates/workspace-inverted-order/path-dep-with-root", |
| 488 |
None, |
| 489 |
"integration-workspace-inverted-order", |
| 490 |
false, |
| 491 |
None, |
| 492 |
)); |
| 493 |
} |
| 494 |
|
| 495 |
#[test] |
| 496 |
// Sourced from https://pypi.org/project/wasmtime/11.0.0/#files |
| 497 |
// update with wasmtime updates |
| 498 |
#[cfg(any( |
| 499 |
all(target_os = "windows", target_arch = "x86_64"), |
| 500 |
all( |
| 501 |
target_os = "linux", |
| 502 |
any(target_arch = "x86_64", target_arch = "aarch64"), |
| 503 |
target_env = "gnu", |
| 504 |
), |
| 505 |
all( |
| 506 |
target_os = "macos", |
| 507 |
any(target_arch = "x86_64", target_arch = "aarch64") |
| 508 |
), |
| 509 |
))] |
| 510 |
fn integration_wasm_hello_world() { |
| 511 |
use std::path::Path; |
| 512 |
|
| 513 |
handle_result(integration::test_integration( |
| 514 |
"test-crates/hello-world", |
| 515 |
None, |
| 516 |
"integration-wasm-hello-world", |
| 517 |
false, |
| 518 |
Some("wasm32-wasip1"), |
| 519 |
)); |
| 520 |
|
| 521 |
let python_implementation = test_python_implementation().unwrap(); |
| 522 |
let venv_name = |
| 523 |
format!("integration-wasm-hello-world-py3-wasm32-wasip1-{python_implementation}"); |
| 524 |
|
| 525 |
// Make sure we're actually running wasm |
| 526 |
assert!(Path::new("test-crates") |
| 527 |
.join("venvs") |
| 528 |
.join(venv_name) |
| 529 |
.join(if cfg!(target_os = "windows") { |
| 530 |
"Scripts" |
| 531 |
} else { |
| 532 |
"bin" |
| 533 |
}) |
| 534 |
.join("hello-world.wasm") |
| 535 |
.is_file()) |
| 536 |
} |
| 537 |
|
| 538 |
#[test] |
| 539 |
fn abi3_without_version() { |
| 540 |
handle_result(other::abi3_without_version()) |
| 541 |
} |
| 542 |
|
| 543 |
#[test] |
| 544 |
// Only run this test on platforms that has manylinux support |
| 545 |
#[cfg_attr( |
| 546 |
not(all( |
| 547 |
target_os = "linux", |
| 548 |
target_env = "gnu", |
| 549 |
any( |
| 550 |
target_arch = "x86", |
| 551 |
target_arch = "x86_64", |
| 552 |
target_arch = "aarch64", |
| 553 |
target_arch = "powerpc64", |
| 554 |
target_arch = "s390x", |
| 555 |
target_arch = "arm" |
| 556 |
) |
| 557 |
)), |
| 558 |
ignore |
| 559 |
)] |
| 560 |
fn pyo3_no_extension_module() { |
| 561 |
let python_implementation = test_python_implementation().unwrap(); |
| 562 |
if python_implementation == "cpython" { |
| 563 |
handle_result(errors::pyo3_no_extension_module()) |
| 564 |
} |
| 565 |
} |
| 566 |
|
| 567 |
#[test] |
| 568 |
fn locked_doesnt_build_without_cargo_lock() { |
| 569 |
handle_result(errors::locked_doesnt_build_without_cargo_lock()) |
| 570 |
} |
| 571 |
|
| 572 |
#[test] |
| 573 |
#[cfg_attr(not(all(target_os = "linux", target_env = "gnu")), ignore)] |
| 574 |
fn invalid_manylinux_does_not_panic() { |
| 575 |
handle_result(errors::invalid_manylinux_does_not_panic()) |
| 576 |
} |
| 577 |
|
| 578 |
#[test] |
| 579 |
fn warn_on_missing_python_source() { |
| 580 |
handle_result(errors::warn_on_missing_python_source()) |
| 581 |
} |
| 582 |
|
| 583 |
#[test] |
| 584 |
fn pypi_compatibility_unsupported_target() { |
| 585 |
handle_result(errors::pypi_compatibility_unsupported_target()) |
| 586 |
} |
| 587 |
|
| 588 |
#[test] |
| 589 |
fn pypi_compatibility_mixed_tags() { |
| 590 |
handle_result(errors::pypi_compatibility_mixed_tags()) |
| 591 |
} |
| 592 |
|
| 593 |
#[test] |
| 594 |
#[cfg_attr(not(target_os = "linux"), ignore)] |
| 595 |
fn musl() { |
| 596 |
let ran = handle_result(other::test_musl()); |
| 597 |
if !ran { |
| 598 |
eprintln!("⚠️ Warning: rustup and/or musl target not installed, test didn't run"); |
| 599 |
} |
| 600 |
} |
| 601 |
|
| 602 |
#[test] |
| 603 |
fn workspace_cargo_lock() { |
| 604 |
handle_result(other::test_workspace_cargo_lock()) |
| 605 |
} |
| 606 |
|
| 607 |
#[test] |
| 608 |
fn workspace_members_beneath_pyproject_sdist() { |
| 609 |
let cargo_toml = expect![[r#" |
| 610 |
[workspace] |
| 611 |
resolver = "2" |
| 612 |
members = ["pyo3-mixed-workspace", "python/pyo3-mixed-workspace-py"] |
| 613 |
"#]]; |
| 614 |
handle_result(other::test_source_distribution( |
| 615 |
"test-crates/pyo3-mixed-workspace/rust/python/pyo3-mixed-workspace-py", |
| 616 |
SdistGenerator::Cargo, |
| 617 |
expect![[r#" |
| 618 |
{ |
| 619 |
"pyo3_mixed_workspace-2.1.3/PKG-INFO", |
| 620 |
"pyo3_mixed_workspace-2.1.3/pyproject.toml", |
| 621 |
"pyo3_mixed_workspace-2.1.3/rust/Cargo.lock", |
| 622 |
"pyo3_mixed_workspace-2.1.3/rust/Cargo.toml", |
| 623 |
"pyo3_mixed_workspace-2.1.3/rust/pyo3-mixed-workspace/Cargo.toml", |
| 624 |
"pyo3_mixed_workspace-2.1.3/rust/pyo3-mixed-workspace/src/lib.rs", |
| 625 |
"pyo3_mixed_workspace-2.1.3/rust/python/pyo3-mixed-workspace-py/Cargo.toml", |
| 626 |
"pyo3_mixed_workspace-2.1.3/rust/python/pyo3-mixed-workspace-py/src/lib.rs", |
| 627 |
"pyo3_mixed_workspace-2.1.3/src/pyo3_mixed_workspace/__init__.py", |
| 628 |
"pyo3_mixed_workspace-2.1.3/src/pyo3_mixed_workspace/python_module/__init__.py", |
| 629 |
"pyo3_mixed_workspace-2.1.3/src/pyo3_mixed_workspace/python_module/double.py", |
| 630 |
"pyo3_mixed_workspace-2.1.3/src/tests/test_pyo3_mixed.py", |
| 631 |
} |
| 632 |
"#]], |
| 633 |
Some(( |
| 634 |
Path::new("pyo3_mixed_workspace-2.1.3/rust/Cargo.toml"), |
| 635 |
cargo_toml, |
| 636 |
)), |
| 637 |
"sdist-workspace-members-beneath_pyproject", |
| 638 |
)) |
| 639 |
} |
| 640 |
|
| 641 |
#[test] |
| 642 |
fn workspace_members_non_local_dep_sdist() { |
| 643 |
let cargo_toml = expect![[r#" |
| 644 |
[package] |
| 645 |
authors = ["konstin <[email protected]>"] |
| 646 |
name = "pyo3-pure" |
| 647 |
version = "2.1.2" |
| 648 |
edition = "2021" |
| 649 |
description = "Implements a dummy function (get_fortytwo.DummyClass.get_42()) in rust" |
| 650 |
license = "MIT" |
| 651 |
readme = "README.md" |
| 652 |
|
| 653 |
[dependencies] |
| 654 |
pyo3 = { version = "0.25.0", features = [ |
| 655 |
"abi3-py37", |
| 656 |
"extension-module", |
| 657 |
"generate-import-lib", |
| 658 |
] } |
| 659 |
|
| 660 |
[lib] |
| 661 |
name = "pyo3_pure" |
| 662 |
crate-type = ["cdylib"] |
| 663 |
"#]]; |
| 664 |
handle_result(other::test_source_distribution( |
| 665 |
"test-crates/pyo3-pure", |
| 666 |
SdistGenerator::Cargo, |
| 667 |
expect![[r#" |
| 668 |
{ |
| 669 |
"pyo3_pure-0.1.0+abc123de/Cargo.lock", |
| 670 |
"pyo3_pure-0.1.0+abc123de/Cargo.toml", |
| 671 |
"pyo3_pure-0.1.0+abc123de/LICENSE", |
| 672 |
"pyo3_pure-0.1.0+abc123de/PKG-INFO", |
| 673 |
"pyo3_pure-0.1.0+abc123de/README.md", |
| 674 |
"pyo3_pure-0.1.0+abc123de/check_installed/check_installed.py", |
| 675 |
"pyo3_pure-0.1.0+abc123de/pyo3_pure.pyi", |
| 676 |
"pyo3_pure-0.1.0+abc123de/pyproject.toml", |
| 677 |
"pyo3_pure-0.1.0+abc123de/src/lib.rs", |
| 678 |
"pyo3_pure-0.1.0+abc123de/tests/test_pyo3_pure.py", |
| 679 |
"pyo3_pure-0.1.0+abc123de/tox.ini", |
| 680 |
} |
| 681 |
"#]], |
| 682 |
Some((Path::new("pyo3_pure-0.1.0+abc123de/Cargo.toml"), cargo_toml)), |
| 683 |
"sdist-workspace-members-non-local-dep", |
| 684 |
)) |
| 685 |
} |
| 686 |
|
| 687 |
#[test] |
| 688 |
fn lib_with_path_dep_sdist() { |
| 689 |
handle_result(other::test_source_distribution( |
| 690 |
"test-crates/sdist_with_path_dep", |
| 691 |
SdistGenerator::Cargo, |
| 692 |
expect![[r#" |
| 693 |
{ |
| 694 |
"sdist_with_path_dep-0.1.0/PKG-INFO", |
| 695 |
"sdist_with_path_dep-0.1.0/pyproject.toml", |
| 696 |
"sdist_with_path_dep-0.1.0/sdist_with_path_dep/Cargo.lock", |
| 697 |
"sdist_with_path_dep-0.1.0/sdist_with_path_dep/Cargo.toml", |
| 698 |
"sdist_with_path_dep-0.1.0/sdist_with_path_dep/src/lib.rs", |
| 699 |
"sdist_with_path_dep-0.1.0/some_path_dep/Cargo.toml", |
| 700 |
"sdist_with_path_dep-0.1.0/some_path_dep/src/lib.rs", |
| 701 |
"sdist_with_path_dep-0.1.0/transitive_path_dep/Cargo.toml", |
| 702 |
"sdist_with_path_dep-0.1.0/transitive_path_dep/src/lib.rs", |
| 703 |
} |
| 704 |
"#]], |
| 705 |
None, |
| 706 |
"sdist-lib-with-path-dep", |
| 707 |
)) |
| 708 |
} |
| 709 |
|
| 710 |
#[test] |
| 711 |
fn lib_with_target_path_dep_sdist() { |
| 712 |
let cargo_toml = expect![[r#" |
| 713 |
[package] |
| 714 |
name = "sdist_with_target_path_dep" |
| 715 |
version = "0.1.0" |
| 716 |
authors = ["konstin <[email protected]>"] |
| 717 |
edition = "2021" |
| 718 |
|
| 719 |
[lib] |
| 720 |
crate-type = ["cdylib"] |
| 721 |
|
| 722 |
[dependencies] |
| 723 |
pyo3 = { version = "0.25.0", features = ["extension-module"] } |
| 724 |
|
| 725 |
[target.'cfg(not(target_endian = "all-over-the-place"))'.dependencies] |
| 726 |
some_path_dep = { path = "../some_path_dep" } |
| 727 |
"#]]; |
| 728 |
handle_result(other::test_source_distribution( |
| 729 |
"test-crates/sdist_with_target_path_dep", |
| 730 |
SdistGenerator::Cargo, |
| 731 |
expect![[r#" |
| 732 |
{ |
| 733 |
"sdist_with_target_path_dep-0.1.0/PKG-INFO", |
| 734 |
"sdist_with_target_path_dep-0.1.0/pyproject.toml", |
| 735 |
"sdist_with_target_path_dep-0.1.0/sdist_with_target_path_dep/Cargo.lock", |
| 736 |
"sdist_with_target_path_dep-0.1.0/sdist_with_target_path_dep/Cargo.toml", |
| 737 |
"sdist_with_target_path_dep-0.1.0/sdist_with_target_path_dep/src/lib.rs", |
| 738 |
"sdist_with_target_path_dep-0.1.0/some_path_dep/Cargo.toml", |
| 739 |
"sdist_with_target_path_dep-0.1.0/some_path_dep/src/lib.rs", |
| 740 |
"sdist_with_target_path_dep-0.1.0/transitive_path_dep/Cargo.toml", |
| 741 |
"sdist_with_target_path_dep-0.1.0/transitive_path_dep/src/lib.rs", |
| 742 |
} |
| 743 |
"#]], |
| 744 |
Some(( |
| 745 |
Path::new("sdist_with_target_path_dep-0.1.0/sdist_with_target_path_dep/Cargo.toml"), |
| 746 |
cargo_toml, |
| 747 |
)), |
| 748 |
"sdist-lib-with-target-path-dep", |
| 749 |
)) |
| 750 |
} |
| 751 |
|
| 752 |
#[test] |
| 753 |
fn pyo3_mixed_src_layout_sdist() { |
| 754 |
handle_result(other::test_source_distribution( |
| 755 |
"test-crates/pyo3-mixed-src/rust", |
| 756 |
SdistGenerator::Cargo, |
| 757 |
expect![[r#" |
| 758 |
{ |
| 759 |
"pyo3_mixed_src-2.1.3/PKG-INFO", |
| 760 |
"pyo3_mixed_src-2.1.3/pyproject.toml", |
| 761 |
"pyo3_mixed_src-2.1.3/rust/Cargo.lock", |
| 762 |
"pyo3_mixed_src-2.1.3/rust/Cargo.toml", |
| 763 |
"pyo3_mixed_src-2.1.3/rust/src/lib.rs", |
| 764 |
"pyo3_mixed_src-2.1.3/src/pyo3_mixed_src/__init__.py", |
| 765 |
"pyo3_mixed_src-2.1.3/src/pyo3_mixed_src/python_module/__init__.py", |
| 766 |
"pyo3_mixed_src-2.1.3/src/pyo3_mixed_src/python_module/double.py", |
| 767 |
"pyo3_mixed_src-2.1.3/src/tests/test_pyo3_mixed.py", |
| 768 |
} |
| 769 |
"#]], |
| 770 |
None, |
| 771 |
"sdist-pyo3-mixed-src-layout", |
| 772 |
)) |
| 773 |
} |
| 774 |
|
| 775 |
#[test] |
| 776 |
fn pyo3_mixed_include_exclude_sdist() { |
| 777 |
handle_result(other::test_source_distribution( |
| 778 |
"test-crates/pyo3-mixed-include-exclude", |
| 779 |
SdistGenerator::Cargo, |
| 780 |
expect![[r#" |
| 781 |
{ |
| 782 |
"pyo3_mixed_include_exclude-2.1.3/.gitignore", |
| 783 |
"pyo3_mixed_include_exclude-2.1.3/Cargo.lock", |
| 784 |
"pyo3_mixed_include_exclude-2.1.3/Cargo.toml", |
| 785 |
"pyo3_mixed_include_exclude-2.1.3/PKG-INFO", |
| 786 |
"pyo3_mixed_include_exclude-2.1.3/README.md", |
| 787 |
"pyo3_mixed_include_exclude-2.1.3/check_installed/check_installed.py", |
| 788 |
"pyo3_mixed_include_exclude-2.1.3/pyo3_mixed_include_exclude/__init__.py", |
| 789 |
"pyo3_mixed_include_exclude-2.1.3/pyo3_mixed_include_exclude/include_this_file", |
| 790 |
"pyo3_mixed_include_exclude-2.1.3/pyo3_mixed_include_exclude/python_module/__init__.py", |
| 791 |
"pyo3_mixed_include_exclude-2.1.3/pyo3_mixed_include_exclude/python_module/double.py", |
| 792 |
"pyo3_mixed_include_exclude-2.1.3/pyproject.toml", |
| 793 |
"pyo3_mixed_include_exclude-2.1.3/src/lib.rs", |
| 794 |
"pyo3_mixed_include_exclude-2.1.3/tox.ini", |
| 795 |
} |
| 796 |
"#]], |
| 797 |
None, |
| 798 |
"sdist-pyo3-mixed-include-exclude", |
| 799 |
)) |
| 800 |
} |
| 801 |
|
| 802 |
#[test] |
| 803 |
fn pyo3_mixed_include_exclude_git_sdist_generator() { |
| 804 |
if !Path::new(".git").exists() { |
| 805 |
return; |
| 806 |
} |
| 807 |
handle_result(other::test_source_distribution( |
| 808 |
"test-crates/pyo3-mixed-include-exclude", |
| 809 |
SdistGenerator::Git, |
| 810 |
expect![[r#" |
| 811 |
{ |
| 812 |
"pyo3_mixed_include_exclude-2.1.3/.gitignore", |
| 813 |
"pyo3_mixed_include_exclude-2.1.3/Cargo.lock", |
| 814 |
"pyo3_mixed_include_exclude-2.1.3/Cargo.toml", |
| 815 |
"pyo3_mixed_include_exclude-2.1.3/PKG-INFO", |
| 816 |
"pyo3_mixed_include_exclude-2.1.3/README.md", |
| 817 |
"pyo3_mixed_include_exclude-2.1.3/check_installed/check_installed.py", |
| 818 |
"pyo3_mixed_include_exclude-2.1.3/pyo3_mixed_include_exclude/__init__.py", |
| 819 |
"pyo3_mixed_include_exclude-2.1.3/pyo3_mixed_include_exclude/include_this_file", |
| 820 |
"pyo3_mixed_include_exclude-2.1.3/pyo3_mixed_include_exclude/python_module/__init__.py", |
| 821 |
"pyo3_mixed_include_exclude-2.1.3/pyo3_mixed_include_exclude/python_module/double.py", |
| 822 |
"pyo3_mixed_include_exclude-2.1.3/pyproject.toml", |
| 823 |
"pyo3_mixed_include_exclude-2.1.3/src/lib.rs", |
| 824 |
"pyo3_mixed_include_exclude-2.1.3/tox.ini", |
| 825 |
} |
| 826 |
"#]], |
| 827 |
None, |
| 828 |
"sdist-pyo3-mixed-include-exclude-git", |
| 829 |
)) |
| 830 |
} |
| 831 |
|
| 832 |
#[test] |
| 833 |
fn pyo3_mixed_include_exclude_wheel_files() { |
| 834 |
handle_result(other::check_wheel_files( |
| 835 |
"test-crates/pyo3-mixed-include-exclude", |
| 836 |
vec![ |
| 837 |
"pyo3_mixed_include_exclude-2.1.3.dist-info/METADATA", |
| 838 |
"pyo3_mixed_include_exclude-2.1.3.dist-info/RECORD", |
| 839 |
"pyo3_mixed_include_exclude-2.1.3.dist-info/WHEEL", |
| 840 |
"pyo3_mixed_include_exclude-2.1.3.dist-info/entry_points.txt", |
| 841 |
"pyo3_mixed_include_exclude/__init__.py", |
| 842 |
"pyo3_mixed_include_exclude/include_this_file", |
| 843 |
"pyo3_mixed_include_exclude/python_module/__init__.py", |
| 844 |
"pyo3_mixed_include_exclude/python_module/double.py", |
| 845 |
"README.md", |
| 846 |
], |
| 847 |
"wheel-files-pyo3-mixed-include-exclude", |
| 848 |
)) |
| 849 |
} |
| 850 |
|
| 851 |
#[test] |
| 852 |
fn workspace_sdist() { |
| 853 |
handle_result(other::test_source_distribution( |
| 854 |
"test-crates/workspace/py", |
| 855 |
SdistGenerator::Cargo, |
| 856 |
expect![[r#" |
| 857 |
{ |
| 858 |
"py-0.1.0/Cargo.lock", |
| 859 |
"py-0.1.0/Cargo.toml", |
| 860 |
"py-0.1.0/PKG-INFO", |
| 861 |
"py-0.1.0/py/Cargo.toml", |
| 862 |
"py-0.1.0/py/src/main.rs", |
| 863 |
"py-0.1.0/pyproject.toml", |
| 864 |
} |
| 865 |
"#]], |
| 866 |
None, |
| 867 |
"sdist-workspace", |
| 868 |
)) |
| 869 |
} |
| 870 |
|
| 871 |
#[test] |
| 872 |
fn workspace_with_path_dep_sdist() { |
| 873 |
handle_result(other::test_source_distribution( |
| 874 |
"test-crates/workspace_with_path_dep/python", |
| 875 |
SdistGenerator::Cargo, |
| 876 |
expect![[r#" |
| 877 |
{ |
| 878 |
"workspace_with_path_dep-0.1.0/Cargo.lock", |
| 879 |
"workspace_with_path_dep-0.1.0/Cargo.toml", |
| 880 |
"workspace_with_path_dep-0.1.0/PKG-INFO", |
| 881 |
"workspace_with_path_dep-0.1.0/generic_lib/Cargo.toml", |
| 882 |
"workspace_with_path_dep-0.1.0/generic_lib/src/lib.rs", |
| 883 |
"workspace_with_path_dep-0.1.0/pyproject.toml", |
| 884 |
"workspace_with_path_dep-0.1.0/python/Cargo.toml", |
| 885 |
"workspace_with_path_dep-0.1.0/python/src/lib.rs", |
| 886 |
"workspace_with_path_dep-0.1.0/transitive_lib/Cargo.toml", |
| 887 |
"workspace_with_path_dep-0.1.0/transitive_lib/src/lib.rs", |
| 888 |
} |
| 889 |
"#]], |
| 890 |
None, |
| 891 |
"sdist-workspace-with-path-dep", |
| 892 |
)) |
| 893 |
} |
| 894 |
|
| 895 |
#[test] |
| 896 |
fn workspace_with_path_dep_git_sdist_generator() { |
| 897 |
if !Path::new(".git").exists() { |
| 898 |
return; |
| 899 |
} |
| 900 |
handle_result(other::test_source_distribution( |
| 901 |
"test-crates/workspace_with_path_dep/python", |
| 902 |
SdistGenerator::Git, |
| 903 |
expect![[r#" |
| 904 |
{ |
| 905 |
"workspace_with_path_dep-0.1.0/Cargo.toml", |
| 906 |
"workspace_with_path_dep-0.1.0/PKG-INFO", |
| 907 |
"workspace_with_path_dep-0.1.0/pyproject.toml", |
| 908 |
"workspace_with_path_dep-0.1.0/src/lib.rs", |
| 909 |
} |
| 910 |
"#]], |
| 911 |
None, |
| 912 |
"sdist-workspace-with-path-dep-git", |
| 913 |
)) |
| 914 |
} |
| 915 |
|
| 916 |
#[rustversion::since(1.64)] |
| 917 |
#[test] |
| 918 |
fn workspace_inheritance_sdist() { |
| 919 |
handle_result(other::test_source_distribution( |
| 920 |
"test-crates/workspace-inheritance/python", |
| 921 |
SdistGenerator::Cargo, |
| 922 |
expect![[r#" |
| 923 |
{ |
| 924 |
"workspace_inheritance-0.1.0/Cargo.lock", |
| 925 |
"workspace_inheritance-0.1.0/Cargo.toml", |
| 926 |
"workspace_inheritance-0.1.0/PKG-INFO", |
| 927 |
"workspace_inheritance-0.1.0/generic_lib/Cargo.toml", |
| 928 |
"workspace_inheritance-0.1.0/generic_lib/src/lib.rs", |
| 929 |
"workspace_inheritance-0.1.0/pyproject.toml", |
| 930 |
"workspace_inheritance-0.1.0/python/Cargo.toml", |
| 931 |
"workspace_inheritance-0.1.0/python/src/lib.rs", |
| 932 |
} |
| 933 |
"#]], |
| 934 |
None, |
| 935 |
"sdist-workspace-inheritance", |
| 936 |
)) |
| 937 |
} |
| 938 |
|
| 939 |
#[test] |
| 940 |
fn workspace_license_files() { |
| 941 |
handle_result(other::test_source_distribution( |
| 942 |
"test-crates/hello-world", |
| 943 |
SdistGenerator::Cargo, |
| 944 |
expect![[r#" |
| 945 |
{ |
| 946 |
"hello_world-0.1.0/Cargo.lock", |
| 947 |
"hello_world-0.1.0/Cargo.toml", |
| 948 |
"hello_world-0.1.0/LICENSE", |
| 949 |
"hello_world-0.1.0/PKG-INFO", |
| 950 |
"hello_world-0.1.0/README.md", |
| 951 |
"hello_world-0.1.0/check_installed/check_installed.py", |
| 952 |
"hello_world-0.1.0/licenses/AUTHORS.txt", |
| 953 |
"hello_world-0.1.0/pyproject.toml", |
| 954 |
"hello_world-0.1.0/src/bin/foo.rs", |
| 955 |
"hello_world-0.1.0/src/main.rs", |
| 956 |
} |
| 957 |
"#]], |
| 958 |
None, |
| 959 |
"sdist-hello-world", |
| 960 |
)) |
| 961 |
} |
| 962 |
|
| 963 |
#[test] |
| 964 |
fn abi3_python_interpreter_args() { |
| 965 |
handle_result(other::abi3_python_interpreter_args()); |
| 966 |
} |
| 967 |
|
| 968 |
#[test] |
| 969 |
fn pyo3_source_date_epoch() { |
| 970 |
env::set_var("SOURCE_DATE_EPOCH", "0"); |
| 971 |
handle_result(other::check_wheel_mtimes( |
| 972 |
"test-crates/pyo3-mixed-include-exclude", |
| 973 |
vec![datetime!(1980-01-01 0:00 UTC)], |
| 974 |
"pyo3_source_date_epoch", |
| 975 |
)) |
| 976 |
} |