diff --git a/tools/developer/run.sh b/tools/developer/run.sh index 1a6480008e..e863501185 100755 --- a/tools/developer/run.sh +++ b/tools/developer/run.sh @@ -59,16 +59,18 @@ function set_cmake { #cmake -DWITH_DOC=ON -DBUILD_DOXY=ON .. # Building using clang - #CXX=clang++ CC=clang cmake -DPOSTGRESQL_BIN=${PGBIN} -DCMAKE_BUILD_TYPE=Debug .. + #CXX=clang++ CC=clang cmake -DPOSTGRESQL_BIN=${PGBIN} -DCMAKE_BUILD_TYPE=Debug -DDOC_USE_BOOTSTRAP=ON -DWITH_DOC=ON -DBUILD_DOXY=OFF .. + # Building with debug on #cmake -DPOSTGRESQL_BIN=${PGBIN} -DDOC_USE_BOOTSTRAP=ON -DWITH_DOC=ON -DBUILD_DOXY=ON -DBUILD_LATEX=ON -DCMAKE_BUILD_TYPE=Debug -DES=ON -DPROJECT_DEBUG=ON .. - # building languages -DES=ON -DJA=ON -DZH_HANS=ON -DDE=ON -DKO=ON - #cmake -DPOSTGRESQL_BIN=${PGBIN} -DDOC_USE_BOOTSTRAP=ON -DWITH_DOC=ON -DBUILD_DOXY=ON -DBUILD_LATEX=ON -DES=ON -DCMAKE_BUILD_TYPE=Debug .. + # building languages -DES=ON -DJA=ON -DZH_HANS=ON -DDE=ON -DKO=ON and CMAKE_EXPORT_COMPILE_COMMANDS for static analysis tools. + #cmake -DPOSTGRESQL_BIN=${PGBIN} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DDOC_USE_BOOTSTRAP=ON -DWITH_DOC=ON -DBUILD_DOXY=ON -DBUILD_LATEX=ON -DES=ON -DCMAKE_BUILD_TYPE=Debug .. # check link in documentation #cmake -DPOSTGRESQL_BIN=${PGBIN} -DDOC_USE_BOOTSTRAP=ON -DWITH_DOC=ON -DES=ON -DLINKCHECK=ON -DCMAKE_BUILD_TYPE=Release .. + # build only english cmake -DPOSTGRESQL_BIN=${PGBIN} -DDOC_USE_BOOTSTRAP=ON -DWITH_DOC=ON -DBUILD_DOXY=ON -DBUILD_LATEX=ON -DCMAKE_BUILD_TYPE=Debug .. } @@ -105,14 +107,16 @@ function set_compiler { echo ------------------------------------ if [ -n "$1" ]; then - update-alternatives --set gcc "/usr/bin/gcc-$1" + export CC="/usr/bin/gcc-$1" + export CXX="/usr/bin/g++-$1" fi } function build_doc { pushd build > /dev/null || exit 1 #rm -rf doc/* ; rm -rf locale/*/*/*.mo - rm -rf doc/* + # Clean only generated files while preserving custom content + find doc -type f \( -name "*.html" -o -name "*.pdf" \) -delete make doc #example on how to only build spanish html #make html-es @@ -123,6 +127,30 @@ function build_doc { popd > /dev/null || exit 1 } +function check { + pushd build > /dev/null || exit 1 + cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. + + # Run with error handling and report generation + cppcheck --project=compile_commands.json \ + --enable=all \ + --suppress=missingIncludeSystem \ + --error-exitcode=1 \ + --output-file=cppcheck-report.txt 2>&1 || { + echo "Static analysis failed. See build/cppcheck-report.txt for details" + return 1 + } + popd > /dev/null || exit 1 +} + +function tidy_with_clang { + local base_branch=${1:-"upstream/develop"} + .github/scripts/tidy-vs-commit.sh "$base_branch" || { + echo "clang-tidy checks failed" + return 1 + } +} + function build { pushd build > /dev/null || exit 1 set_cmake @@ -141,25 +169,30 @@ function test_compile { build echo -------------------------------------------- - echo Execute tap_directories + echo Execute documentation queries echo -------------------------------------------- - for d in ${TAP_DIRS} + for d in ${QUERIES_DIRS} do - time bash taptest.sh "${d}" "-p ${PGPORT}" + # generate the documentation queries + #tools/testers/doc_queries_generator.pl -alg "docqueries/${d}" -documentation -pgport "${PGPORT}" + # Show warnings + #tools/testers/doc_queries_generator.pl -alg "docqueries/${d}" -level WARNING -pgport "${PGPORT}" + # Compare differences on results + tools/testers/doc_queries_generator.pl -alg "docqueries/${d}" -pgport "${PGPORT}" done echo -------------------------------------------- - echo Execute documentation queries + echo Execute tap_directories echo -------------------------------------------- - for d in ${QUERIES_DIRS} + for d in ${TAP_DIRS} do - #tools/testers/doc_queries_generator.pl -alg "docqueries/${d}" -documentation -pgport "${PGPORT}" - #tools/testers/doc_queries_generator.pl -alg "docqueries/${d}" -debug1 -pgport "${PGPORT}" - tools/testers/doc_queries_generator.pl -alg "docqueries/${d}" -pgport "${PGPORT}" + time bash taptest.sh "${d}" "-p ${PGPORT}" done + tap_test + tools/testers/doc_queries_generator.pl -pgport $PGPORT + build_doc - #exit 0 tap_test action_tests } diff --git a/tools/developer/taptest.sh b/tools/developer/taptest.sh index e5461cee29..b3ab90269e 100755 --- a/tools/developer/taptest.sh +++ b/tools/developer/taptest.sh @@ -26,16 +26,35 @@ if [[ -z $1 ]]; then exit 1; fi +# run from root of repository +if ! DIR=$(git rev-parse --show-toplevel 2>/dev/null); then + echo "Error: Must be run from within the git repository" >&2 + exit 1 +fi +pushd "${DIR}" > /dev/null || exit 1 DIR="$1" shift PGFLAGS=$* +if ! VERSION=$(grep -E '^[[:space:]]*project\(PGROUTING[[:space:]]+VERSION[[:space:]]+([^[:space:];]+)' CMakeLists.txt | sed -E 's/.*VERSION[[:space:]]+([^[:space:];]+).*/\1/'); then + echo "Error: Failed to extract version from CMakeLists.txt" >&2 + exit 1 +fi + +if [[ -z "${VERSION}" ]]; then + echo "Error: Version not found in CMakeLists.txt" >&2 + exit 1 +fi echo "dir ${DIR}" echo "pgflags ${PGFLAGS}" +echo "VERSION ${VERSION}" QUIET="-v" QUIET="-q" +PGPORT="${PGPORT:-5432}" +PGUSER="${PGUSER:-$USER}" + PGDATABASE="___pgr___test___" PGRVERSION="3.6.1 3.6.0 3.5.1 3.5.0 3.2.0 3.1.3 3.0.6" PGRVERSION="3.7.2" @@ -46,49 +65,51 @@ do pushd tools/testers/ echo "--------------------------" echo " Running with version ${v}" + echo " test ${DIR}" echo "--------------------------" + # give time to developer to read message + sleep 3 dropdb --if-exists "${PGFLAGS}" "${PGDATABASE}" createdb "${PGFLAGS}" "${PGDATABASE}" - psql "$PGFLAGS" -d "$PGDATABASE" -X -q --set client_min_messages=WARNING --set ON_ERROR_STOP=1 --pset pager=off \ - -c "CREATE EXTENSION IF NOT EXISTS pgtap; CREATE EXTENSION IF NOT EXISTS pgrouting WITH VERSION '${v}' CASCADE;" - + if ! bash setup_db.sh "${PGPORT}" "${PGDATABASE}" "${PGUSER}" "${v}"; then + echo "Error: Database setup failed" >&2 + exit 1 + fi echo "--------------------------" echo " Installed version" echo "--------------------------" psql "${PGFLAGS}" -d "$PGDATABASE" -c "SELECT * FROM pgr_full_version();" - #psql "${PGFLAGS}" -d "$PGDATABASE" -c "SET client_min_messages TO DEBUG3; ALTER EXTENSION pgrouting UPDATE TO '3.7.0';" - echo "--------------------------" - echo " update version" - echo "--------------------------" - psql "${PGFLAGS}" -d "$PGDATABASE" -c "SELECT * FROM pgr_full_version();" + popd - psql "${PGFLAGS}" -d "$PGDATABASE" -X -q --set client_min_messages=WARNING --set ON_ERROR_STOP=1 --pset pager=off \ - -f sampledata.sql \ - -f solomon_100_rc101.data.sql \ - -f innerQuery.sql \ - -f innerQuery_old.sql \ - -f inner_styles.sql \ - -f old_inner_styles.sql \ - -f no_crash_test.sql \ - -f alphaShapeTester.sql \ - -f general_pgtap_tests.sql \ - -f no_crash_general.sql \ - -f dijkstra_pgtap_tests.sql \ - -f flow_pgtap_tests.sql \ - -f trsp_tests.sql \ - -f spanningtree.sql \ - -f types_check.sql \ - -f via_compare.sql \ - -f astar_pgtap_tests.sql \ - -f compare_dijkstra.sql \ - -f allpairs_tests.sql \ - -f contraction_tapfuncs.sql\ - -f tsp_pgtap_tests.sql + if [[ "${v}" != "${VERSION}" ]] + then + # run tests on old version + pg_prove "$QUIET" --normalize --directives --recurse "${PGFLAGS}" -d "${PGDATABASE}" "pgtap/${DIR}" + + # update to this version + echo "--------------------------" + echo " update version" + echo "--------------------------" + if ! psql "${PGFLAGS}" -d "$PGDATABASE" -c "SET client_min_messages TO DEBUG3; ALTER EXTENSION pgrouting UPDATE TO '${VERSION}';"; then + echo "Error: Failed to update pgrouting extension to version ${VERSION}" >&2 + exit 1 + fi + + psql "${PGFLAGS}" -q -t -d "$PGDATABASE" -c "SELECT extversion FROM pg_extension WHERE extname = 'pgrouting';" + + # Verify update success + if ! psql "${PGFLAGS}" -q -t -d "$PGDATABASE" -c "SELECT extversion FROM pg_extension WHERE extname = 'pgrouting';" | grep -q "${VERSION}"; then + echo "Error: Extension version mismatch after update" >&2 + exit 1 + fi + fi + + # run this version's test + psql "${PGFLAGS}" -d "$PGDATABASE" -c "SELECT * FROM pgr_full_version();" - popd pg_prove "$QUIET" --normalize --directives --recurse "${PGFLAGS}" -d "${PGDATABASE}" "pgtap/${DIR}" #dropdb --if-exists "${PGFLAGS}" "${PGDATABASE}" done diff --git a/tools/testers/doc_queries_generator.pl b/tools/testers/doc_queries_generator.pl index 34cb9b5628..edcdf5f16f 100755 --- a/tools/testers/doc_queries_generator.pl +++ b/tools/testers/doc_queries_generator.pl @@ -124,8 +124,9 @@ sub Usage { elsif ($a =~ /^-c/i) { $clean = 1; } - elsif ($a =~ /^-l$/i) { - $LEVEL = $psql = shift @ARGV || Usage(); + elsif ($a =~ /^-l(evel)?/i) { + $LEVEL = shift @ARGV || Usage(); + print "The level $LEVEL\n"; } elsif ($a =~ /^-v/i) { $VERBOSE = 1;