From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:5f26::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id WAUIIqKT62VIXQEAbAwnHQ (envelope-from ) for ; Fri, 08 Mar 2024 23:39:30 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id 6FViHqKT62WhxQAAqHPOHw (envelope-from ) for ; Fri, 08 Mar 2024 23:39:30 +0100 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=UfX8YnWt; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=cY4bEr1F; spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht; dmarc=none; arc=pass ("mailchannels.net:s=arc-2022:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1709937570; 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=VlQy8Uwqv/chPgBWfzlBQsKNN3nF9OeDGjhLiNmm2i0=; b=15iUJUCTzm0OLBK7h1rUa4VPGzQNRXmm/luB+YRURpl44MAWayxWMZrDdnAd8qkLVYQoo9 r9mZ9m91qwG8kVKmfkizcYYT2d3ITXy0Q6xC/jwUl+fRh/CbHyfPy1cNQ5Nh0d3Pi5aZ/p Pz+SEy5VG0XmrP06+Ao+LVrFVB+38BWvBLnXIj0D9PPofy3ZPlLstKs2Bu7mLoct4LGSMg 16o1hr3b8EB31117rEYaSz5aLmhcFyb2hthW57w3Z4Or/yz1JqqtmcIrfh7Hn6BQPuhEiJ b5n+zkozyBOozEPt70L3pOcKQD4N4YB1gR3KswVJvt85gndHXvzQEHqSlC5kTQ== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=UfX8YnWt; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=cY4bEr1F; spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht; dmarc=none; arc=pass ("mailchannels.net:s=arc-2022:i=1") ARC-Seal: i=2; s=key1; d=johnnyrichard.com; t=1709937570; a=rsa-sha256; cv=pass; b=F4RRlKzq80ndUZWijbbnbXX24HesvO7Eicj4g8oOKytbNfJsS1D+yMEbVh5v3lQLOrNyGL oNIwpa5spNZ3FCGRGuh2GEHefOGPFeOkav+y0EM7NY1VrqQSSuec9Rxt/zUUs+prdPMETp LtbNMRfdfhmJIwBFWLSeyzgyiRqSBC0sv05t9E9MCXUgX62ep49peN4+cVBEA+2OGgWTrg CJqE94I4VAsw/3VDVBltqREpltgqSphNcMfFxnfexQI3owWbiGf5Gdo6kNpMBNUflIJQnI f2pUXY9gka+N2jOPLHX5XijK4O6jJfOFJ1j+ztV/1DnMNd1BDpXJ8u1OSKeW6Q== 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 568A166947 for ; Fri, 8 Mar 2024 23:39:30 +0100 (CET) DKIM-Signature: a=rsa-sha256; bh=DPHdNkBajvrgZi7Hn0u716Xvi8zinL6EjuxqOl9WU1k=; 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=1709937570; v=1; b=UfX8YnWtyfbgfJF/3mmjzXg87wYNapK9pXxH9EnuokQ1d3YjL6WqfUlQeZ8upjQZ8vz5d87r L6BZrWfeSxk3lCUZCS47R6glwFs+x3iQn9E3OxEo0BHKd0P1/lJXfDGujIpWHaYREGlkCoyJcdt xV1ccgwaVTvsqfPyzYu6yxHhdRa3aC4fNvkE8WLOtKhxIIKW776fPgMIokSscSpiSaSHVtD1YBq 13LLtkBfhN37MxG5vaYIO4BgpMB6HOsBRxjJZqOmSG72FEmVX+wuyJP43blkq+x973YLxGLy44H 7ZpRWxouaMDlsYEeXiREcJvPGMrRldX6kcJzOj8RA67tw== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id EE0692026C for ; Fri, 8 Mar 2024 22:39:29 +0000 (UTC) Received: from weasel.tulip.relay.mailchannels.net (weasel.tulip.relay.mailchannels.net [23.83.218.247]) by mail-a.sr.ht (Postfix) with ESMTPS id EBB7220256 for <~johnnyrichard/olang-devel@lists.sr.ht>; Fri, 8 Mar 2024 22:39:28 +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 5E70A6C1819 for <~johnnyrichard/olang-devel@lists.sr.ht>; Fri, 8 Mar 2024 22:39:27 +0000 (UTC) Received: from nl-srv-smtpout4.hostinger.io (unknown [127.0.0.6]) (Authenticated sender: hostingeremail) by relay.mailchannels.net (Postfix) with ESMTPA id B7F696C24B5 for <~johnnyrichard/olang-devel@lists.sr.ht>; Fri, 8 Mar 2024 22:39:26 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1709937567; a=rsa-sha256; cv=none; b=RyDP9JnZbogTQ4xCQXy2us5T39Vn+349Jfa4xyRz7IjQ39kBU5PukpUyqdpjy2hiI19ILb DgUyCbYCEbpREGY/RAM0gJGEsjjC9QuYv7N6jC31BDG0rUO2VzLNnkHiOuUu74+4ZYDQ0e rU0+HtJ/yTINRu/iomlXM+OleORKvXGiFfgt9f0FjzLJKBujEOTuq1NAC36X5+/wujJgK+ ZkVsS0OyXb4S9EHBDVyMICN9mm1fNGQT2ep286g648XMw8in1U9x23D9QSoMzOSiyd7Gc7 GTnetVKHUBHCMWoknNy1PQcnTZrfbPF8L7qPQLilrRJ2Z3tO12Yjpo9apAf2zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1709937567; 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=VlQy8Uwqv/chPgBWfzlBQsKNN3nF9OeDGjhLiNmm2i0=; b=TSNAujnqMrQV5D2d+ZM8jUt1INVBjBJsIP8gx0A98E+Fm2IFg5GyXVkCkhaCqLrPJfmGvX D34cDB7ysdHjP5UR0Bf5yTXgrZwIst0q9TEq5DDeuXi01yeiPttomCGG05WMLeUx7cMNXb G3b+0yp18mBikTTN0QyYnG3HBkttoUilHK8IIW08Dnedl85wapdcIJmO0lozPGcziwYkpI RzuWex3ilifRtEnF2GnjsgdDZSjDRTeqVFtFTecFxFGEPdw42kk0+j8Pc+K+SEQiNxNTl6 axqe9Ez1VDWcTkH2lG2yZen+uvZdjsQ7xYhq+SaP2Y3E4BRGOAZYvPFlEEFmVQ== ARC-Authentication-Results: i=1; rspamd-67fb46fddd-97qq9; 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-Illegal-Desert: 258cbfa372ccb072_1709937567244_882018825 X-MC-Loop-Signature: 1709937567244:4049612844 X-MC-Ingress-Time: 1709937567243 Received: from nl-srv-smtpout4.hostinger.io (nl-srv-smtpout4.hostinger.io [145.14.159.45]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.98.116.93 (trex/6.9.2); Fri, 08 Mar 2024 22:39:27 +0000 From: Carlos Maniero DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maniero.me; s=hostingermail1; t=1709937565; 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=VlQy8Uwqv/chPgBWfzlBQsKNN3nF9OeDGjhLiNmm2i0=; b=cY4bEr1FtKmYIro8fpnvhdbLN1hy6qMEA4GBgOiSQC5kZoy/5ZQXydyY02B0piy/aqYZh3 IaTdZtyXLB1coI3e1FbNxqjB1xcdEweu+pyDcm//iiLWFT4yzJjgiS1sk8dyKSa32nSInf /SA5b01CyaS3H1gAAhNX6OijoOusxDUO9tVdkywHz0jfkOPCNzDwB6Vf4R7vGBVWHOXQLa WjNUZSn41QXoZxIlOidH37kDM4qtt8tPf6060500bx7RKg/MZiBsOUTNgbLWhOwSNYvNWT YNlB30eAeJC2Q0cej3IVgoJfMfz7b4O7aXCQ+XNtGFEwLqVplQerNxkRKc/Kjg== To: ~johnnyrichard/olang-devel@lists.sr.ht Cc: Carlos Maniero Subject: [PATCH olang v2 3/3] tests: add tests for the minimal possible olang program Date: Fri, 8 Mar 2024 19:39:09 -0300 Message-Id: <20240308223909.3184226-4-carlos@maniero.me> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240308223909.3184226-1-carlos@maniero.me> References: <20240308223909.3184226-1-carlos@maniero.me> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-Envelope: MS4xfD/9FfIS5sUjK5qaSwzGsuAmTvcTT45PPXkWzArngKWF7cI6+ljWttq+qQwkGbHr77mP1SBM6JZ598hR2DC+A/24vKJCz2J+UD+1nm/2E5a3iQmHRhQ4 VMSRpe3FwG0hKUTS80CINfMgZQE8mUPzdIYtTc55tWGOycO6d1rwe6VZbKRXwHOoCPiGhBwxF+1DWNzMKkTiJizyQYYcsZkcRJ7QRqzDeZAQFavLXMgSmKDZ X-CM-Analysis: v=2.4 cv=SNJEVvvH c=0 sm=1 tr=0 ts=65eb939d p=ls5Y7oOjibMo07TBq7dl:22 a=5+VMC1FZ3J4mVPAKpPmAqg==:117 a=5+VMC1FZ3J4mVPAKpPmAqg==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=gV4hKnv5amuZ1ImtDKEA:9 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: -9.55 X-Spam-Score: -9.55 X-Migadu-Queue-Id: 568A166947 X-Migadu-Scanner: mx13.migadu.com X-TUID: bHMA5gHfkoYC This test is just to ensure the cli is well set and it is compiling a program given the appropriated flags. Signed-off-by: Carlos Maniero --- tests/integration/cli_runner.c | 11 +++++++++++ tests/integration/cli_test.c | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/tests/integration/cli_runner.c b/tests/integration/cli_runner.c index 5a40e15..fed12ab 100644 --- a/tests/integration/cli_runner.c +++ b/tests/integration/cli_runner.c @@ -87,3 +87,14 @@ cli_runner_compiler_dump_tokens(char *src) cli_runner_compiler(&result, program_args); return result; } + +cli_result_t +cli_runner_compiler_compile(char *src) +{ + cli_result_t result = { 0 }; + create_tmp_file_name(result.binary_path); + + char *program_args[] = { "0c", src, "-o", result.binary_path, NULL }; + cli_runner_compiler(&result, program_args); + return result; +} diff --git a/tests/integration/cli_test.c b/tests/integration/cli_test.c index 126f612..c5896df 100644 --- a/tests/integration/cli_test.c +++ b/tests/integration/cli_test.c @@ -17,6 +17,7 @@ #define MUNIT_ENABLE_ASSERT_ALIASES #include "cli_runner.h" #include "munit.h" +#include static MunitResult test_cli_dump_tokens(const MunitParameter params[], void *user_data_or_fixture) @@ -41,8 +42,28 @@ test_cli_dump_tokens(const MunitParameter params[], void *user_data_or_fixture) return MUNIT_OK; } +static MunitResult +test_cli_compile_minimal_program(const MunitParameter params[], void *user_data_or_fixture) +{ + cli_result_t compilation_result = cli_runner_compiler_compile("../../examples/main_exit.0"); + munit_assert_int(compilation_result.exec.exit_code, ==, 0); + + char *command_args[] = { compilation_result.binary_path, NULL }; + + proc_exec_command_t command = { .path = command_args[0], .args = command_args }; + + proc_exec(&command); + + remove(command_args[0]); + + munit_assert_int(command.result.exit_code, ==, 0); + + return MUNIT_OK; +} + static MunitTest tests[] = { { "/test_cli_dump_tokens", test_cli_dump_tokens, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }, + { "/test_cli_compile_minimal_program", test_cli_compile_minimal_program, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }, { NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL } }; -- 2.34.1