From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 0BROBGMZCWefYAEAqHPOHw:P1 (envelope-from ) for ; Fri, 11 Oct 2024 14:26:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id 0BROBGMZCWefYAEAqHPOHw (envelope-from ) for ; Fri, 11 Oct 2024 14:26:11 +0200 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=BXFjC5rh; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=j5Oc6TBY; dmarc=pass (policy=none) header.from=maniero.me; spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht; arc=reject ("signature check failed: fail, {[1] = sig:mailchannels.net:reject}") ARC-Seal: i=2; s=key1; d=johnnyrichard.com; t=1728649570; a=rsa-sha256; cv=fail; b=SrSNvyXomesSokgxBYoL1BKj5AjNnDzvLGj5Fh04vxS060Bb6Z3PR0XMrqa3K1QQ3DkjKK +XgEr8VtUdUOEY6GcjIbnaiiAOV41jyOKDi/8fENHy9r5c0g45Qa1xB/m0FZeAvqGvRxJt D8NzzBm2GZFPBiC2vQ6YdqUpsJHU56vM8+3+k9nGFqM5xt2XfmeOQO4im4MoADfuW5fylt UAvrn1FEaupVMmWY5vJwHYm3zKrR9IKGUechowKA/5byCUN7kVaNMG5eO0FawS4j9dB58t 1fjts7h15bnj1oVROaO6qNTlz1XhhSEoK1Mi5nwf5JbxGRS/hao6g+axLxiuOw== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=BXFjC5rh; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=j5Oc6TBY; dmarc=pass (policy=none) header.from=maniero.me; spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht; arc=reject ("signature check failed: fail, {[1] = sig:mailchannels.net:reject}") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1728649570; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:list-id: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=Lm7O02rlmHb7KWiRAIMuf4LuNSSpTegVTz8pH6mw2Dg=; b=vYXJgkwgOWzLVhughg38FFfkSaFbxik62SpKAjVau2vRBSJQV09hSKpzC8AdeI1r1Vc6b7 hM345f+nEBD8NnOQTn0CZ6zcZpyIBctzXYxn/VanhOiEdqfcJcIB5mEJFNBqhR6kyZ8yLm fy7Mmh9RDCZnkVobc1Zqk7sk0mQDoj2Y7sVIC1IRQJdTZKQ5AQiXXpb0hRvZH/Zh0MO0Lg 9hlr8HkiB4zo8WcuKF1U/x8su291gd4qEu3lVH1RPoOQVzwm7j2arqezqs5iW/GKkXwRA4 vJNtrw0b5jb9Z5LhI7l0+1dKpHmIGhntpV+mbqHANQsB6RFE4gFApd68BxDfOw== Received: from mail-a.sr.ht (mail-a.sr.ht [46.23.81.152]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id EF79789730 for ; Fri, 11 Oct 2024 14:26:09 +0200 (CEST) DKIM-Signature: a=rsa-sha256; bh=TX/QEAFL/Qn2s4XO9bAHJaQuvIRV8CYeeGTALgjJFq4=; c=simple/simple; d=lists.sr.ht; h=From:To:Cc:Subject:Date:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-ID; q=dns/txt; s=20240113; t=1728649569; v=1; b=BXFjC5rh5tPRxUy7pQ+i1QuCD1EiW7qDM7oM+4I1VbYd5o4JZ5CbS/m4qWoUL/rgbiWma4Yc oUeHVl7ItGWusBG7EILCfHnTBF3uyZ6aHl0Y8dCgEbqoj22eQc3kxhb5xBA9HwR/xnfdHNSHFJo KcNli4eryJgSze53G6s9B9FTyfg+oZ/F1OxZsYoYAzG9ileGIJMrlKJ2enmjT1XjdDZpeeYnKgi QekmEx8H+oUeH36COjY33ziYO93tJx8mMWPAW4dQIgZw2VrcGVukwgkNWsKnhoR73be0kZDQ63Z f2KpgLY/SSdfqbneYdEb9psN3V+xpwTCKXKFokEKRMMog== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id CDE3120273 for ; Fri, 11 Oct 2024 12:26:09 +0000 (UTC) Received: from fennec.ash.relay.mailchannels.net (fennec.ash.relay.mailchannels.net [23.83.222.58]) by mail-a.sr.ht (Postfix) with ESMTPS id B6F5520030 for <~johnnyrichard/olang-devel@lists.sr.ht>; Fri, 11 Oct 2024 12:26:08 +0000 (UTC) X-Sender-Id: hostingeremail|x-authuser|carlos@maniero.me Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id C4EBA167B63 for <~johnnyrichard/olang-devel@lists.sr.ht>; Fri, 11 Oct 2024 12:26:06 +0000 (UTC) Received: from fr-int-smtpout5.hostinger.io (trex-1.trex.outbound.svc.cluster.local [100.101.174.171]) (Authenticated sender: hostingeremail) by relay.mailchannels.net (Postfix) with ESMTPA id E8F081681C3 for <~johnnyrichard/olang-devel@lists.sr.ht>; Fri, 11 Oct 2024 12:26:05 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1728649566; a=rsa-sha256; cv=none; b=gxSyIURcfTCxCXcgNai2oKCHcc/HgFe+GKzl+UYUV4k2LnY9na6E+3D0cAddVzGsOe9kEo 1I6pSOc1zTsBV/9FG9k5mao1kDse7N66bxgj2SBhLp3aCFj43n+puPymBSo7FsHJoBh5/V f/VwJ5PRpUGtOnH/wwMZCAFroxUrkUNzlEuwh0Ihmhs9hrY+o+j/hSkZTKMJEMABrU4ekh 5TYPdEtKxG8uNQeiRkxseDB8rTVKUj/r6KWm08MvLokw3t7diwb5njnFo4wydSdMuuiRZK CbJ0wkn6kzNRj6SLccgJ3M4yl4SP0h5QlqhYC+4qtdir3aAVroXC6jNbnoN8Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1728649566; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:dkim-signature; bh=T5mMRYf5xDBQFQb8zZEyuFwBWbe/EE+Ypj+Wxv4LGKo=; b=joiykf5qTF0ewS4y4O3OdPTvima1/fxqdoHh6H/wRa0mokS53RWGRejwG1LEKA/NSETfed KwPxPqP4x4GCHMc0fU+Xsry5sRnWbH7pdoTcNeLUzKXvO7QGqThv7mjX3khz/shsrITHPN JjCLkFvVmwpvuZAH2zVkMhT2/U7fct319RO8xLsatuMK5xJHTbP19iajGR+DY0cpOPgIO4 DS/9ozQXzUX8/4IsTWD6rZsdgkYBvJopFSohvsmXCLKtmt0utxuKjKaaQjRDt7IxcbfkVT 6yI2xgUHGAQUkEaPnMH6kocE1H4+hESA5WeQdepKMzj79/3I4k2gNeXn96bQ7Q== ARC-Authentication-Results: i=1; rspamd-6ddc7ff9cb-8t48w; auth=pass smtp.auth=hostingeremail smtp.mailfrom=carlos@maniero.me X-Sender-Id: hostingeremail|x-authuser|carlos@maniero.me X-MC-Relay: Neutral X-MailChannels-SenderId: hostingeremail|x-authuser|carlos@maniero.me X-MailChannels-Auth-Id: hostingeremail X-Thoughtful-Abortive: 65ba8a8c7765ad96_1728649566445_2592163495 X-MC-Loop-Signature: 1728649566445:2620131692 X-MC-Ingress-Time: 1728649566445 Received: from fr-int-smtpout5.hostinger.io (fr-int-smtpout5.hostinger.io [89.116.146.168]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.101.174.171 (trex/7.0.2); Fri, 11 Oct 2024 12:26:06 +0000 From: Carlos Maniero DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maniero.me; s=hostingermail1; t=1728649564; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Lm7O02rlmHb7KWiRAIMuf4LuNSSpTegVTz8pH6mw2Dg=; b=j5Oc6TBYGrjP+lHYV3MriK/QJvlY+5BJolqL/EYvo4cHUBXQTNtGMyuocJ+FbEVLdAjTLW FAp4KeXvofb4XYActFCQHevzq9Lx2NGs6joaqPYf115OOedXAksv0mMWP/Z1KHvNDQn4ki facvk/fZTP9ZvbXdf1c6UCNIneVVexCrnjLlrvVNYXcz2mTs9MfS0rVcJNZGLhPuwUvoNX XHRwt+/Ds/cPkMSD60H3TEnYtRCNZLx81lA5KKIwylUSTOLJ6CKvsq3/iwoDPxEZFObu+c wt3Z+o42iDSpmxbLS6jfvzKOomOPKe9hAL61yVe51y8eWOCgz8xm8RA9R4jTtg== To: ~johnnyrichard/olang-devel@lists.sr.ht Cc: Carlos Maniero Subject: [PATCH olang v1] tests: show test name into test execution output Message-ID: <20241011122554.549125-1-carlos@maniero.me> X-Mailer: git-send-email 2.46.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Fri, 11 Oct 2024 12:26:03 +0000 (UTC) X-CM-Envelope: MS4xfBYAgY4UQ69mGxxDXWwhpesLY5qaAPO9ECle6z/UraqzZpKhC5jixW1E5RDQHv4XNnsbUKXUYmrAt9cC/FZJ1D9tAGIdSRICFzgYGyY4spDbwpF7aVcq icH7yTtAT35yvp26K2PPe8qG57XAMFRyettMaRBUgrPCPIe3Qry1NeLb3OmVzMP4WhOiDNEgVgnq5vfTwOJS+Li/sRsbuqimmIBH8JbEME05kV8+XjY0jF87 X-CM-Analysis: v=2.4 cv=Z6G+H2RA c=1 sm=1 tr=0 ts=6709195c a=WwxFCuf3mf1fs3oSi6/dng==:117 a=WwxFCuf3mf1fs3oSi6/dng==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=b5JNFWEILqVUMA-6xSMA:9 a=BXDaF_L80NY05PYiAFlV:22 X-AuthUser: carlos@maniero.me X-Sourcehut-Patchset-Status: PROPOSED List-Unsubscribe: List-Subscribe: List-Archive: Archived-At: List-Post: List-ID: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel.lists.sr.ht> Sender: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel@lists.sr.ht> X-Migadu-Flow: FLOW_IN X-Migadu-Country: NL X-Migadu-Spam-Score: 0.20 X-Spam-Score: 0.20 X-Migadu-Queue-Id: EF79789730 X-Migadu-Scanner: mx12.migadu.com X-TUID: /KrNsDSFF7bu The test output was printing a bunch of dots *.* during the test execution. Now the tests are printing in the following format: ./0002_binary_operator_addition.ol [ OK ] [ 222ms ] ./0005_binary_operator_reminder.ol [ OK ] [ 264ms ] ./0004_binary_operator_division.ol [ OK ] [ 259ms ] ./0003_binary_operator_multiplication.ol [ OK ] [ 252ms ] ./0006_binary_operator_subtraction.ol [ OK ] [ 260ms ] ./0008_binary_operator_lt.ol [ OK ] [ 231ms ] The script changed from multiple printf calls into a single call to make sure the scripts can be executed in parallel without breaking the output. Signed-off-by: Carlos Maniero --- tests/olc/run.sh | 59 +++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/tests/olc/run.sh b/tests/olc/run.sh index 503f960..033ab5b 100755 --- a/tests/olc/run.sh +++ b/tests/olc/run.sh @@ -28,7 +28,6 @@ TEST_INVOCATION="" TEST_LINE_NUMBER="" TEST_CONTENTS_PATH="" TEST_ARGS="" -TEST_SOME_PASSED="" # UI COLOR_RED=1 @@ -37,17 +36,21 @@ COLOR_YELLOW=3 COLOR_CYAN=6 COLOR_GRAY=7 +if [ -t 1 ]; then + if tput setaf 1 > /dev/null 2>&1; then + HAS_COLORS=1 + fi +fi + colored() { text="$1" - if [ -t 1 ]; then - if tput setaf 1 > /dev/null 2>&1; then - color=$(tput setaf "$2") - reset=$(tput sgr0) + if [ -n "$HAS_COLORS" ]; then + color=$(tput setaf "$2") + reset=$(tput sgr0) - printf "%s%s%s" "$color" "$text" "$reset" - return - fi + printf "%s%s%s" "$color" "$text" "$reset" + return fi printf "%s" "$text" @@ -58,22 +61,12 @@ colored() { print_failed() { reason="$1" - if [ -n "$TEST_SOME_PASSED" ]; then - echo - fi - - colored "$TEST_FILE:$TEST_LINE_NUMBER:1: " $COLOR_GRAY - colored "[$TEST_INVOCATION] " $COLOR_CYAN - colored "failed" $COLOR_RED - if [ -n "$reason" ]; then - printf ": %s" "$reason" - fi - echo -} - -print_passed() { - colored "." $COLOR_GREEN - TEST_SOME_PASSED="true" + printf "%s:%s:1: %s %s: %s\n" \ + "$TEST_FILE" \ + "$TEST_LINE_NUMBER" \ + "$(colored "failed" "$COLOR_RED")" \ + "$(colored "$TEST_INVOCATION" "$COLOR_CYAN")" \ + "$reason" } # end test output @@ -88,9 +81,9 @@ expect_output_contains() { if [ "$(grep "$(printf "%s" "$expected_line" | sed 's/\\/\\\\/g')" "$actual_file" | wc -c)" = "0" ]; then print_failed - colored "(not found) $expected_line" $COLOR_YELLOW + colored "(not found) $expected_line" "$COLOR_YELLOW" echo - colored "$(awk '{print "(actual) " $0}' "$actual_file")" $COLOR_GRAY + colored "$(awk '{print "(actual) " $0}' "$actual_file")" "$COLOR_GRAY" echo exit 1 fi @@ -119,6 +112,8 @@ cleanup() { main() { all_test_end="$(grep -n "# END" "$TEST_FILE" | awk -F: '{print $1}')" + ts=$(date +%s%N) + grep -n "# TEST " "$TEST_FILE" | while read -r line ; do TEST_LINE_NUMBER="$(echo "$line" | awk -F: '{ print $1 }')" TEST_INVOCATION="$(echo "$line" | awk -F: '{ print $2 }' | sed 's/^\# TEST //' | sed 's/ WITH$//')" @@ -147,14 +142,22 @@ main() { if type "$TEST_NAME" | grep -q 'function'; then "$TEST_NAME" - print_passed else print_failed "test not implemented" fi done || exit 1; + elapsed=$((($(date +%s%N) - ts)/1000000)) + + padsize=$((59 - ${#TEST_FILE})) + + printf "%s %*s [ %s ] [ % 4dms ]\n" \ + "$TEST_FILE" \ + $(( padsize > 0 ? padsize : 0 )) "" \ + "$(colored "OK" "$COLOR_GREEN")"\ + $elapsed + cleanup - echo } get_test_args() { base-commit: 3a988ec943cd6b97d9fd6ff255dcdc387f80516c -- 2.46.1