From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0r.migadu.com with LMTPS id mwUsBq9CjWA0YwEALuJCtg (envelope-from ) for ; Sat, 01 May 2021 13:59:43 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 0A12Aa9CjWCaOwAA1q6Kng (envelope-from ) for ; Sat, 01 May 2021 11:59:43 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A7D4B10F03 for ; Sat, 1 May 2021 13:59:42 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 5142A271E5; Sat, 1 May 2021 07:59:37 -0400 (EDT) Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by mail.notmuchmail.org (Postfix) with ESMTPS id AB12D271E8 for ; Sat, 1 May 2021 07:59:32 -0400 (EDT) Received: by mail-oi1-x22f.google.com with SMTP id i26so828999oii.3 for ; Sat, 01 May 2021 04:59:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UXYQm++Er03noxmf/QCUVPIU4ED/9pNQw0hgww0ZxTo=; b=RXW0bVL8ChV2JX721i+ieKP4zIrSGUnFmD+5NaPJV5rexEJQC7GlmWQG+/LdPaPI1C 3vrGFyJFEOHMYcmgu01PYZ9MCF/kHt52aUrUqIIZA/i+8twI4rOpP6NsYYVVkxCJ0Qlh SNDy8zSXOe/gAYjGziqXqFzIk8nUDV7pNJu+KzxPE5uLMxf45QDAT9yNaV5QNDRGYwH5 35RadSYuT8vRGesczazjCM/Ipf/9W6le/B7J1hCvrepFixNCOeOynXsT3V670bywTum7 gmL+Niwgvl6eSVVw6vx1FM4PZ6dcHMPRcgTGd8fXs/w+E3/eBYyrxQHz1erz/fUfUXOn FXjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UXYQm++Er03noxmf/QCUVPIU4ED/9pNQw0hgww0ZxTo=; b=GABPAWZmYWa8G0Qn536Vlk8e7dB0kP+2X503L0AGuO2P6FMV0JU7oMWZnp0ujece19 veAYI97UKE3EfDz3q1arNxG96dVBXAg+TB5TSxySW2P5WdZxn7EMHPY9+/RJCyXgQPB5 Dr0/KaSeCzXydd1EfAToqBN/wn2z+nv5HuXbtmjopHZw7R9+iYX4CbibYjPxxvKuDtrM VH5HG45lA+L8PjgSAOoCw94UzLtBouNYQGklv+l+iHPsK/qlY0k7AeMgGqJNyR1CMrz0 AuGTN+rsIVOp657K+jdP9HVIBxUjxhx0qrsKQcNlMEedoK0QpzQ5vkP1225ojHI0ki9E 80gg== X-Gm-Message-State: AOAM531wgnOC47taglDtqeuxHp9kW75LNEUEr7V8rDi0JhuSgVOFz1ZJ jvKhXvBbx4whAPtn0fMUWWSWGE63qnDtYA== X-Google-Smtp-Source: ABdhPJx2QRBOByTwedv7XMr3kPFLeOjLKif+cFf30b/MMD5Bo9A/bmWecTDC08TZFbxa1DUHctGKpA== X-Received: by 2002:a05:6808:d9:: with SMTP id t25mr2741432oic.24.1619870368419; Sat, 01 May 2021 04:59:28 -0700 (PDT) Received: from localhost ([2806:2f0:4060:638f:a2c5:89ff:fe0c:1151]) by smtp.gmail.com with ESMTPSA id a4sm821685oib.17.2021.05.01.04.59.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 May 2021 04:59:28 -0700 (PDT) From: Felipe Contreras To: notmuch@notmuchmail.org Subject: [PATCH 2/9] test: ruby: refactor test_ruby() Date: Sat, 1 May 2021 06:59:16 -0500 Message-Id: <20210501115923.483816-3-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210501115923.483816-1-felipe.contreras@gmail.com> References: <20210501115923.483816-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Message-ID-Hash: YT4QEP7HVQ2GC5Z6MBY42BDI3IYMZ3HM X-Message-ID-Hash: YT4QEP7HVQ2GC5Z6MBY42BDI3IYMZ3HM X-MailFrom: felipe.contreras@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Daniel Kahn Gillmor , Ludovic LANGE , Tomi Ollila , Stefano Zacchiroli X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1619870382; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=v6wRagDpmhFJaq+IwyhXLqsNN+CXt9tG6CaY2tS8A8A=; b=VdpX53+2bdAzxqF/rKShTNb6Tfys5M3s8eZmw9FTYBFucztoPLC3JRELIeaNEZGEVgsHDc qiwTNejZF+vNOCK+a2pckUJAyKoBWY84cCoo0JmqRHH58iEqccnwaRVP76lQI8wkcnmoMj 52boa34/qrVdnK5e8lmfgRRPVzOeLMvBJ0a53lsTJyBzeBo6mLCtvZKbDdmBMUt6xtq/Ds 3o0F/65YId/hpZ63ijSk9AA2UNNQmtojn6KmA5YBmpwF9q8S+aCovX9vqKiOhV0pnPUKcb nbYOxkTTM/JmlCWlTCFz8yI4nJ+AgZXZfMHzE35i+hJzxqr7ckgSoQlSmqZfsw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1619870382; a=rsa-sha256; cv=none; b=bzzVhgDpQe9crDmp7u90/Khp34ml3qXctFNJkikefmAK/caNrxTobgagxT+neNwHPQFqsm DxOpFZvtdjJooO21cwHrc2UUomNNWBEGV4v0V4o5AyAZ8J4CuAcXCRFwtVHsTHcLYeYcPk hO4VBpwogdCMCmWg3Vb2dsNhrXqrVT5zWsQjDDJxBZUBCvTfiJUlAstYE7pMbTdVomBHah /wjkQ/FSMlU56Gp4zScBCnjmW0LDf5gb4am1ztfR7xdKUZpHrIrAPWLz29ECvlb18FBlbx f4g6oqrnx/q+sCbmduDpy4XckhqRe2SRnnTHSmzfpkJgLqMtfF66m4WK4qb8KQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=RXW0bVL8; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.00 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=RXW0bVL8; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: A7D4B10F03 X-Spam-Score: -1.00 X-Migadu-Scanner: scn0.migadu.com X-TUID: fZJtjbpmHvIU There's no point in repeating the same initialization in all the tests. Signed-off-by: Felipe Contreras --- test/T395-ruby.sh | 48 +++++++++++------------------------------------ 1 file changed, 11 insertions(+), 37 deletions(-) diff --git a/test/T395-ruby.sh b/test/T395-ruby.sh index fec1f5ef..1d27e191 100755 --- a/test/T395-ruby.sh +++ b/test/T395-ruby.sh @@ -9,17 +9,21 @@ fi add_email_corpus test_ruby() { - MAIL_DIR=$MAIL_DIR $NOTMUCH_RUBY -I "$NOTMUCH_BUILDDIR/bindings/ruby"> OUTPUT + ( + cat <<-\EOF + require 'notmuch' + $maildir = ENV['MAIL_DIR'] + if not $maildir then + abort('environment variable MAIL_DIR must be set') + end + @db = Notmuch::Database.new($maildir) + EOF + cat + ) | MAIL_DIR=$MAIL_DIR $NOTMUCH_RUBY -I "$NOTMUCH_BUILDDIR/bindings/ruby"> OUTPUT } test_begin_subtest "compare thread ids" test_ruby <<"EOF" -require 'notmuch' -$maildir = ENV['MAIL_DIR'] -if not $maildir then - abort('environment variable MAIL_DIR must be set') -end -@db = Notmuch::Database.new($maildir) @q = @db.query('tag:inbox') @q.sort = Notmuch::SORT_OLDEST_FIRST for t in @q.search_threads do @@ -31,12 +35,6 @@ test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "compare message ids" test_ruby <<"EOF" -require 'notmuch' -$maildir = ENV['MAIL_DIR'] -if not $maildir then - abort('environment variable MAIL_DIR must be set') -end -@db = Notmuch::Database.new($maildir) @q = @db.query('tag:inbox') @q.sort = Notmuch::SORT_OLDEST_FIRST for m in @q.search_messages do @@ -48,12 +46,6 @@ test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "get non-existent file" test_ruby <<"EOF" -require 'notmuch' -$maildir = ENV['MAIL_DIR'] -if not $maildir then - abort('environment variable MAIL_DIR must be set') -end -@db = Notmuch::Database.new($maildir) result = @db.find_message_by_filename('i-dont-exist') print (result == nil) EOF @@ -61,12 +53,6 @@ test_expect_equal "$(cat OUTPUT)" "true" test_begin_subtest "count messages" test_ruby <<"EOF" -require 'notmuch' -$maildir = ENV['MAIL_DIR'] -if not $maildir then - abort('environment variable MAIL_DIR must be set') -end -@db = Notmuch::Database.new($maildir) @q = @db.query('tag:inbox') print @q.count_messages(),"\n" EOF @@ -75,12 +61,6 @@ test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "count threads" test_ruby <<"EOF" -require 'notmuch' -$maildir = ENV['MAIL_DIR'] -if not $maildir then - abort('environment variable MAIL_DIR must be set') -end -@db = Notmuch::Database.new($maildir) @q = @db.query('tag:inbox') print @q.count_threads(),"\n" EOF @@ -89,12 +69,6 @@ test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "get all tags" test_ruby <<"EOF" -require 'notmuch' -$maildir = ENV['MAIL_DIR'] -if not $maildir then - abort('environment variable MAIL_DIR must be set') -end -@db = Notmuch::Database.new($maildir) @t = @db.all_tags() for tag in @t do print tag,"\n" -- 2.31.0