Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libcurses/director tests/libcurses: use a single m...



details:   https://anonhg.NetBSD.org/src/rev/af25534bcd4c
branches:  trunk
changeset: 1018586:af25534bcd4c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 07 21:33:27 2021 +0000

description:
tests/libcurses: use a single message style for diagnostics

Previously, there were several concurring styles:

        $msg in line %zu of file %s
        $msg line %zu of file %s
        %s, %zu: $msg

All these are now replaced with "%s:%zu: $msg".

diffstat:

 tests/lib/libcurses/director/testlang_parse.y |  255 +++++++++++++------------
 1 files changed, 129 insertions(+), 126 deletions(-)

diffs (truncated from 574 to 300 lines):

diff -r f0a9a6733838 -r af25534bcd4c tests/lib/libcurses/director/testlang_parse.y
--- a/tests/lib/libcurses/director/testlang_parse.y     Sun Feb 07 21:24:50 2021 +0000
+++ b/tests/lib/libcurses/director/testlang_parse.y     Sun Feb 07 21:33:27 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: testlang_parse.y,v 1.33 2021/02/07 20:48:07 rillig Exp $       */
+/*     $NetBSD: testlang_parse.y,v 1.34 2021/02/07 21:33:27 rillig Exp $       */
 
 /*-
  * Copyright 2009 Brett Lymn <blymn%NetBSD.org@localhost>
@@ -198,7 +198,7 @@
 %%
 
 statements     : /* empty */
-               | statement eol statements
+               | statement EOL statements
                ;
 
 statement      : assign
@@ -290,8 +290,8 @@
        var_t *vptr;
 
        if (command.returns[0].data_index == -1)
-               err(1, "Undefined variable in check statement, line %zu"
-                   " of file %s", line, cur_file);
+               err(1, "%s:%zu: Undefined variable in check statement",
+                   cur_file, line);
 
        if (command.returns[1].data_type == data_var) {
                vptr = &vars[command.returns[1].data_index];
@@ -315,8 +315,7 @@
        if (((command.returns[1].data_type == data_byte) &&
             (vars[command.returns[0].data_index].type != data_byte)))
                err(1, "Var type %s (%d) does not match return type %s (%d)",
-                   enum_names[
-                   vars[command.returns[0].data_index].type],
+                   enum_names[vars[command.returns[0].data_index].type],
                    vars[command.returns[0].data_index].type,
                    enum_names[command.returns[1].data_type],
                    command.returns[1].data_type);
@@ -370,8 +369,7 @@
                break;
 
        default:
-               err(1, "Malformed check statement at line %zu "
-                   "of file %s", line, cur_file);
+               err(1, "%s:%zu: Malformed check statement", cur_file, line);
                break;
        }
 
