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