add test for installed library

This commit is contained in:
Pedro 2016-02-27 16:40:24 +01:00
parent ad072dd79d
commit ef7c3cf349
4 changed files with 14 additions and 8 deletions

View File

@ -1,4 +1,6 @@
language: cpp
install: install:
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get -qq update - sudo apt-get -qq update
@ -9,12 +11,9 @@ install:
- which g++ - which g++
- g++ -v - g++ -v
language: cpp
compiler: compiler:
- gcc - gcc
script: script:
- make - make
- sudo make install - make test
- make test

View File

@ -62,6 +62,11 @@ format:
test: $(BIN)/sql_tests $(BIN)/sql_grammar_test test: $(BIN)/sql_tests $(BIN)/sql_grammar_test
bash test/test.sh bash test/test.sh
# test whete
test_install:
make -C example/
./example/example "SELECT * FROM students WHERE name = 'Max Mustermann';"
$(BIN)/sql_tests: library $(BIN)/sql_tests: library
@mkdir -p $(BIN)/ @mkdir -p $(BIN)/
$(CC) $(CTESTFLAGS) $(TESTCPP) test/sql_tests.cpp -o $(BIN)/sql_tests -lsqlparser $(CC) $(CTESTFLAGS) $(TESTCPP) test/sql_tests.cpp -o $(BIN)/sql_tests -lsqlparser

View File

@ -16,20 +16,21 @@ int main(int argc, char *argv[]) {
std::string query = argv[1]; std::string query = argv[1];
// parse a given query // parse a given query
hsql::SQLStatementList* result = hsql::SQLParser::parseSQLString(query); hsql::SQLParserResult* result = hsql::SQLParser::parseSQLString(query);
// check whether the parsing was successful // check whether the parsing was successful
if (result->isValid) { if (result->isValid) {
printf("Parsed successfully!\n"); printf("Parsed successfully!\n");
printf("Number of statements: %lu\n", result->numStatements()); printf("Number of statements: %lu\n", result->size());
for (hsql::SQLStatement* stmt : result->statements) { for (hsql::SQLStatement* stmt : result->statements) {
// process the statements... // process the statements...
hsql::printStatementInfo(stmt); hsql::printStatementInfo(stmt);
} }
return 0;
} else { } else {
printf("Invalid SQL!\n"); printf("Invalid SQL!\n");
return -1;
} }
return 0;
} }

View File

@ -1,3 +1,4 @@
#!/bin/bash
# has to be executed from the root of the repository # has to be executed from the root of the repository
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./