From 729a894967e6e0cc1999617ad18c7278f9263a8c Mon Sep 17 00:00:00 2001 From: Michael Cuffaro Date: Tue, 7 Nov 2023 14:44:34 -0500 Subject: [PATCH] add guess test files --- Makefile | 27 ++++++++++++---- test/guess_test_data/column.tsv | 53 +++++++++++++++++++++++++++++++ test/guess_test_data/datatype.tsv | 22 +++++++++++++ test/guess_test_data/rule.tsv | 9 ++++++ test/guess_test_data/table.tsv | 11 +++++++ 5 files changed, 115 insertions(+), 7 deletions(-) create mode 100644 test/guess_test_data/column.tsv create mode 100644 test/guess_test_data/datatype.tsv create mode 100644 test/guess_test_data/rule.tsv create mode 100644 test/guess_test_data/table.tsv diff --git a/Makefile b/Makefile index d13430b5..d2bd4a2b 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ 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 @@ -22,12 +22,17 @@ doc: 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 $< $@ @@ -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,$^) $| @@ -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,$^) $@ @@ -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 diff --git a/test/guess_test_data/column.tsv b/test/guess_test_data/column.tsv new file mode 100644 index 00000000..552b1036 --- /dev/null +++ b/test/guess_test_data/column.tsv @@ -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 diff --git a/test/guess_test_data/datatype.tsv b/test/guess_test_data/datatype.tsv new file mode 100644 index 00000000..c118588d --- /dev/null +++ b/test/guess_test_data/datatype.tsv @@ -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 diff --git a/test/guess_test_data/rule.tsv b/test/guess_test_data/rule.tsv new file mode 100644 index 00000000..3a9356ff --- /dev/null +++ b/test/guess_test_data/rule.tsv @@ -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' diff --git a/test/guess_test_data/table.tsv b/test/guess_test_data/table.tsv new file mode 100644 index 00000000..1fcc8584 --- /dev/null +++ b/test/guess_test_data/table.tsv @@ -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)