diff --git a/ext/wasm/api/sqlite3-api-oo1.js b/ext/wasm/api/sqlite3-api-oo1.js index 5b934818fd..b1b79c643e 100644 --- a/ext/wasm/api/sqlite3-api-oo1.js +++ b/ext/wasm/api/sqlite3-api-oo1.js @@ -87,7 +87,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ being-construct DB object as its "this". See the DB constructor for the argument docs. This is split into a separate function in order to enable simple creation of special-case DB constructors, - e.g. JsStorageDB and OpfsDB. + e.g. JsStorageDB and OpfsDb. Expects to be passed a configuration object with the following properties: diff --git a/ext/wasm/common/testing.css b/ext/wasm/common/testing.css index 27f77e45c7..47517d9672 100644 --- a/ext/wasm/common/testing.css +++ b/ext/wasm/common/testing.css @@ -34,8 +34,10 @@ span.labeled-input { color: red; background-color: yellow; } +.strong { font-weight: 700 } .warning { color: firebrick; } .green { color: darkgreen; } +.faded { opacity: 0.5; } .group-start { color: blue; } .group-end { color: blue; } .input-wrapper { white-space: nowrap; } diff --git a/ext/wasm/tester1-worker.html b/ext/wasm/tester1-worker.html index e127cffdca..4baf084e73 100644 --- a/ext/wasm/tester1-worker.html +++ b/ext/wasm/tester1-worker.html @@ -20,7 +20,11 @@ const logTarget = document.querySelector('#test-output'); const logHtml = function(cssClass,...args){ const ln = document.createElement('div'); - if(cssClass) ln.classList.add(cssClass); + if(cssClass){ + for(const c of (Array.isArray(cssClass) ? cssClass : [cssClass])){ + ln.classList.add(c); + } + } ln.append(document.createTextNode(args.join(' '))); logTarget.append(ln); }; diff --git a/ext/wasm/tester1.js b/ext/wasm/tester1.js index 642ca1024e..bc93c9c37c 100644 --- a/ext/wasm/tester1.js +++ b/ext/wasm/tester1.js @@ -70,7 +70,11 @@ const logTarget = document.querySelector('#test-output'); logClass = function(cssClass,...args){ const ln = document.createElement('div'); - if(cssClass) ln.classList.add(cssClass); + if(cssClass){ + for(const c of (Array.isArray(cssClass) ? cssClass : [cssClass])){ + ln.classList.add(c); + } + } ln.append(document.createTextNode(normalizeArgs(args).join(' '))); logTarget.append(ln); }; @@ -105,6 +109,8 @@ throw new Error(args.join(' ')); }; + const roundMs = (ms)=>Math.round(ms*100)/100; + /** Helpers for writing sqlite3-specific tests. */ @@ -210,33 +216,41 @@ return this; }, run: async function(sqlite3){ - if(this.predicate && !this.predicate()){ - log("SKIPPING test group #"+this.number,this.name); - return; - } log(TestUtil.separator); logClass('group-start',"Group #"+this.number+':',this.name); const indent = ' '; + if(this.predicate && !this.predicate(sqlite3)){ + logClass('warning',indent, + "SKIPPING group because predicate says to."); + return; + } const assertCount = TestUtil.counter; const groupState = Object.create(null); const skipped = []; + let runtime = 0; for(let i in this.tests){ const t = this.tests[i]; const n = this.number+"."+i; - if(t.predicate && !t.predicate()){ - logClass('warning',indent, n+': SKIPPING',t.name); + log(indent, n+":", t.name); + if(t.predicate && !t.predicate(sqlite3)){ + logClass('warning', indent, indent, + 'SKIPPING because predicate says to'); skipped.push( n+': '+t.name ); }else{ - const tc = TestUtil.counter - log(indent, n+":", t.name); + const tc = TestUtil.counter, now = performance.now(); await t.test.call(groupState, sqlite3); - log(indent, indent, TestUtil.counter - tc, 'assertion(s)'); + const then = performance.now(); + runtime += then - now; + logClass('faded',indent, indent, + TestUtil.counter - tc, 'assertion(s) in', + roundMs(then-now),'ms'); } } logClass('green', - "Group #"+this.number,"assertion count:",(TestUtil.counter - assertCount)); + "Group #"+this.number+":",(TestUtil.counter - assertCount), + "assertion(s) in",roundMs(runtime),"ms"); if(skipped.length){ - log("SKIPPED test(s) in group",this.number+":",skipped); + logClass('warning',"SKIPPED test(s) in group",this.number+":",skipped); } } }; @@ -245,7 +259,8 @@ testGroups: [], currentTestGroup: undefined, addGroup: function(name, predicate){ - this.testGroups.push( this.currentTestGroup = new this.TestGroup(name) ); + this.testGroups.push( this.currentTestGroup = + new this.TestGroup(name, predicate) ); return this; }, addTest: function(name, callback){ @@ -264,11 +279,16 @@ runTests: async function(sqlite3){ return new Promise(async function(pok,pnok){ try { + let runtime = 0; for(let g of this.testGroups){ + const now = performance.now(); await g.run(sqlite3); + runtime += performance.now() - now; } log(TestUtil.separator); - log("Done running tests. Total assertion count:",TestUtil.counter); + logClass(['strong','green'], + "Done running tests.",TestUtil.counter,"assertions in", + roundMs(runtime),'ms'); pok(); }catch(e){ error(e); @@ -1558,6 +1578,33 @@ }) ;/* end of oo1 checks */ + //////////////////////////////////////////////////////////////////////// + T.g('OPFS (Worker thread only and only in supported browsers)', + (sqlite3)=>{return !!sqlite3.opfs}) + .t({ + name: 'OPFS sanity checks', + test: function(sqlite3){ + const filename = 'tester1.js'; + const pVfs = capi.sqlite3_vfs_find('opfs'); + T.assert(pVfs); + const unlink = (fn=filename)=>wasm.sqlite3_wasm_vfs_unlink(pVfs,fn); + unlink(); + let db = new sqlite3.opfs.OpfsDb(filename); + db.exec([ + 'create table p(a);', + 'insert into p(a) values(1),(2),(3)' + ]); + T.assert(3 === db.selectValue('select count(*) from p')); + db.close(); + db = new sqlite3.opfs.OpfsDb(filename); + db.exec('insert into p(a) values(4),(5),(6)'); + T.assert(6 === db.selectValue('select count(*) from p')); + db.close(); + unlink(); + } + }/*OPFS sanity checks*/) + ;/* end OPFS tests */ + //////////////////////////////////////////////////////////////////////// log("Loading and initializing sqlite3 WASM module..."); if(!isUIThread()){ @@ -1592,9 +1639,15 @@ wasm = capi.wasm; log("sqlite3 version:",capi.sqlite3_libversion(), capi.sqlite3_sourceid()); - log("BigInt/int64 support is",(wasm.bigIntEnabled ? "enabled" : "disabled")); + if(wasm.bigIntEnabled){ + log("BigInt/int64 support is enabled."); + }else{ + logClass('warning',"BigInt/int64 support is disabled."); + } if(haveWasmCTests()){ log("sqlite3_wasm_test_...() APIs are available."); + }else{ + logClass('warning',"sqlite3_wasm_test_...() APIs unavailable."); } TestUtil.runTests(sqlite3); }); diff --git a/manifest b/manifest index e45eccf68a..95d27b17b9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Expose\ssqlite3_vfs_unregister()\sto\sWASM\sand\sunregister\skvvfs\sin\sWorker\sthreads\sto\savoid\sits\sunintended\suse\sthere\s(in\scontexts\sother\sthan\slocal/sessionStorage).\sCorrect\sregistration\sof\swindow\sfunctions,\sextend\soo1.DB.createFunction()\sto\ssupport\swindow\sfunctions,\sand\sadd\swindow\sfunction\stests\sto\stester1.js.\sCorrect\san\sincorrect\s1-arg\shandling\scase\sfor\sDB.exec().\sAdd\sper-test\sassertion\scounts\sto\stester1.js. -D 2022-10-21T05:27:40.995 +C Add\stiming\sinfo\sand\sOPFS\ssanity\stests\sto\stester1.js +D 2022-10-21T06:26:17.258 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -485,7 +485,7 @@ F ext/wasm/api/post-js-header.js 2e5c886398013ba2af88028ecbced1e4b22dc96a86467f1 F ext/wasm/api/pre-js.js 151e0616614a49f3db19ed544fa13b38c87c108959fbcd4029ea8399a562d94f F ext/wasm/api/sqlite3-api-cleanup.js 4d07a7524dc9b7b050acfde57163e839243ad2383bd7ee0de0178b1b3e988588 F ext/wasm/api/sqlite3-api-glue.js 6e4e472eb5afc732a695cd7c5ded6dee6ef8b480e61aa0d648a3fc9033c84745 -F ext/wasm/api/sqlite3-api-oo1.js 5016f6dd4b6b461bb6047fe6a2d3d7cbe85aa6b110c263ebf0347672a0cd897e +F ext/wasm/api/sqlite3-api-oo1.js a8f48c76b127c6e20af8937e519e059626e8b859d17036266ae1b1b18c96a31f F ext/wasm/api/sqlite3-api-opfs.js 22d60ba956e873b65e2e0591e239178082bd53a6d563c3c58db7dc03e562e8f7 F ext/wasm/api/sqlite3-api-prologue.js fa00d55f927e5a4ec51cf2c80f6f0eaed2f4f5774341ecf3d63a0ea4c738f8f5 F ext/wasm/api/sqlite3-api-worker1.js a7f38f03275d6c27ab2aef3e83215d3c97ce09c43e6904df47c3764d9d4572b4 @@ -499,7 +499,7 @@ F ext/wasm/batch-runner.html 4deeed44fe41496dc6898d9fb17938ea3291f40f4bfb977e29d F ext/wasm/batch-runner.js 5bae81684728b6be157d1f92b39824153f0fd019345b39f2ab8930f7ee2a57d8 F ext/wasm/common/SqliteTestUtil.js 647bf014bd30bdd870a7e9001e251d12fc1c9ec9ce176a1004b838a4b33c5c05 F ext/wasm/common/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f -F ext/wasm/common/testing.css 53394885077edd3db22d2a0896192334dfc06fb3d1da0b646eb12a332d22f18e +F ext/wasm/common/testing.css c5f37db26f0c86c06503fdbe813f4786c454de2b4ec1e4437ace49256417f54d F ext/wasm/common/whwasmutil.js 50d2ede0b0fa01c1d467e1801fab79f5e46bb02bcbd2b0232e4fdc6090a47818 F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508 @@ -531,9 +531,9 @@ F ext/wasm/sql/000-mandelbrot.sql 775337a4b80938ac8146aedf88808282f04d02d983d826 F ext/wasm/sql/001-sudoku.sql 35b7cb7239ba5d5f193bc05ec379bcf66891bce6f2a5b3879f2f78d0917299b5 F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555e685bce3da8c3f F ext/wasm/test-opfs-vfs.js 48fc59110e8775bb43c9be25b6d634fc07ebadab7da8fbd44889e8129c6e2548 -F ext/wasm/tester1-worker.html 048c341f124fdb61ca14dfd1bd1f78742490f208aa3bb1e84399f83f1e7e6a74 +F ext/wasm/tester1-worker.html dae897329d095a56ec48881878f3b17c2833ebc850aef0b7ddc06ce075917267 F ext/wasm/tester1.html 37ccc958fa0d95074af2d72b7241c8e2d982bbec6dda4dc790241af3d933c3b6 -F ext/wasm/tester1.js 3fc539001b861d6360ea8c4825351157251204781b7a45389527574ad338c7e1 +F ext/wasm/tester1.js bbdf1ff6446f767871c0a88bb9c05dba14139ee9e04c236bea48da014090f825 F ext/wasm/version-info.c 5fa356d38859d71a0369b5c37e1935def7413fcc8a4e349a39d9052c1d0479f4 F ext/wasm/wasmfs.make ee0004813e16c283ff633e08b482008d56adf9b7d42f6c5612f7ab002b924f69 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x @@ -2036,8 +2036,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 89f3e1982ec32c010af67d15ef780847df20de568669e5c9d02f3cf084f51330 -R 8a68d8975e926edd4ad048c9589fdc73 +P f07ce15479b7224b0d1ba9f147a433136e70c1461aa667d2737d4a918f778f55 +R 9850bd6041ab5774a27f08fd128a0d0d U stephan -Z 78e197950cf91aa30272843b46106df8 +Z 22f5514a98dfdd6ddf86c9b4efb8fd0e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9dfbdf93ac..879c083aaf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f07ce15479b7224b0d1ba9f147a433136e70c1461aa667d2737d4a918f778f55 \ No newline at end of file +99915b0076422487cdd181a54e55694404fba13e4a540329b5ede9e2c9e12532 \ No newline at end of file