Skip to content

Commit

Permalink
Add and fix macOS builds
Browse files Browse the repository at this point in the history
  • Loading branch information
filipnavara committed Jul 17, 2021
1 parent 7cb092c commit 5207738
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 21 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ on:
jobs:
build:

runs-on: windows-latest
strategy:
matrix:
os: [windows-latest, macos-latest]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
Expand All @@ -33,6 +37,7 @@ jobs:
with:
dotnet-version: 2.1.x
- name: Add msbuild to PATH
if: startsWith(matrix.os, 'windows')
uses: microsoft/[email protected]
- name: Install T4
run: dotnet tool install --global dotnet-t4
Expand Down
28 changes: 17 additions & 11 deletions build/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
open System
open System.Diagnostics
open System.IO
open System.Runtime.InteropServices
open System.Xml.Linq
open System.Linq

Expand Down Expand Up @@ -165,25 +166,30 @@ let main argv =

//exec "dotnet" (sprintf "run --framework=%s" "net5.0") (Path.Combine(top, "test_nupkgs", "cil", "fake_xunit"))

exec "dotnet" "test" (Path.Combine(top, "test_nupkgs", "e_sqlite3", "real_xunit"))
exec "dotnet" "test" (Path.Combine(top, "test_nupkgs", "winsqlite3", "real_xunit"))
exec "dotnet" "test" (Path.Combine(top, "test_nupkgs", "e_sqlcipher", "real_xunit"))
// TODO do bundle_sqlite3 real_xunit here?
let real_xunit_dirs = [
yield "e_sqlite3"
yield "e_sqlcipher"
// TODO do bundle_sqlite3 real_xunit here?
if RuntimeInformation.IsOSPlatform(OSPlatform.Windows) then yield "winsqlite3"
]

let fake_xunit_tfms = [
"netcoreapp2.1"
"netcoreapp3.1"
//"net461"
yield "netcoreapp2.1"
yield "netcoreapp3.1"
if RuntimeInformation.IsOSPlatform(OSPlatform.Windows) then yield "net461"
]

let fake_xunit_dirs = [
"e_sqlite3"
"e_sqlcipher"
"winsqlite3"
"sqlite3"
yield "e_sqlite3"
yield "e_sqlcipher"
if RuntimeInformation.IsOSPlatform(OSPlatform.Windows) then yield "winsqlite3"
yield "sqlite3"
]

for tfm in fake_xunit_tfms do
for dir in real_xunit_dirs do
let args = sprintf "test --framework=%s" tfm
exec "dotnet" args (Path.Combine(top, "test_nupkgs", dir, "real_xunit"))
for dir in fake_xunit_dirs do
let args = sprintf "run --framework=%s" tfm
exec "dotnet" args (Path.Combine(top, "test_nupkgs", dir, "fake_xunit"))
Expand Down
38 changes: 29 additions & 9 deletions src/common/tests_xunit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using SQLitePCL;
using SQLitePCL.Ugly;
Expand Down Expand Up @@ -67,10 +68,13 @@ public void test_GetZeroTerminatedUTF8Bytes()
[Fact]
public void test_call_sqlite3_enable_load_extension()
{
using (sqlite3 db = ugly.open(":memory:"))
if (0 == raw.sqlite3_compileoption_used("SQLITE_OMIT_LOAD_EXTENSION"))
{
var rc = raw.sqlite3_enable_load_extension(db, 0);
Assert.Equal(raw.SQLITE_OK, rc);
using (sqlite3 db = ugly.open(":memory:"))
{
var rc = raw.sqlite3_enable_load_extension(db, 0);
Assert.Equal(raw.SQLITE_OK, rc);
}
}
}

Expand Down Expand Up @@ -781,10 +785,17 @@ public void test_threadsafe()
public void test_enable_shared_cache()
{
int result = raw.sqlite3_enable_shared_cache(1);
Assert.Equal(raw.SQLITE_OK, result);
// https://www.sqlite.org/c3ref/enable_shared_cache.html
// Note: This method is disabled on MacOS X 10.7 and iOS version 5.0 and will always
// return SQLITE_MISUSE. On those systems, shared cache mode should be enabled
// per-database connection via sqlite3_open_v2() with SQLITE_OPEN_SHAREDCACHE.
if (result != raw.SQLITE_MISUSE)
{
Assert.Equal(raw.SQLITE_OK, result);

result = raw.sqlite3_enable_shared_cache(0);
Assert.Equal(raw.SQLITE_OK, result);
result = raw.sqlite3_enable_shared_cache(0);
Assert.Equal(raw.SQLITE_OK, result);
}
}

[Fact]
Expand Down Expand Up @@ -815,12 +826,15 @@ public void test_sqlite3_soft_heap_limit64()
}

[Fact]
public void sqlite3_hard_heap_limit64()
public void test_sqlite3_hard_heap_limit64()
{
var version = raw.sqlite3_libversion_number();

if (version < 3031001) return; // Added in 3.31.1: https://sqlite.org/releaselog/3_31_1.html

// Skip failing test on macOS system provided libsqlite3.dylib
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && raw.GetNativeLibraryName() == "sqlite3")
return;

var query = raw.sqlite3_hard_heap_limit64(-1);
Assert.True(query >= 0);

Expand All @@ -835,11 +849,17 @@ public void sqlite3_hard_heap_limit64()
[Fact]
public void test_sqlite3_status()
{
// Skip failing test on macOS system provided libsqlite3.dylib
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && raw.GetNativeLibraryName() == "sqlite3")
return;

using (sqlite3 db = ugly.open(":memory:"))
{
int current;
int highwater;
ugly.sqlite3_status(raw.SQLITE_STATUS_MEMORY_USED, out current, out highwater, 0);

var rc = raw.sqlite3_status(raw.SQLITE_STATUS_MEMORY_USED, out current, out highwater, 0);
Assert.Equal(raw.SQLITE_OK, rc);

Assert.True(current > 0);
Assert.True(highwater > 0);
Expand Down

0 comments on commit 5207738

Please sign in to comment.