Skip to content

Commit

Permalink
add guess test files
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcmicu committed Nov 7, 2023
1 parent 33ce7af commit 729a894
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 7 deletions.
27 changes: 20 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,25 @@ build:

.PHONY: doc time test sqlite_test pg_test
.PHONY: api_test sqlite_api_test pg_qpi_test
.PHONY: random_test_data random_test sqlite_random_test pg_random_test
.PHONY: random_test_data random_test sqlite_random_test pg_random_test valve_debug valve_release

doc:
cargo doc --document-private-items

readme:
cargo readme --no-title > README.md

valve: src/*.rs src/*.lalrpop
valve: valve_debug

valve_release: src/*.rs src/*.lalrpop
rm -f valve
cargo build --release
ln -s target/release/ontodev_valve valve
# cargo build
# ln -s target/debug/ontodev_valve valve

valve_debug: src/*.rs src/*.lalrpop
rm -f valve
cargo build
ln -s target/debug/ontodev_valve valve

build/valve.db: test/src/table.tsv valve clean | build
./valve $< $@
Expand Down Expand Up @@ -93,7 +98,7 @@ random_test_dir = test/random_test_data
random_test: sqlite_random_test pg_random_test

$(random_test_dir)/ontology:
mkdir -p $(random_test_dir)/ontology
mkdir -p $@

random_test_data: test/generate_random_test_data.py valve valve test/random_test_data/table.tsv | $(random_test_dir)/ontology
./$< $$(date +"%s") 100 5 $(word 3,$^) $|
Expand All @@ -110,7 +115,15 @@ pg_random_test: valve clean random_test_data | build test/output
test/round_trip.sh postgresql:///valve_postgres $(random_test_dir)/table.tsv
@echo "Test succeeded!"

test/perf_test_data/ontology: test/generate_random_test_data.py valve test/random_test_data/table.tsv
guess_test_dir = test/guess_test_data

$(guess_test_dir)/ontology:
mkdir -p $@

guess_test_data: test/generate_random_test_data.py valve valve $(guess_test_dir)/table.tsv | $(guess_test_dir)/ontology
./$< $$(date +"%s") 10000 5 $(word 3,$^) $|

test/perf_test_data/ontology: test/generate_random_test_data.py valve test/perf_test_data/table.tsv
mkdir $@
./$< 1 10000 5 $(word 3,$^) $@

Expand All @@ -136,7 +149,7 @@ pg_perf_test: valve test/perf_test_data/ontology | test/output
perf_test: sqlite_perf_test pg_perf_test

clean:
rm -Rf build/valve.db build/valve_random.db test/output $(random_test_dir)/ontology
rm -Rf build/valve.db build/valve_random.db test/output $(random_test_dir)/ontology $(guess_test_dir)/ontology

cleanperfdb:
rm -Rf build/valve_perf.db
Expand Down
53 changes: 53 additions & 0 deletions test/guess_test_data/column.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
table column label nulltype datatype structure description
table table table_name table_name primary name of this table
table path path path to the TSV file for this table, relative to the table.tsv file
table type empty table_type type of this table, used for tables with special meanings
table description empty description a description of this table
column table table_name from(table.table) the table that this column belongs to
column column column_name the name of this column
column label empty label the human-readable label for this column
column nulltype empty datatype_name from(datatype.datatype) the datatype for NULL values in this column
column datatype datatype_name from(datatype.datatype) the datatype for this column
column structure empty trimmed_line schema information for this column
column description empty description a description of this column
datatype datatype datatype_name primary the name of this datatype
datatype parent empty datatype_name tree(datatype) the parent datatype
datatype transform empty word
datatype condition empty datatype_condition
datatype structure empty trimmed_line
datatype description empty trimmed_text
datatype SQLite type empty datatype_name
datatype PostgreSQL type empty datatype_name
datatype RDF type empty datatype_name
datatype HTML type empty datatype_name
rule table table_name
rule when column column_name
rule when condition datatype_condition
rule then column column_name
rule then condition datatype_condition
rule level word
rule description empty description
table1 prefix prefix primary
table1 base IRI unique
table1 ontology IRI empty IRI
table1 version IRI empty IRI
table2 child trimmed_line
table2 parent empty trimmed_line
table2 xyzzy empty trimmed_line
table2 foo empty integer
table2 bar empty text
table3 source prefix
table3 id CURIE unique
table3 label label primary
table3 parent empty label
table3 related empty trimmed_line
table4 foreign_column text unique
table4 other_foreign_column text unique
table4 numeric_foreign_column integer primary
table5 foo word primary
table5 bar integer
table6 child integer
table6 parent empty integer
table6 xyzzy empty integer
table6 foo empty text
table6 bar empty integer
22 changes: 22 additions & 0 deletions test/guess_test_data/datatype.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
datatype parent transform condition structure description SQLite type PostgreSQL type RDF type HTML type
CURIE nonspace match(/\S+:\S+/) concat(prefix, ":", suffix) a Compact URI CURIE
IRI nonspace exclude(/\s/) an Internationalized Resource Identifier IRI
column_name trimmed_line match(/\S([^\n]*\S)*/) a column name
datatype_condition line exclude(/\n/) a datatype condition specification
datatype_name word exclude(/\W/) a datatype name
description trimmed_text match(/\S(.*\S)*/) a brief description
empty text equals('') the empty string NULL NULL null
integer nonspace match(/-?\d+/) a positive or negative integer INTEGER INTEGER
label trimmed_line match(/\S([^\n]*\S)*/)
line text exclude(/\n/) a line of text input
natural_number integer match(/\d+/) a natural number, including zero INTEGER INTEGER
nonspace trimmed_line exclude(/\s/) text without whitespace
path line exclude(/\n/) a path to a file
prefix word exclude(/\W/) a prefix for a CURIE
suffix word exclude(/\W/) a suffix for a CURIE
table_name word exclude(/\W/) a table name
table_type word lowercase in('table', 'column', 'datatype') a table type
text any text TEXT TEXT xsd:string textarea
trimmed_line line match(/\S([^\n]*\S)*/) a line of text that does not begin or end with whitespace
trimmed_text text exclude(/^\s+|\s+$/) text that does not begin or end with whitespace
word nonspace exclude(/\W/) a single word: letters, numbers, underscore
9 changes: 9 additions & 0 deletions test/guess_test_data/rule.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
table when column when condition then column then condition level description
table2 foo null bar null error bar must be null whenever foo is null
table2 foo not null bar not null error bar cannot be null if foo is not null
table2 foo IRI bar label error bar must be a label if foo is an IRI
table2 foo equals(5) bar in('y', 'z') error bar must be 'y' or 'z' if foo = 5
table6 foo null bar null error bar must be null whenever foo is null
table6 foo not null bar not null error bar cannot be null if foo is not null
table6 foo IRI bar label error bar must be a label if foo is an IRI
table6 foo equals(e) bar in(25, 26) error bar must be 25 or 26 if foo = 'e'
11 changes: 11 additions & 0 deletions test/guess_test_data/table.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
table path description type
column test/guess_test_data/column.tsv Columns for all of the tables. column
datatype test/guess_test_data/datatype.tsv Datatypes for all of the columns datatype
rule test/guess_test_data/rule.tsv More complex "when" rules rule
table test/guess_test_data/table.tsv All of the user-editable tables in this project. table
table1 test/guess_test_data/ontology/table1.tsv The first data table
table2 test/guess_test_data/ontology/table2.tsv The second data table
table3 test/guess_test_data/ontology/table3.tsv The third data table
table4 test/guess_test_data/ontology/table4.tsv The fourth data table
table5 test/guess_test_data/ontology/table5.tsv The fifth data table
table6 test/guess_test_data/ontology/table6.tsv The sixth data table (like table2 but all numeric)

0 comments on commit 729a894

Please sign in to comment.