Skip to content

Commit b9d8102

Browse files
committed
eliminate custom build and test steps
1 parent 8978e4e commit b9d8102

File tree

8 files changed

+76
-103
lines changed

8 files changed

+76
-103
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
push:
66
branches:
77
- master
8+
- grist-main
9+
- grist-main-dev
810
tags:
911
- '*'
1012
env:
@@ -41,6 +43,7 @@ jobs:
4143
node: 16
4244
host: x86
4345
target: x86
46+
# This is a self-hosted runner, github doesn't have this architecture yet.
4447
- os: macos-m1
4548
node: 16
4649
host: arm64

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"name": "@gristlabs/sqlite3",
33
"description": "Asynchronous, non-blocking SQLite3 bindings",
44
"version": "4.1.1-grist.6",
5-
"homepage": "https://github.com/TryGhost/node-sqlite3",
5+
"homepage": "https://github.com/gristlabs/node-sqlite3",
66
"author": {
77
"name": "Mapbox",
88
"url": "https://mapbox.com/"
99
},
1010
"binary": {
1111
"module_name": "node_sqlite3",
1212
"module_path": "./lib/binding/napi-v{napi_build_version}-{platform}-{libc}-{arch}",
13-
"host": "https://github.com/TryGhost/node-sqlite3/releases/download/",
13+
"host": "https://github.com/gristlabs/node-sqlite3/releases/download/",
1414
"remote_path": "v{version}",
1515
"package_name": "napi-v{napi_build_version}-{platform}-{libc}-{arch}.tar.gz",
1616
"napi_versions": [
@@ -45,7 +45,7 @@
4545
],
4646
"repository": {
4747
"type": "git",
48-
"url": "https://github.com/TryGhost/node-sqlite3.git"
48+
"url": "https://github.com/gristlabs/node-sqlite3.git"
4949
},
5050
"dependencies": {
5151
"@mapbox/node-pre-gyp": "^1.0.0",
@@ -73,7 +73,7 @@
7373
"build:debug": "node-pre-gyp build --debug",
7474
"install": "node-pre-gyp install --fallback-to-build",
7575
"pretest": "node test/support/createdb.js",
76-
"test": "./scripts/prepare_for_test.sh; mocha -R spec --timeout 480000",
76+
"test": "mocha -R spec --timeout 480000",
7777
"rebuild-tests": "node-gyp rebuild --directory test/cpp",
7878
"pack": "node-pre-gyp package"
7979
},

scripts/prepare_for_test.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/node_sqlite3.cc

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,68 @@ const char* sqlite_authorizer_string(int type) {
125125
}
126126
}
127127

128-
NODE_API_MODULE(node_sqlite3, RegisterModule)
128+
129+
/*************************************/
130+
/* Some hooks for Grist testing. */
131+
/*************************************/
132+
133+
Napi::Value Serialize(const Napi::CallbackInfo& info) {
134+
Napi::Env env = info.Env();
135+
if (info.Length() > 0) {
136+
Marshaller m;
137+
m.marshalValue(info[0]);
138+
const std::vector<char> &buffer = m.getBuffer();
139+
Napi::Env env = info.Env();
140+
return Napi::Buffer<char>::Copy(env, &buffer[0], buffer.size());
141+
}
142+
return env.Null();
143+
}
144+
145+
Napi::Value Parse(const Napi::CallbackInfo& info) {
146+
Napi::Env env = info.Env();
147+
if (info.Length() > 0) {
148+
if (!info[0].IsBuffer()) {
149+
Napi::Error::New(env, "Argument must be a buffer").ThrowAsJavaScriptException();
150+
return env.Null();
151+
} else {
152+
Napi::Buffer<char> buffer = info[0].As<Napi::Buffer<char>>();
153+
Napi::Value result = Unmarshaller::parse(info, buffer.Data(), buffer.Length());
154+
if (!result.IsEmpty()) {
155+
return result;
156+
}
157+
}
158+
}
159+
return env.Null();
160+
}
161+
162+
Napi::Value TestOppositeEndianness(const Napi::CallbackInfo& info) {
163+
Napi::Env env = info.Env();
164+
if (info.Length() > 0) {
165+
marshalTestOppositeEndianness(info[0].As<Napi::Boolean>().Value());
166+
}
167+
return env.Null();
168+
}
169+
170+
Napi::Object RegisterTestHooks(Napi::Env env, Napi::Object exports) {
171+
exports.Set(Napi::String::New(env, "serialize"),
172+
Napi::Function::New(env, Serialize));
173+
exports.Set(Napi::String::New(env, "parse"),
174+
Napi::Function::New(env, Parse));
175+
exports.Set(Napi::String::New(env, "testOppositeEndianness"),
176+
Napi::Function::New(env, TestOppositeEndianness));
177+
return exports;
178+
}
179+
180+
Napi::Object RegisterModuleAndTestHooks(Napi::Env env, Napi::Object exports) {
181+
RegisterModule(env, exports);
182+
return RegisterTestHooks(env, exports);
183+
}
184+
185+
186+
/*************************************/
187+
/* End of hooks for Grist testing. */
188+
/*************************************/
189+
190+
191+
192+
NODE_API_MODULE(node_sqlite3, RegisterModuleAndTestHooks)

test/cpp/binding.gyp

Lines changed: 0 additions & 19 deletions
This file was deleted.

test/cpp/marshal.cc

Lines changed: 0 additions & 55 deletions
This file was deleted.

test/electron.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
var assert = require('assert');
22

3-
describe('electron', function() {
3+
// I can't find definitive documentation, but the napi-based binaries seem to run
4+
// fine with Electron these days, no need for a special song and dance.
5+
describe.skip('electron', function() {
46
it('respects ELECTRON_VERSION', function() {
57
process.env.ELECTRON_VERSION = '1.2.3';
68
let name = require.resolve('..');

test/marshal-test.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
const path = require('path');
44
const assert = require('assert');
55
const util = require('util');
6-
const bindings = require('bindings');
7-
8-
const testRoot = path.resolve(__dirname, 'cpp');
9-
const mainRoot = path.resolve(__dirname, '..');
10-
bindings({ module_root: mainRoot, bindings: 'node_sqlite3' });
11-
const marshal = bindings({ module_root: testRoot, bindings: 'marshal' });
6+
const marshal = require('..'); // Marshaling test hooks are now in library.
127

138
describe('marshal', function() {
149
function stringToArray(str) {

0 commit comments

Comments
 (0)