Skip to content

Commit

Permalink
ci: fix sspi-ffi test job for Windows (#98)
Browse files Browse the repository at this point in the history
On Windows, we rename symbols using a .def file.
For that, we emit a cargo instruction.

> cargo:rustc-link-arg=/DEF:sspi.def

However, when attempting to run unit tests this causes an error.

```
Caused by:
  could not execute process `<redacted>` (never executed)

Caused by:
  %1 is not a valid Win32 application. (os error 193)
```

There is currently no built-in way to check if cargo is going to run the tests from the build.rs itself:
rust-lang/cargo#4001

This commit adds a new environment variable that when set prevent the instruction emission.
  • Loading branch information
CBenoit authored Jan 31, 2023
1 parent ce00a08 commit 61a8ea8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ jobs:
name: Tests [${{ matrix.os }}] [${{ matrix.crate-name }}]
runs-on: ${{ matrix.runner }}
needs: formatting
env:
SSPI_RS_IS_RUNNING_TESTS: true
strategy:
fail-fast: true
matrix:
Expand Down
3 changes: 2 additions & 1 deletion ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use std::path::PathBuf;

fn main() {
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
let is_running_tests = env::var("SSPI_RS_IS_RUNNING_TESTS").is_ok();

if target_os == "windows" {
if target_os == "windows" && !is_running_tests {
// On Windows, we provide the linker with a .def file to rename exports.
// This module definition file is used to rename some symbols
// and avoid linkage conflicts with secur32.dll when building the library.
Expand Down

0 comments on commit 61a8ea8

Please sign in to comment.