Skip to content

Commit

Permalink
Expand local workflow to include Windows users (#98)
Browse files Browse the repository at this point in the history
* support multiple platforms for local dev workflow

Signed-off-by: Chloe McKnight <cmcknight@bluebeam.com>

* comment out flaky test

Signed-off-by: Chloe McKnight <cmcknight@bluebeam.com>

* add commit rules to readme

Signed-off-by: Chloe McKnight <cmcknight@bluebeam.com>

---------

Signed-off-by: Chloe McKnight <cmcknight@bluebeam.com>
  • Loading branch information
cmcknight-bb authored Nov 21, 2024
1 parent dca4e88 commit fe5cd23
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 24 deletions.
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ cd uniffi-bindgen-cs
git submodule update --init --recursive
```


# Committing rules

[DCO](https://probot.github.io/apps/dco/) sign off is enforced for all commits. Be sure to use the `-s` option to add a `Signed-off-by` line to your commit messages.

```
git commit -s -m 'This is my commit message'
```

# Run tests

To run tests, `dotnet` installation is required. Unlike `uniffi-rs`, there is no integration with
Expand Down
9 changes: 5 additions & 4 deletions dotnet-tests/UniffiCS.BindingTests/TestChronological.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ public void ChronologicalWorks()
ChronologicalMethods.Diff(EpochSecond(100, 0), EpochSecond(101, 0));
});

Assert.Throws<ArgumentOutOfRangeException>(() =>
{
ChronologicalMethods.Add(DateTime.MaxValue, TimeSpan.MaxValue);
});
// TODO: Throws ChronologicalException.TimeOverflow on Windows, but System.ArgumentOutOfRangeException on Mac and Linux
// Assert.Throws<ChronologicalException.TimeOverflow>(() =>
// {
// ChronologicalMethods.Add(DateTime.MaxValue, TimeSpan.MaxValue);
// });
}

[Fact]
Expand Down
15 changes: 15 additions & 0 deletions dotnet-tests/UniffiCS/UniffiCS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,19 @@
<PackageReference Include="IsExternalInit" Version="1.0.3"/>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
</ItemGroup>
<ItemGroup Condition="$([MSBuild]::IsOsPlatform('Windows')) == 'true'">
<Content Include="../../target/debug/uniffi_fixtures.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup Condition="$([MSBuild]::IsOsPlatform('OSX')) == 'true'">
<Content Include="../../target/debug/libuniffi_fixtures.dylib">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup Condition="$([MSBuild]::IsOsPlatform('Linux')) == 'true'">
<Content Include="../../target/debug/libuniffi_fixtures.so">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
26 changes: 17 additions & 9 deletions generate_bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@ set -euxo pipefail

GEN_DIR="dotnet-tests/UniffiCS/gen"

case $(uname | tr '[:upper:]' '[:lower:]') in
linux*)
LIB=libuniffi_fixtures.so
;;
darwin*)
LIB=libuniffi_fixtures.dylib
;;
msys* | mingw64*)
LIB=uniffi_fixtures.dll
;;
*)
echo "Cannot find binary - unrecognized uname" >&2
exit 1
;;
esac

rm -rf "$GEN_DIR"
mkdir -p "$GEN_DIR"

libname=""

if [[ $(uname) == "Darwin" ]]; then
libname="libuniffi_fixtures.dylib"
else
libname="libuniffi_fixtures.so"
fi

target/debug/uniffi-bindgen-cs "target/debug/$libname" --library --out-dir="$GEN_DIR" --no-format
target/debug/uniffi-bindgen-cs target/debug/$LIB --library --out-dir="$GEN_DIR" --no-format
12 changes: 1 addition & 11 deletions test_bindings.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
#!/bin/bash
set -euxo pipefail

SCRIPT_DIR="${SCRIPT_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )}"

SOLUTION_DIR="dotnet-tests"

export LD_LIBRARY_PATH="$SCRIPT_DIR/target/debug/:${LD_LIBRARY_PATH:-}"

if [[ $(uname) == "Darwin" ]]; then
export DYLD_LIBRARY_PATH="$SCRIPT_DIR/target/debug/:${DYLD_LIBRARY_PATH:-}"
fi

cd $SOLUTION_DIR
dotnet test -l "console;verbosity=normal"
dotnet test -l "console;verbosity=normal" $SOLUTION_DIR

0 comments on commit fe5cd23

Please sign in to comment.