Skip to content

Commit

Permalink
Added regression test for the dictionary setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dvarrazzo committed Apr 23, 2011
1 parent 465860b commit 07b5623
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ dict/HEADER
dict/italian_ispell.affix
dict/italian_ispell.dict
dict/italian_ispell.stop

src/results
src/regression.diffs
src/regression.out
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ DOCFILES = README.rst LEGGIMI.rst COPYING CHANGES \
META.json $(EXTENSION).control
SRCFILES = Makefile $(EXTENSION).sql uninstall_$(EXTENSION).sql
DICTFILES = italian_ispell.dict italian_ispell.affix italian_ispell.stop
DISTFILES = $(addprefix build/, $(SRCFILES) $(DOCFILES) $(DICTFILES))
TESTFILES = $(patsubst src/%,%,$(wildcard src/test/sql/*.sql) $(wildcard src/test/expected/*.out))
DISTFILES = $(addprefix build/, $(SRCFILES) $(DOCFILES) $(DICTFILES) $(TESTFILES))

VERSION = $(shell cat VERSION)
PKGNAME = $(EXTENSION)-$(VERSION)
Expand Down Expand Up @@ -35,7 +36,7 @@ build/% : src/%.in
cat $< | $(FILTER_VAR) > $@

build/% : src/%
@mkdir -p build
@mkdir -p $(dir $@)
cat < $< > $@

build/% : %
Expand Down
3 changes: 3 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ PG91 = $(shell $(PG_CONFIG) --version | grep -qE " 8\.| 9\.0" && echo pre91 || e
DATA_TSEARCH = italian_ispell.dict italian_ispell.affix italian_ispell.stop
DOCS = README.rst LEGGIMI.rst

# the += doesn't work if the user specified his own REGRESS_OPTS
REGRESS = --inputdir=test setup-$(PG91) italian_fts

ifeq ($(PG91),91)
INSTALLSCRIPT = $(EXTENSION)--$(EXTVERSION).sql
UNINSTALLSCRIPT =
Expand Down
32 changes: 32 additions & 0 deletions src/test/expected/italian_fts.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--
-- Test italian_fts configuration
--
select token, dictionary, lexemes
from ts_debug('italian_ispell', $$
Né più mai toccherò le sacre sponde
ove il mio corpo fanciulletto giacque,
Zacinto mia, che te specchi nell'onde
del greco mar da cui vergine nacque
...
$$)
where array_upper(lexemes,1) <> 0;
token | dictionary | lexemes
--------------+----------------+----------------
più | italian_ispell | {più}
mai | italian_ispell | {mai}
toccherò | italian_ispell | {toccare}
sacre | italian_ispell | {sacro}
sponde | italian_ispell | {sponda}
ove | italian_ispell | {ove}
corpo | italian_ispell | {corpo}
fanciulletto | italian_ispell | {fanciulletto}
giacque | italian_ispell | {giacere}
Zacinto | italian_stem | {zacint}
specchi | italian_ispell | {specchiare}
onde | italian_ispell | {onda}
greco | italian_ispell | {greco}
mar | italian_ispell | {mare}
vergine | italian_ispell | {vergine}
nacque | italian_ispell | {nascere}
(16 rows)

3 changes: 3 additions & 0 deletions src/test/expected/setup-91.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SET client_min_messages = warning;
\set ECHO none
RESET client_min_messages;
3 changes: 3 additions & 0 deletions src/test/expected/setup-pre91.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SET client_min_messages = warning;
\set ECHO none
RESET client_min_messages;
13 changes: 13 additions & 0 deletions src/test/sql/italian_fts.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--
-- Test italian_fts configuration
--

select token, dictionary, lexemes
from ts_debug('italian_ispell', $$
Né più mai toccherò le sacre sponde
ove il mio corpo fanciulletto giacque,
Zacinto mia, che te specchi nell'onde
del greco mar da cui vergine nacque
...
$$)
where array_upper(lexemes,1) <> 0;
13 changes: 13 additions & 0 deletions src/test/sql/setup-91.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SET client_min_messages = warning;
\set ECHO none
-- The above turn off echoing so that expected file
-- does not depend on contents of the setup file.

-- Setup the extension on PostgreSQL 9.1


CREATE EXTENSION italian_fts;

\set ECHO all
RESET client_min_messages;

12 changes: 12 additions & 0 deletions src/test/sql/setup-pre91.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
SET client_min_messages = warning;
\set ECHO none
-- The above turn off echoing so that expected file
-- does not depend on contents of the setup file.

-- Setup the extension on PostgreSQL before 9.1

\i italian_fts.sql

\set ECHO all
RESET client_min_messages;

0 comments on commit 07b5623

Please sign in to comment.