@@ -382,8 +380,8 @@
 delay          : DELAY numeric {
        /* set the inter-character delay */
        if (sscanf($2, "%d", &input_delay) == 0)
-               err(1, "delay specification %s could not be converted to "
-                   "numeric at line %zu of file %s", $2, line, cur_file);
+               err(1, "%s:%zu: Delay specification %s must be an int",
+                   cur_file, line, $2);
        if (verbose) {
                fprintf(stderr, "Set input delay to %d ms\n", input_delay);
        }
@@ -409,8 +407,7 @@
 
 input          : INPUT STRING {
        if (input_str != NULL) {
-               warnx("%s, %zu: Discarding unused input string",
-                   cur_file, line);
+               warnx("%s:%zu: Discarding unused input string", cur_file, line);
                free(input_str);
        }
 
@@ -424,8 +421,7 @@
 
 noinput                : NOINPUT {
        if (input_str != NULL) {
-               warnx("%s, %zu: Discarding unused input string",
-                   cur_file, line);
+               warnx("%s:%zu: Discarding unused input string", cur_file, line);
                free(input_str);
        }
 
@@ -582,9 +578,6 @@
                }
                ;
 
-eol            : EOL
-               ;
-
 %%
 
 static void
@@ -600,7 +593,7 @@
        if (strnvisx(dst, dstlen, data, datalen, VIS_WHITE | VIS_OCTAL) == -1)
                err(1, "strnvisx");
 
-       warnx("%s, %zu: [%s] Excess %zu bytes%s [%s]",
+       warnx("%s:%zu: [%s] Excess %zu bytes%s [%s]",
            fname, lineno, func, datalen, comment, dst);
        free(dst);
 }
@@ -704,8 +697,8 @@
 
        case data_var:
                if ((i = find_var_index((char *) arg)) < 0)
-                       err(1, "Variable %s is undefined at line %zu "
-                           "of file %s", (char *) arg, line, cur_file);
+                       err(1, "%s:%zu: Variable %s is undefined",
+                           cur_file, line, (const char *) arg);
 
                switch (vars[i].type) {
 
@@ -716,17 +709,16 @@
                        break;
 
                default:
-                       err(1, "Variable %s is not a valid type for cchar"
-                           " at line %zu of file %s", (char *) arg, line,
-                           cur_file);
+                       err(1, "%s:%zu: Variable %s has invalid type for cchar",
+                           cur_file, line, (const char *) arg);
                        break;
 
                }
                break;
 
        default:
-               err(1, "add_to_vals: Unhandled type for vals array "
-                   "at line %zu of file %s", line, cur_file);
+               err(1, "%s:%zu: Internal error: Unhandled type for vals array",
+                   cur_file, line);
 
                /* if we get here without a value then tidy up */
                if ((nvals == 0) && (have_malloced == 1)) {
@@ -784,16 +776,16 @@
        attr_t attribs;
 
        if (nvals >= CURSES_CCHAR_MAX)
-               err(1, "%s: too many characters in complex char type at "
-                       "line %zu of file %s", __func__, line, cur_file);
+               err(1, "%s:%zu: %s: too many characters in complex char type",
+                   cur_file, line, __func__);
 
        i = find_var_index(name);
        if (i < 0)
                i = assign_var(name);
 
        if (sscanf((char *) attributes, "%d", &attribs) != 1)
-               err(1, "%s: conversion of attributes to integer failed at"
-                       "line %zu of file %s", __func__, line, cur_file);
+               err(1, "%s:%zu: %s: conversion of attributes to integer failed",
+                   cur_file, line, __func__);
 
        vars[i].type = data_cchar;
        vars[i].cchar.attributes = attribs;
@@ -881,8 +873,8 @@
        if (cur.arg_type == data_var) {
                cur.var_index = find_var_index(arg);
                if (cur.var_index < 0)
-                       err(1, "Invalid variable %s at line %zu of file %s",
-                           str, line, cur_file);
+                       err(1, "%s:%zu: Invalid variable %s",
+                           cur_file, line, str);
        } else if (cur.arg_type == data_byte) {
                ret = arg;
                cur.arg_len = ret->data_len;
@@ -1037,15 +1029,15 @@
                if (check_file_flag & GEN_CHECK_FILE)
                        create_check_file = 1;
                else
-                       err(2, "failed to open file %s line %zu of file %s",
-                               check_file, line, cur_file);
+                       err(2, "%s:%zu: failed to open file %s",
+                           cur_file, line, check_file);
        }
 
        if (create_check_file) {
                check_fd = open(check_file, O_WRONLY | O_CREAT, 0644);
                if (check_fd < 0) {
-                       err(2, "failed to create file %s line %zu of file %s",
-                               check_file, line, cur_file);
+                       err(2, "%s:%zu: failed to create file %s",
+                           cur_file, line, check_file);
                }
        }
 
@@ -1114,9 +1106,9 @@
                }
 
                if (!create_check_file && ref != data) {
-                       errx(2, "%s, %zu: refresh data from slave does "
-                           "not match expected from file %s offs %zu "
-                           "[reference 0x%x (%c) != slave 0x%x (%c)]",
+                       errx(2, "%s:%zu: refresh data from slave does "
+                           "not match expected from file %s offset %zu "
+                           "[reference 0x%02x (%c) != slave 0x%02x (%c)]",
                            cur_file, line, check_file, offs,
                            ref, (ref >= ' ') ? ref : '-',
                            data, (data >= ' ') ? data : '-');
@@ -1216,7 +1208,7 @@
                }
 
                if (input_str == NULL)
-                       errx(2, "%s, %zu: Call to input function "
+                       errx(2, "%s:%zu: Call to input function "
                            "but no input defined", cur_file, line);
 
                fds[0].fd = slvpipe[READ_PIPE];
@@ -1231,7 +1223,7 @@
                        if (poll(fds, 2, 0) < 0)
                                err(2, "poll failed");
                        if (fds[0].revents & POLLIN) {
-                               warnx("%s, %zu: Slave function "
+                               warnx("%s:%zu: Slave function "
                                    "returned before end of input string",
                                    cur_file, line);
                                break;
@@ -1243,7 +1235,7 @@
                                    *p);
                        }
                        if (write(master, p, 1) != 1) {
-                               warn("%s, %zu: Slave function write error",
+                               warn("%s:%zu: Slave function write error",
                                    cur_file, line);
                                break;
                        }
@@ -1427,7 +1419,7 @@
        if (result < 0)
                err(2, "Poll of slave pty failed");
        else if (result > 0)
-               warnx("%s, %zu: Unexpected data from slave", cur_file, line);
+               warnx("%s:%zu: Unexpected data from slave", cur_file, line);
 }
 
 /*
@@ -1447,11 +1439,11 @@
                if ((byte_response->data_type == data_byte) ||
                    (byte_response->data_type == data_err) ||
                    (byte_response->data_type == data_ok))
-                       err(1, "%s: expecting type %s, received type %s"
-                           " at line %zu of file %s", __func__,
+                       err(1,
+                           "%s:%zu: %s: expecting type %s, received type %s",
+                           cur_file, line, __func__,
                            enum_names[command.returns[i].data_type],
-                           enum_names[byte_response->data_type],
-                           line, cur_file);
+                           enum_names[byte_response->data_type]);
 
                response = byte_response->data_value;
        }
@@ -1488,8 +1480,7 @@
                break;
 
        default:
-               err(1, "Malformed statement at line %zu of file %s",
-                   line, cur_file);
+               err(1, "%s:%zu: Malformed statement", cur_file, line);
                break;
        }
 }
@@ -1537,9 +1528,8 @@
                break;
 
        default:
-               err(1,
-                   "Invalid return type for reference at line %zu of file %s",
-                   line, cur_file);
+               err(1, "%s:%zu: Invalid return type for reference",
+                   cur_file, line);
                break;
        }
 }
@@ -1553,17 +1543,18 @@
 {
        if (((check == 0) && (expected != value->data_type)) ||
            ((check == 1) && (expected == value->data_type)))
-               err(1, "Validate expected type %s %s %s line %zu of file %s",
+               err(1, "%s:%zu: Validate expected type %s %s %s",
+                   cur_file, line,
                    enum_names[expected],
                    (check == 0)? "matching" : "not matching",
-                   enum_names[value->data_type], line, cur_file);
+                   enum_names[value->data_type]);
 
        if (verbose) {
-               fprintf(stderr, "Validate expected type %s %s %s line %zu"
-                   " of file %s\n",
+               fprintf(stderr, "%s:%zu: Validated expected type %s %s %s\n",
+                   cur_file, line,
                    enum_names[expected],
                    (check == 0)? "matching" : "not matching",
-                   enum_names[value->data_type], line, cur_file);
+                   enum_names[value->data_type]);
        }
 }
 
@@ -1576,15 +1567,18 @@
 {
        if (((check == 0) && strcmp(expected, value) != 0) ||
            ((check == 1) && strcmp(expected, value) == 0))



Home | Main Index | Thread Index | Old Index