From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id yIzeF7BhxWahdwEAe85BDQ:P1 (envelope-from ) for ; Wed, 21 Aug 2024 05:40:32 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id yIzeF7BhxWahdwEAe85BDQ (envelope-from ) for ; Wed, 21 Aug 2024 05:40:32 +0200 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=LvgJDJX6; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=Ka0hrETS; arc=pass ("mailchannels.net:s=arc-2022:i=1"); 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-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1724211632; 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: in-reply-to:in-reply-to:references:references:list-id: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=/pnD+UwiON4jYr8jQsQfFHc6Wlqq4yq4aRh46Tb0QKc=; b=H4Iij0vdDXjAilGJFVur2UeJgwxvCw4a51TKLjfOgkbBk1ZeSfa7H1+rrvkl+hc9h9xBoG PJhKkjiYlMUauWw2Tmf3uFxmvdjws3wVEp8jQoGNrIP4SGm3dmmrtcgxHmgQKGx1f9/gu4 B+7FqCXW5xLejjsaOYZA84iPAZ8IeGACOdQ5AGsBMYV1RM8wrhAD0rPdMwhiaqimQlnubc 1Naa7imQQuvJLc8JD4CRjp1ETBYsekHFj+QzpWC88Qg6zhsFR7nDFcl7VckBa5W+XyMxyM 7l321CyKd8MSrdfQqxhvSYyFOvZAGMe6cQDiZttFMfqE0ypx50b8S2SXyP6bSw== ARC-Seal: i=2; s=key1; d=johnnyrichard.com; t=1724211632; a=rsa-sha256; cv=pass; b=lWaLG6j2uS/cYUUsAsleSPtjWDMvFg9l5gHSbWK9oOe3+7o2HmyThOh8lws9DPOYmgAB7I TZXuzPbpNh3yRPTuMQVqW1Sh4QuiJ5MA+Y7QUP0qsKRoKZFC5XwC20D9+zZFejGBa/9LSL Fq1GDBxTwmKFwncT6HdlPTpbZpG/EO7ZpJ1cUw+/VFZ6SqjZ4xaH3QO/GA1d4IRo7mtSno JNSKF794vvJaW8wk+jM1UlXIqkVWZrqaIfsLlItbh7LiPX3ugvhgjjLbNU3IqZ5PKHAmvU /oCnSyw4oqvDnFBy5GVsdpZGaSgKXn51xnBpCbUPTCCevo3mTDhKDs8cze4SDQ== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=LvgJDJX6; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=Ka0hrETS; arc=pass ("mailchannels.net:s=arc-2022:i=1"); 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 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 14E4D61752 for ; Wed, 21 Aug 2024 05:40:28 +0200 (CEST) DKIM-Signature: a=rsa-sha256; bh=/fGOxvSjn6jgkuJF1dat1Wbo0N0VPGTJoEFq80CuyvU=; c=simple/simple; d=lists.sr.ht; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-ID; q=dns/txt; s=20240113; t=1724211627; v=1; b=LvgJDJX6k7NTv1auLx/InzV5ZmVTT6EjVh/AB2gj7nFkiVL59nT3vNcqqKM6cm18S+ktV+qM Kro1q9qPoNhaT1XCMkw9NzY9zwUnD269TOh08OjcnzRXt2t+rxFlYwKxZhyPSXBOo/oB/y97FQk i4tkouVKaJSMzuSJGzp4/v/Lo0tKs3yAtGe1V4M63Zp1uwH7RzsF6zBvu1vxwssw28ZxNAtwp/O 0kg+gEvK8r0uPQcEMtclXLy7jW55Kh29aZb0S93CAtP0m0FQgzHAmU2vjhKFb0SifQ42FBwih5Q AH0IZesIDObud4VqKR7MgqMHAW7tyBcZZ7sGMPSxnrofA== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id 55AAF20294 for ; Wed, 21 Aug 2024 03:40:27 +0000 (UTC) Received: from sienna.cherry.relay.mailchannels.net (sienna.cherry.relay.mailchannels.net [23.83.223.165]) by mail-a.sr.ht (Postfix) with ESMTPS id AC64D20200 for <~johnnyrichard/olang-devel@lists.sr.ht>; Wed, 21 Aug 2024 03:40:19 +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 3A69B845845 for <~johnnyrichard/olang-devel@lists.sr.ht>; Wed, 21 Aug 2024 03:40:18 +0000 (UTC) Received: from nl-srv-smtpout1.hostinger.io (unknown [127.0.0.6]) (Authenticated sender: hostingeremail) by relay.mailchannels.net (Postfix) with ESMTPA id 8EFE984557E for <~johnnyrichard/olang-devel@lists.sr.ht>; Wed, 21 Aug 2024 03:40:17 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1724211617; a=rsa-sha256; cv=none; b=xUEeRT57F3s8rMon1OaHenUSlOnbH0B+zpV1J40yAOE1Q6Dyz921NBlRpMqelOIhzuQ/Zx TOHkX2RP/Fyg/9AAqdl+Lbqc4eCM6mh02zgrwkGyueyhlMcmvtCD2TN29aSzv4dXT944fX 09Qg6d70JF+OjS0BDoDGdfbBx9wqhMxFOUOHbmJiPGP/y4gL/qxiiU7kaH5Aodf9Ho6V+I uMlAJ3PyFdUBvEluJwygTZwUK7YYV7oOtu6JFm5pwKTWvILpLfglrJWUdWD8E4J40wGNdt +npC/9WFTsjYEFdrhrCEjStgXyQ0+HU/5EXJPTR+yns/QvGZCBhqbchKLhLLHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1724211617; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/pnD+UwiON4jYr8jQsQfFHc6Wlqq4yq4aRh46Tb0QKc=; b=R0xLaHitEtmRPQA2A74RxWabWVLmWSlQiqJxKbLVhHFxn2oItV9MVNfc+RbCW8ks2WqY2U /LLcr3tl8UO3D7EFl/6B++rkVnbqmZY0TA6IspNSTfIx1+NFt4Sjs5rzeTc4j6VoGA8SzH jhdYcBn5M/RK3ScsDBQo3DEwORDP/F49RGtTR7ZTXyxEQLTEN09abHTBqdMDU0FlFr9+6B Usvp3iOcWWFiYDIkKv4fjt3MGSl6rBlccJIaAzdfIfbP+zHTipXnAf7XdhQ51NKc2l0X7f j/0oq8gG27GvnRiUMwdSiWkJb/7eyArB0TGF7uyE6sh9CC09TchKL2di9Ca+5A== ARC-Authentication-Results: i=1; rspamd-c4b59d8dc-wpgsb; 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-Plucky-Descriptive: 0e4838c633ab39b4_1724211618182_418034969 X-MC-Loop-Signature: 1724211618182:2180231209 X-MC-Ingress-Time: 1724211618182 Received: from nl-srv-smtpout1.hostinger.io (nl-srv-smtpout1.hostinger.io [145.14.150.87]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.103.82.141 (trex/7.0.2); Wed, 21 Aug 2024 03:40:18 +0000 From: Carlos Maniero DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maniero.me; s=hostingermail1; t=1724211615; 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: in-reply-to:in-reply-to:references:references; bh=/pnD+UwiON4jYr8jQsQfFHc6Wlqq4yq4aRh46Tb0QKc=; b=Ka0hrETSw0fb+ELTIZzOLFZDYFm9nojOqS+W0aPC4NrcujVcEwak79Rd0fDZltil+VBUXb OKxS+Z8PnGfXn1ZND8VjzTc2Qka9ibEYA3CNxH7EyTxI6gX0tek8t103iNiwhfO+ESWs6Z B69PNJtkhnJQuVlhBKcYW7JMqyTlwb+kUbMZ/rFUCZ2upEWoLVTaB190fTxSn4mxjJjeYu H0SJkqW5i21yKegRGsloprrmc+hCAgXpZbjIpcyupvZZHo0e60oqGekRUcfPJAEefE7eZv oESD/BTsryx+3BeIWac7z9lDcq3Zb0trn5AgBSi2Ba+u6blxYp4RK0mWzTtkYA== To: ~johnnyrichard/olang-devel@lists.sr.ht Cc: Carlos Maniero Subject: [PATCH olang 1/2] tests: add comment based integration tests mechanism Date: Wed, 21 Aug 2024 00:39:52 -0300 Message-Id: <20240821033953.253090-2-carlos@maniero.me> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821033953.253090-1-carlos@maniero.me> References: <20240821033953.253090-1-carlos@maniero.me> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-Envelope: MS4xfHiYTdaHLBOgHQDoz4MpCPnlWgcuLuRHoV1kF7ceobblWkuq/z5jPlafY7tWa6xbqRxCjFSd8h9sFyDT3Vh8tI+pWfoMLglvtoi2PCbrIH2mrl/dRCnW ULgdJ1/+H4qRebq6pe6U58VFzNb0WEivmtopCJhaTGzOu1moFv+5GgJ5DtkS6Dro1cMIAljQ40xGsTIoExKCOvEvnOvh1EO7L+xSfXF9oHLEIUcwBwpro7SS X-CM-Analysis: v=2.4 cv=YLPNygGx c=1 sm=1 tr=0 ts=66c5619f a=WwxFCuf3mf1fs3oSi6/dng==:117 a=WwxFCuf3mf1fs3oSi6/dng==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=mDV3o1hIAAAA:8 a=ygo9rCkrubw3BqXON8UA:9 a=_FVE-zBwftR9WsbkzFJk:22 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: -2.81 X-Spam-Score: -2.81 X-Migadu-Queue-Id: 14E4D61752 X-Migadu-Scanner: mx11.migadu.com X-TUID: 03GJ4WlwTYp7 To create an integration tests you just need to create a olang file at *tests/integration/tests* directory. The assertions are performed thought a couple of comments. All tests features must start with the TEST statement. Arguments can be provided to the test feature thought invocation using *test_feature(arg_name_1=arg_value_1,arg_name_n=arg_value_n)* and multi-line text (test contents) can be passed thought tests over the WITH statement. Available test features: ======================== test_compile ------------ Compiles the program, assert the exit code and the stdout/stderr if WITH statement is present. test_run_binary --------------- Run the binary, assert the exit code and check the binary stdout/stderr if WITH statement is present. The test_run_binary depends on the test_compile. test_ast -------- Executes the *olang --dump-ast* over the test file and check if the ast matches for the given test contents over the diff command. test_contains_tokens -------------------- Validate that every given token by the test contents is present on the output of *olang --dump-tokens*. Since the language has the line_feed token it is impossible to test the EOF once when added a comment the EOF will be located at line + 1. So that the tokens test the first n-lines defined. So instead of performing a diff like test_ast it validates line by line. Signed-off-by: Carlos Maniero --- Makefile | 3 - tests/integration/Makefile | 34 +--- tests/integration/test.sh | 231 ++++++++++++++++++++++ tests/integration/tests/0001_main_exit.ol | 46 +++++ 4 files changed, 283 insertions(+), 31 deletions(-) create mode 100755 tests/integration/test.sh create mode 100644 tests/integration/tests/0001_main_exit.ol diff --git a/Makefile b/Makefile index 27337d4..2f5273b 100644 --- a/Makefile +++ b/Makefile @@ -19,13 +19,11 @@ $(BUILD_DIR): .PHONY: format format: $(SRCS) $(HEADERS) clang-format --dry-run --Werror $? - $(MAKE) -C tests/integration/ format $(MAKE) -C tests/unit/ format .PHONY: format-fix format-fix: $(SRCS) $(HEADERS) clang-format -i $? - $(MAKE) -C tests/integration/ format-fix $(MAKE) -C tests/unit/ format-fix .PHONY: integration-test @@ -40,7 +38,6 @@ unit-test: .PHONY: clean clean: - $(MAKE) -C tests/integration/ clean $(MAKE) -C tests/unit/ clean @rm -rf build/ $(TARGET) diff --git a/tests/integration/Makefile b/tests/integration/Makefile index 4625707..bda51af 100644 --- a/tests/integration/Makefile +++ b/tests/integration/Makefile @@ -1,31 +1,9 @@ -SRCS := $(wildcard *_test.c) -OBJS := $(patsubst %_test.c, %_test.o, $(SRCS)) -CFLAGS := -I../../src -I../shared -TESTS := $(patsubst %_test.c, %_test, $(SRCS)) -EXEC_TESTS := $(patsubst %_test, ./%_test, $(TESTS)) -MUNIT_SRC := ../shared/munit.c -MUNIT := ./munit.o +TESTER_SRC := ./test.sh +TESTS := $(wildcard ./tests/*.ol) .PHONY: all -all: $(MUNIT) proc_exec.o cli_runner.o $(TESTS) - @for file in $(EXEC_TESTS); do \ - ./"$$file"; \ +all: + @set -e; \ + for file in $(TESTS); do \ + $(TESTER_SRC) "$$file"; \ done - -.PHONY: clean -clean: - $(RM) *.o *_test - -.PHONY: format -format: $(SRCS) - clang-format --dry-run --Werror $? - -.PHONY: format-fix -format-fix: $(SRCS) - clang-format -i $? - -cli_test: $(MUNIT) proc_exec.o cli_runner.o cli_test.o - $(CC) $? $(CFLAGS) -o $@ - -$(MUNIT): - $(CC) -c $(MUNIT_SRC) $(CFLAGS) -o $(MUNIT) diff --git a/tests/integration/test.sh b/tests/integration/test.sh new file mode 100755 index 0000000..ae0a707 --- /dev/null +++ b/tests/integration/test.sh @@ -0,0 +1,231 @@ +#!/bin/sh +# Copyright (C) 2024 olang mantainers +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Ignores variables been modified in a subshell +# shellcheck disable=SC2030,SC2031 +OLANG_PATH="../../olang" +TEST_FILE="$1" + +TEST_TMP_FILES="$TEST_FILE.test" +TEST_TMP_BIN="$TEST_TMP_FILES.bin" + +# Execution state vars +TEST_NAME="" +TEST_INVOCATION="" +TEST_LINE_NUMBER="" +TEST_CONTENTS_PATH="" +TEST_ARGS="" +TEST_SOME_PASSED="" + +# UI +COLOR_RED=1 +COLOR_GREEN=2 +COLOR_YELLOW=3 +COLOR_CYAN=6 +COLOR_GRAY=7 + +colored() { + text="$1" + + if [ -t 1 ]; then + if tput setaf 1 > /dev/null 2>&1; then + color=$(tput setaf "$2") + reset=$(tput sgr0) + + printf "%s%s%s" "$color" "$text" "$reset" + return + fi + fi + + printf "%s" "$text" +} +# end UI + +# test output +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" +} +# end test output + +# expectations +expect_output_contains() { + actual_file="$1" + expected_file="$2" + original_line_number="$TEST_LINE_NUMBER" + + while read -r expected_line ; do + TEST_LINE_NUMBER=$((TEST_LINE_NUMBER+1)) + + if [ "$(grep "$(printf "%s" "$expected_line" | sed 's/\\/\\\\/g')" "$actual_file" | wc -c)" = "0" ]; then + print_failed + colored "(not found) $expected_line" $COLOR_YELLOW + echo + colored "$(awk '{print "(actual) " $0}' "$actual_file")" $COLOR_GRAY + echo + exit 1 + fi + done < "$expected_file" + + TEST_LINE_NUMBER="$original_line_number" +} + +diff_output() { + actual_file="$1" + expected_file="$2" + + if cmp -s "$expected_file" "$actual_file"; then + return + fi + + print_failed "match failed" + diff "$actual_file" "$expected_file" -u --color + exit 1 +} + +cleanup() { + rm -rf "$TEST_TMP_FILES"* +} + +main() { + all_test_end="$(grep -n "# END" "$TEST_FILE" | awk -F: '{print $1}')" + + 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$//')" + + TEST_NAME="$(echo "$TEST_INVOCATION" | awk -F\( '{ print $1 }')" + TEST_ARGS="$(echo "$TEST_INVOCATION" | awk -F\( '{ print $2 }' | sed 's/)$//')" + + has_with_contents="$(echo "$line" | sed 's/.*WITH$/true/')" + end_line="$TEST_LINE_NUMBER" + + if [ "$has_with_contents" = "true" ]; then + for test_end in $all_test_end; do + if [ "$test_end" -gt "$TEST_LINE_NUMBER" ]; then + end_line="$test_end" + break + fi + done + + TEST_CONTENTS_PATH="$TEST_TMP_FILES.$TEST_LINE_NUMBER.$end_line.partial" + + awk -v start="$TEST_LINE_NUMBER" -v end="$end_line" 'NR > start && NR < end' "$TEST_FILE" \ + | sed 's/^\# /#/' | sed 's/^\#//' > "$TEST_CONTENTS_PATH" + else + TEST_CONTENTS_PATH="" + fi + + if type "$TEST_NAME" | grep -q 'function'; then + "$TEST_NAME" + print_passed + else + print_failed "test not implemented" + fi + done || exit 1; + + cleanup + echo +} + +get_test_args() { + arg_name="$1" + echo "$TEST_ARGS" | sed "s/,/\n/g" | grep "$arg_name=" | sed "s/^$arg_name=//" +} + +assert_contents_path() { + if [ -z "$TEST_CONTENTS_PATH" ]; then + print_failed "missing WITH block for test contents" + exit 5 + fi +} + +# Test functions +test_compile() { + expected_exit_code="$(get_test_args "exit_code")" + actual_output_file="$TEST_TMP_FILES.$TEST_LINE_NUMBER.compiler_output" + + $OLANG_PATH "$TEST_FILE" -o "$TEST_TMP_BIN" > "$actual_output_file" 2>&1 + exit_code="$?" + + if [ -n "$expected_exit_code" ]; then + if [ "$expected_exit_code" -ne "$exit_code" ]; then + print_failed "expected compiler exit code: $expected_exit_code actual: $exit_code" + exit 1 + fi + fi + + if [ -n "$TEST_CONTENTS_PATH" ]; then + diff_output "$actual_output_file" "$TEST_CONTENTS_PATH" + fi +} + +test_ast() { + assert_contents_path + + actual_output_file="$TEST_TMP_FILES.$TEST_LINE_NUMBER.ast_output" + + $OLANG_PATH "$TEST_FILE" --dump-ast > "$actual_output_file" 2>&1 + + diff_output "$actual_output_file" "$TEST_CONTENTS_PATH" +} + +test_contains_tokens() { + assert_contents_path + + actual_output_file="$TEST_TMP_FILES.$TEST_LINE_NUMBER.tokens_output" + + $OLANG_PATH "$TEST_FILE" --dump-tokens > "$actual_output_file" 2>&1 + + expect_output_contains "$actual_output_file" "$TEST_CONTENTS_PATH" +} + +test_run_binary() { + expected_exit_code="$(get_test_args "exit_code")" + actual_output_file="$TEST_TMP_FILES.$TEST_LINE_NUMBER.run_output" + + "$TEST_TMP_BIN" > "$actual_output_file" 2>&1 + exit_code="$?" + + if [ -n "$expected_exit_code" ]; then + if [ "$expected_exit_code" -ne "$exit_code" ]; then + print_failed "expected compiler exit code: $expected_exit_code actual: $exit_code" + exit 1 + fi + fi + + if [ -n "$TEST_CONTENTS_PATH" ]; then + diff_output "$actual_output_file" "$TEST_CONTENTS_PATH" + fi +} + +main diff --git a/tests/integration/tests/0001_main_exit.ol b/tests/integration/tests/0001_main_exit.ol new file mode 100644 index 0000000..f446eb9 --- /dev/null +++ b/tests/integration/tests/0001_main_exit.ol @@ -0,0 +1,46 @@ +# Copyright (C) 2024 olang mantainers +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# A minimal olang program +fn main(): u32 { + return 0 +} + +# TEST test_compile(exit_code=0) +# +# TEST test_run_binary(exit_code=0) +# +# TEST test_ast WITH +# Translation_Unit +# `-Function_Definition +# `-Block +# `-Return_Statement +# `-Literal +# END +# +# TEST test_contains_tokens WITH +# ./tests/0001_main_exit.ol:17:1: +# ./tests/0001_main_exit.ol:17:4: +# ./tests/0001_main_exit.ol:17:8: <(> +# ./tests/0001_main_exit.ol:17:9: <)> +# ./tests/0001_main_exit.ol:17:10: <:> +# ./tests/0001_main_exit.ol:17:12: +# ./tests/0001_main_exit.ol:17:16: <{> +# ./tests/0001_main_exit.ol:17:17: +# ./tests/0001_main_exit.ol:18:3: +# ./tests/0001_main_exit.ol:18:10: +# ./tests/0001_main_exit.ol:18:11: +# ./tests/0001_main_exit.ol:19:1: <}> +# END -- 2.34.1