From 14bd6282ad44a52465530a663124d6652a8ee03f Mon Sep 17 00:00:00 2001 From: Ashley Anderson Date: Tue, 11 Jan 2022 15:07:46 -0500 Subject: [PATCH] Add test for export-config round trip. --- .github/workflows/ci.yml | 2 +- pyo3-build-config/src/impl_.rs | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e0cd74a..589e3ad3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/pyo3-build-config/src/impl_.rs b/pyo3-build-config/src/impl_.rs index e8dbf50b..dc147467 100644 --- a/pyo3-build-config/src/impl_.rs +++ b/pyo3-build-config/src/impl_.rs @@ -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); + } }