This is an automated email from the ASF dual-hosted git repository.

maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit c3926f05beabfdeb757fd2ad03b20c5aea83fce4
Author: HustonMmmavr <[email protected]>
AuthorDate: Tue Jan 24 09:35:13 2023 -0800

    test/regress: fix misleading error message
    
    This patch fixes misleading error message when test binaries
    `pg_regress/pg_isolation2_regress` are executed with the newer version
    of `.pm` scripts.
    
    For example: test binaries are builded at previous gpdb version
    (previous commit) and `./configure` script is called again, so
    `src/test/regress/GPTest.pm` (which stores version of gpdb at
    `$VERSION` constant) file is generated with newer version. And run of
    these tests exits with next error message: "The program "gpdiff.pl" is
    needed by pg_regress but was not found in the same\n directory as
    "/.../src/test/regress/pg_regress". But the real problem is next:
    `GP_VERSION` from binaries doesn't equal `$VERSION` from `GPTest.pm`
    script.
---
 src/test/regress/pg_regress.c | 40 ++++++++++++++++++++++++++++------------
 1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index aa35e345c9..99d7c5c827 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -2511,6 +2511,24 @@ run_single_test(const char *test, test_start_function 
startfunc,
        status_end();
 }
 
+/*
+ * Get error message pattern based on return code
+ */
+static const char *
+get_helper_err_pattern(int rc)
+{
+       if (rc == -2)
+       {
+               return "The program \"%s\" is needed by %s "
+                       "has differece in build version (check \"GpTest.pm\" 
import) with "
+                       "\"%s\".\nPlease rebuild tests or reconfigure the 
project.\n";
+       }
+       /* default error message pattern */
+       return "The program \"%s\" is needed by %s "
+               "but was not found in the same directory as \"%s\".\n"
+               "Please check that file exists (or is it a regular file).\n";
+}
+
 /*
  * Find the other binaries that we need. Currently, gpdiff.pl and
  * gpstringsubs.pl.
@@ -2518,31 +2536,29 @@ run_single_test(const char *test, test_start_function 
startfunc,
 static void
 find_helper_programs(const char *argv0)
 {
-       if (find_other_exec(argv0, "gpdiff.pl", "gpdiff.pl " GP_VERSION"\n", 
gpdiffprog) != 0)
+       int             rc;
+       char            full_path[MAXPGPATH];
+       const char      *msg;
+
+       if ((rc = find_other_exec(argv0, "gpdiff.pl", "gpdiff.pl " 
GP_VERSION"\n", gpdiffprog)) != 0)
        {
-               char            full_path[MAXPGPATH];
+               msg = get_helper_err_pattern(rc);
 
                if (find_my_exec(argv0, full_path) < 0)
                        strlcpy(full_path, progname, sizeof(full_path));
 
-               fprintf(stderr,
-                               _("The program \"gpdiff.pl\" is needed by %s "
-                                 "but was not found in the same directory as 
\"%s\".\n"),
-                               progname, full_path);
+               fprintf(stderr, _(msg), "gpdiff.pl", progname, full_path);
                exit(1);
        }
 
-       if (find_other_exec(argv0, "gpstringsubs.pl", "gpstringsubs.pl " 
GP_VERSION"\n", gpstringsubsprog) != 0)
+       if ((rc = find_other_exec(argv0, "gpstringsubs.pl", "gpstringsubs.pl " 
GP_VERSION"\n", gpstringsubsprog)) != 0)
        {
-               char            full_path[MAXPGPATH];
+               msg = get_helper_err_pattern(rc);
 
                if (find_my_exec(argv0, full_path) < 0)
                        strlcpy(full_path, progname, sizeof(full_path));
 
-               fprintf(stderr,
-                               _("The program \"gpstringsubs.pl\" is needed by 
%s "
-                                 "but was not found in the same directory as 
\"%s\".\n"),
-                               progname, full_path);
+               fprintf(stderr, _(msg), "gpstringsubs.pl", progname, full_path);
                exit(1);
        }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to