Add test for export-config round trip.

This commit is contained in:
Ashley Anderson 2022-01-11 15:07:46 -05:00
parent 04b8652612
commit 14bd6282ad
2 changed files with 16 additions and 1 deletions

View file

@ -227,7 +227,7 @@ jobs:
run: cargo test --manifest-path=pyo3-macros-backend/Cargo.toml
- name: Test build config
run: cargo test --manifest-path=pyo3-build-config/Cargo.toml
run: cargo test --manifest-path=pyo3-build-config/Cargo.toml --all-features
- name: Test python examples and tests
shell: bash

View file

@ -1945,4 +1945,19 @@ mod tests {
.expect("failed to run Python script");
assert_eq!(out.trim_end(), "42");
}
#[test]
#[cfg(feature = "export-config")]
fn test_emit_pyo3_configs_round_trip() {
let interpreter = make_interpreter_config()
.expect("could not get InterpreterConfig from installed interpreter");
interpreter.emit_pyo3_cfgs();
// config path env var is not set during testing of this crate alone, as it relies on the
// pyo3 python links manifest key, so we have to hard-code the same path
let output_path =
Path::new(&cargo_env_var("OUT_DIR").unwrap()).join(EXPORT_CONFIG_FILENAME);
let reimported_interpreter = InterpreterConfig::from_path(output_path)
.expect("could not generated InterpreterConfig from exported config");
assert_eq!(interpreter, reimported_interpreter);
}
}