From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:700:3204::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id AOj7KodM6mVjIAEAbAwnHQ (envelope-from ) for ; Fri, 08 Mar 2024 00:23:51 +0100 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 uLp5IodM6mU/VQEAe85BDQ (envelope-from ) for ; Fri, 08 Mar 2024 00:23:51 +0100 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=BjiiFKeF; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=xmjd+aAu; arc=pass ("mailchannels.net:s=arc-2022:i=1"); 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-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1709853831; 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=oraKvHULRiW1zSqvyYctStFu1DGogtmxVKsNPdTGBqpJ30gO4+TOyO9H5MP4PEtjOxFfo8 wCyyUaven2ROLxq2RnXm72M615xZjZXeZBKwvfVMnvc1Grb6FZ1i2IS2KFjG2hnzPn7xwI 7qsyoFYHks3vgsJQxMAf3r6++WvCwKRcFMwkWaeOa282CKNJn26Yodi8bYhekRsAK9bqf7 2B7Y5rQOun1ULyvV6yn2DFciqK12BucM6sv3j1kWS+ohndpm5FCg4PS5K7MP1h1Og2uM2c MPv5EbwSLLZ527atcZfczVVNuO/MAEA1bQdSSSCRMsjqKZpm7A7JEzWMAewuww== ARC-Seal: i=2; s=key1; d=johnnyrichard.com; t=1709853831; a=rsa-sha256; cv=pass; b=GnBiJGKrBHqNRG1P+fTGOvIWa7wWvjd4IGjcBzeWDXN7Ou91xzvjNiPoPvdx0xWb0YcEg5 Qwe8MrtoRAt9J/jghd5YV0FfNycYeRQEMvUBIO7W0zNLuLMcHtgAxB3lQdU0WyYQHU+8Cj 44CJ1EJ1k1QYGWMa0VZL3yyTWp2ghbttQkc/j6AHGXkFGd1iWfADyG3AYpJK9CMgroUjnP hsmqZZcyvLJd/E91n/kP1Ut/t7tiPyiD/yvkMO/WMnztmKYXezNSVUiTIVxdUbTgT4d+Nd JtSpE0LuycySVhpnHzqcSvwOh2p9yK7MyW0Up2v3n5YFQSXB2QW15lhmEPhg7A== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=BjiiFKeF; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=xmjd+aAu; arc=pass ("mailchannels.net:s=arc-2022:i=1"); 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 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 639F776AD0 for ; Fri, 8 Mar 2024 00:23:48 +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=1709853827; v=1; b=BjiiFKeFAPFIUVqPBnsZyAlbemL7XHuPYD9W8LAdxdZeLx58e8/LJ5cbO7a6Vl72+vFnxO4J B5rfCh+2ZuYtxlM+oas10hG0qEDe3Np+/ZHZwySj4ErZ8F9Jhez/nipjsyfj5hS9YKs+T1X1vQn EXtXuzIsHFGToWCzBJvILRKAKO8a0HM6Ds2xmB2C6mzgqBRQAmOFiOK9Fi22PJWQtgZdyXc8rT0 /rcr7JKaJyH4matb5dGdcljQqG8IfpMyqkZ/q47wKxiu4oSqyC7UMT6ypDFLoyybTEpWog9JwFs nNus8J8WmOhdZSPFEq6J/jeAIDvUdWmRKuys45ogAa7vg== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id CC0A020140 for ; Thu, 7 Mar 2024 23:23:47 +0000 (UTC) Received: from bee.birch.relay.mailchannels.net (bee.birch.relay.mailchannels.net [23.83.209.14]) by mail-a.sr.ht (Postfix) with ESMTPS id C79EF200E0 for <~johnnyrichard/olang-devel@lists.sr.ht>; Thu, 7 Mar 2024 23:23:46 +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 2F9F76C2676 for <~johnnyrichard/olang-devel@lists.sr.ht>; Thu, 7 Mar 2024 23:23:45 +0000 (UTC) Received: from uk-fast-smtpout2.hostinger.io (unknown [127.0.0.6]) (Authenticated sender: hostingeremail) by relay.mailchannels.net (Postfix) with ESMTPA id 7B9AD6C10AA for <~johnnyrichard/olang-devel@lists.sr.ht>; Thu, 7 Mar 2024 23:23:43 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1709853823; a=rsa-sha256; cv=none; b=eqTJ5VDHwX/HGgKuo/Ofs02kjM/7pioiz/zwzxOyScNADIhgtAltzbtt3UFfjeGGMaTa1c bJBA4RcctJzwtdjSB+NJjhP8rIQASGVJFMTIuhVDvSj83eBI9KHxTVSrpDezeOpyMfGBuK 3EiZ+Y+kn5ac0wOTjtPZJqpQlQfJry46kroWnVmQHy11NJXt8NryZZpUNZqOYciPI7msIz dbYRZeSNuQNr4crdkl/Qcs22LsVrZ2lrPRlLrSi/W/U7weEQxA6R98xNTGGBWk9foHfLAn zrxZxY5psSs9b5DLHy35OPo9Gjr17/GUIZxDAcsAmAb+twz/yRqmi+loCz3pdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1709853823; 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=rgdzRz5PlVULPDOY9U7epnsF0wOrU2D6MYAOEmJKvMw9jD88Aq17/Mbv/d/2mv6CVWXzgz EgZzQui14smyFrg7NhNRqoaArYYFYQxfyqDBaLqIMRNkxhrGe+Iih2pU0g67k1Y0L5Qe8E m0r/3S3h+gp6k5hLQiENm1bMhcU53ju4+EAsi5BO+jkZd0bz+m+PUtkUC95rv5ZdJFUqi9 KG5cXdQhsn7/pyH7zdijcRV7CTJy2QKYHDXPkg6PCumXT882YpX7tyiEhmq0AcROZAg+Vg c2qh1cPTIkw4opTh+Vf1hfAOX/Ov/uzxgYMEGyLlxY/RKNR4HFYwEc01JEp5Xg== ARC-Authentication-Results: i=1; rspamd-67fb46fddd-kmqh5; 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-Skirt-Macabre: 0bdd5140404d8a00_1709853825043_3321343443 X-MC-Loop-Signature: 1709853825043:2976737135 X-MC-Ingress-Time: 1709853825043 Received: from uk-fast-smtpout2.hostinger.io (uk-fast-smtpout2.hostinger.io [31.220.23.36]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.106.146.25 (trex/6.9.2); Thu, 07 Mar 2024 23:23:45 +0000 From: Carlos Maniero DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maniero.me; s=hostingermail1; t=1709853820; 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=xmjd+aAu5trjy9tDza7z5CLHyqj+/7uEKBlFtIwr4WhhPUZL/yx5YNuZnB5rNUSe9iAa2j btuebQ1JlDI4DYGiznVYfzVz3invvUFZrZzUnvLrEmJBmX9pl51p5Rz4s3RGbe9Xu8hajf iIr2dv69lgY4AtxucMGFdIL0QA/2xDOSYC+etEInmPbI06rIdbr/2RDYC62ZNeir+6CG3V ANEEXqeIvVpYMaZjIV2/uM2Lu6Okrj1Pjl3SMhhChL2GBK203x6C1JrvfoqJnJWf+av7DY +SOwhT17RWsnsAl0XXAhqvErnPjsCQfrpswAxLxw1uI8zGsurhzdWD1QZF/o4Q== To: ~johnnyrichard/olang-devel@lists.sr.ht Cc: Carlos Maniero Subject: [PATCH olang 3/3] tests: add tests for the minimal possible olang program Date: Thu, 7 Mar 2024 20:23:22 -0300 Message-Id: <20240307232322.2085290-4-carlos@maniero.me> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240307232322.2085290-1-carlos@maniero.me> References: <20240307232322.2085290-1-carlos@maniero.me> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-Analysis: v=2.4 cv=HawSTDE8 c=1 sm=1 tr=0 ts=65ea4c7d a=5+VMC1FZ3J4mVPAKpPmAqg==:117 a=5+VMC1FZ3J4mVPAKpPmAqg==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=gV4hKnv5amuZ1ImtDKEA:9 a=BXDaF_L80NY05PYiAFlV:22 X-CM-Envelope: MS4xfEUaYAUw5A0jsYPlfXr0TPJtAUoJPrJ6M3UPm0kTDv4YF1K1hqJlXeh9MulqvHe8Y/QDOMgmPmiCFcFIDaeqKJfFEHUwAXKMhUrESu6AeLvpgOIOhAOL tnz9f+Lz9HklQ55U2CtSn5+wDbArFZyILiXOES/l1uF08JFzbAcEngpJYSFXimAEfSWeC8TsSZixkwFHCuLlJR6Wj07qyokJR6tg2KDyzxn6KIz8EhajSO6G 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.54 X-Spam-Score: -9.54 X-Migadu-Queue-Id: 639F776AD0 X-Migadu-Scanner: mx11.migadu.com X-TUID: 4ZU6FP1xbi2l 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