diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 00000000..83c2f01d --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,47 @@ +name: .NET + +on: + push: + branches: [ emclient ] + pull_request: + branches: [ emclient ] + +jobs: + build: + + strategy: + matrix: + os: [windows-latest, macos-latest] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + path: "SQLitePCL.raw" + - uses: actions/checkout@v2 + with: + repository: ericsink/cb + path: "cb" + - name: Setup .NET 5 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.x + - name: Setup .NET 3.1 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.x + - name: Setup .NET 2.1 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 2.1.x + - name: Add msbuild to PATH + if: startsWith(matrix.os, 'windows') + uses: microsoft/setup-msbuild@v1.0.2 + - name: Install T4 + run: dotnet tool install --global dotnet-t4 + - name: Build + run: | + cd SQLitePCL.raw/build + dotnet run diff --git a/build/Program.fs b/build/Program.fs index 1686ba94..78869d49 100644 --- a/build/Program.fs +++ b/build/Program.fs @@ -2,6 +2,7 @@ open System open System.Diagnostics open System.IO +open System.Runtime.InteropServices open System.Xml.Linq open System.Linq @@ -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")) diff --git a/gen_nuspecs/gen_nuspecs.cs b/gen_nuspecs/gen_nuspecs.cs index 16b2876e..b0244ef5 100644 --- a/gen_nuspecs/gen_nuspecs.cs +++ b/gen_nuspecs/gen_nuspecs.cs @@ -318,12 +318,13 @@ string cpu } static string make_cb_path_mac( - WhichLib lib + WhichLib lib, + string cpu ) { var dir_name = lib.AsString_basename_in_cb(); var lib_name = lib.AsString_libname_in_cb(LibSuffix.DYLIB); - return Path.Combine("$cb_bin_path$", dir_name, "mac", lib_name); + return Path.Combine("$cb_bin_path$", dir_name, "mac", cpu, lib_name); } static void write_nuspec_file_entry_native_linux( @@ -344,13 +345,15 @@ XmlWriter f static void write_nuspec_file_entry_native_mac( WhichLib lib, + string cpu_in_cb, + string rid, XmlWriter f ) { var filename = lib.AsString_libname_in_nupkg(LibSuffix.DYLIB); write_nuspec_file_entry_native( - make_cb_path_mac(lib), - "osx-x64", + make_cb_path_mac(lib, cpu_in_cb), + rid, filename, f ); @@ -408,7 +411,8 @@ XmlWriter f write_nuspec_file_entry_native_uwp(lib, win_toolset, "appcontainer", "x64", "win10-x64", f); write_nuspec_file_entry_native_uwp(lib, win_toolset, "appcontainer", "x86", "win10-x86", f); - write_nuspec_file_entry_native_mac(lib, f); + write_nuspec_file_entry_native_mac(lib, "x86_64", "osx-x64", f); + write_nuspec_file_entry_native_mac(lib, "arm64", "osx-arm64", f); write_nuspec_file_entry_native_linux(lib, "x64", "linux-x64", f); write_nuspec_file_entry_native_linux(lib, "x86", "linux-x86", f); diff --git a/src/common/tests_xunit.cs b/src/common/tests_xunit.cs index 078a756e..eda7e811 100644 --- a/src/common/tests_xunit.cs +++ b/src/common/tests_xunit.cs @@ -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; @@ -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); + } } } @@ -676,6 +680,10 @@ public void test_last_insert_rowid() [Fact] public void test_keywords() { + var version = raw.sqlite3_libversion_number(); + + if (version < 3024000) return; // Added in 3.24.0: https://sqlite.org/releaselog/3_24_0.html + var n = SQLitePCL.raw.sqlite3_keyword_count(); Assert.True(n > 0); for (var i=0; i= 0); @@ -831,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); @@ -1524,6 +1548,10 @@ public void test_stmt_busy() [Fact] public void test_stmt_isexplain() { + var version = raw.sqlite3_libversion_number(); + + if (version < 3028000) return; // Added in 3.28.0: https://sqlite.org/releaselog/3_28_0.html + using (sqlite3 db = ugly.open(":memory:")) { db.exec("CREATE TABLE foo (x int);"); @@ -2817,6 +2845,10 @@ public class class_test_sqlite3_config [Order(0)] public void test_log() { + // Skip failing test on macOS system provided libsqlite3.dylib + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && raw.GetNativeLibraryName() == "sqlite3") + return; + var msgs = new List(); var rc = raw.sqlite3_config_log( (v, errcode, msg) => msgs.Add(msg),