Change postgresql test database to prepend the cpu string so that running two builders on the Mac Pro build machine will not cause random failures due to interference.
parent
29f6011817
commit
deb1ac9e1d
|
@ -38,6 +38,11 @@ TUPLE: sql-function-missing < sql-error message ;
|
|||
\ sql-function-missing new
|
||||
swap >>message ;
|
||||
|
||||
TUPLE: sql-database-exists < sql-error message ;
|
||||
: <sql-database-exists> ( message -- error )
|
||||
\ sql-database-exists new
|
||||
swap >>message ;
|
||||
|
||||
: ignore-error ( quot word -- )
|
||||
'[ dup _ execute [ drop ] [ rethrow ] if ] recover ; inline
|
||||
|
||||
|
@ -52,3 +57,6 @@ TUPLE: sql-function-missing < sql-error message ;
|
|||
|
||||
: ignore-function-missing ( quot -- )
|
||||
\ sql-function-missing? ignore-error ; inline
|
||||
|
||||
: ignore-database-exists ( quot -- )
|
||||
\ sql-database-exists? ignore-error ; inline
|
||||
|
|
|
@ -15,6 +15,10 @@ TableError =
|
|||
| Error ("relation "|"table ")(!(" does not exist").)+:table " does not exist"
|
||||
=> [[ table >string unquote <sql-table-missing> ]]
|
||||
|
||||
DatabaseError =
|
||||
Error ("database")(!(" already exists").)+:database " already exists"
|
||||
=> [[ database >string <sql-database-exists> ]]
|
||||
|
||||
FunctionError =
|
||||
Error "function" (!(" already exists").)+:table " already exists"
|
||||
=> [[ table >string <sql-function-exists> ]]
|
||||
|
@ -29,7 +33,7 @@ SyntaxError =
|
|||
|
||||
UnknownError = .* => [[ >string <sql-unknown-error> ]]
|
||||
|
||||
PostgresqlSqlError = (TableError | FunctionError | SyntaxError | UnknownError)
|
||||
PostgresqlSqlError = (TableError | DatabaseError | FunctionError | SyntaxError | UnknownError)
|
||||
|
||||
;EBNF
|
||||
|
||||
|
|
|
@ -3,7 +3,9 @@ prettyprint sequences namespaces tools.test db db.private
|
|||
db.tuples db.types unicode.case accessors system db.tester ;
|
||||
IN: db.postgresql.tests
|
||||
|
||||
|
||||
os windows? cpu x86.64? and [
|
||||
! Ensure the table exists
|
||||
[ ] [ postgresql-test-db [ ] with-db ] unit-test
|
||||
|
||||
[ ] [
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
! Copyright (C) 2008 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors kernel math namespaces make sequences random
|
||||
strings math.parser math.intervals combinators math.bitwise
|
||||
nmake db db.tuples db.types classes words shuffle arrays
|
||||
destructors continuations db.tuples.private prettyprint
|
||||
db.private byte-arrays ;
|
||||
USING: accessors arrays byte-arrays classes combinators
|
||||
continuations db db.errors db.private db.tuples
|
||||
db.tuples.private db.types destructors kernel make math
|
||||
math.bitwise math.intervals math.parser namespaces nmake
|
||||
prettyprint random sequences shuffle strings words fry ;
|
||||
IN: db.queries
|
||||
|
||||
GENERIC: where ( specs obj -- )
|
||||
|
@ -208,3 +208,9 @@ M: db-connection <count-statement> ( query -- statement )
|
|||
|
||||
: drop-index ( index-name -- )
|
||||
[ "drop index " % % ] "" make sql-command ;
|
||||
|
||||
: create-database ( string -- )
|
||||
"create database " ";" surround sql-command ;
|
||||
|
||||
: ensure-database ( string -- )
|
||||
'[ _ create-database ] ignore-database-exists ;
|
||||
|
|
|
@ -3,20 +3,30 @@
|
|||
USING: concurrency.combinators db.pools db.sqlite db.tuples
|
||||
db.types kernel math random threads tools.test db sequences
|
||||
io prettyprint db.postgresql accessors io.files.temp
|
||||
namespaces fry system math.parser ;
|
||||
namespaces fry system math.parser db.queries assocs ;
|
||||
IN: db.tester
|
||||
|
||||
: postgresql-test-db-name ( -- string )
|
||||
cpu name>> "-" "factor-test" 3append
|
||||
H{ { CHAR: - CHAR: _ } { CHAR: . CHAR: _ } } substitute ;
|
||||
|
||||
: postgresql-test-db ( -- postgresql-db )
|
||||
<postgresql-db>
|
||||
"localhost" >>host
|
||||
"postgres" >>username
|
||||
"thepasswordistrust" >>password
|
||||
"factor-test" >>database ;
|
||||
postgresql-test-db-name >>database ;
|
||||
|
||||
: postgresql-template1-db ( -- postgresql-db )
|
||||
<postgresql-db>
|
||||
"localhost" >>host
|
||||
"postgres" >>username
|
||||
"thepasswordistrust" >>password
|
||||
"template1" >>database ;
|
||||
|
||||
: sqlite-test-db ( -- sqlite-db )
|
||||
"tuples-test.db" temp-file <sqlite-db> ;
|
||||
|
||||
|
||||
! These words leak resources, but are useful for interactivel testing
|
||||
: set-sqlite-db ( -- )
|
||||
sqlite-db db-open db-connection set ;
|
||||
|
@ -31,6 +41,10 @@ IN: db.tester
|
|||
] call ; inline
|
||||
|
||||
: test-postgresql ( quot -- )
|
||||
postgresql-template1-db [
|
||||
postgresql-test-db-name ensure-database
|
||||
] with-db
|
||||
|
||||
'[
|
||||
os windows? cpu x86.64? and [
|
||||
[ ] [ postgresql-test-db _ with-db ] unit-test
|
||||
|
|
Loading…
Reference in New Issue