Commit a4cdfdd2 by Konstantin Käfer

automatically create test database on first test execution

parent 6cd00d98
......@@ -5,12 +5,18 @@ build:
clean:
node-waf clean
db:
@if ! [ -f test/support/big.db ]; then \
echo "Creating test database... This may take several minutes." ; \
node test/support/createdb.js ; \
fi
ifndef only
test: build
expresso -I lib test/*.test.js
test: build db
@expresso -I lib test/*.test.js
else
test: build
expresso -I lib test/${only}.test.js
test: build db
@expresso -I lib test/${only}.test.js
endif
.PHONY: build clean test
\ No newline at end of file
#!/bin/sh
var sqlite3 = require('../../lib/sqlite3');
function randomString() {
......@@ -10,13 +9,13 @@ function randomString() {
return str;
};
var db = new sqlite3.Database('big.db');
var db = new sqlite3.Database('test/support/big.db');
var count = 10000000;
db.serialize(function() {
db.run("CREATE TABLE foo (id INT, txt TEXT)");
db.run("BEGIN TRANSACTION");
var stmt = db.prepare("INSERT INTO foo VALUES(?, ?)");
for (var i = 0; i < count; i++) {
......@@ -24,5 +23,4 @@ db.serialize(function() {
}
stmt.finalize();
db.run("COMMIT TRANSACTION");
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment