Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp66697ybf; Thu, 27 Feb 2020 16:11:28 -0800 (PST) X-Google-Smtp-Source: APXvYqwoIsEHihnhVf6hEmIRtpKD1Kw/IYF+AWu49dtGWy6jnX4rEnfAxyFgM3cpeE8S8/PYxHnW X-Received: by 2002:a05:6808:98e:: with SMTP id a14mr1224040oic.8.1582848688399; Thu, 27 Feb 2020 16:11:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582848688; cv=none; d=google.com; s=arc-20160816; b=rPzJZ7sBdoSz6ieFgM/d/SntDKygdHAkQ5Ac5ztS9UNzrSuvvM1KAOJm9DQRxLecUd zNjma93xiMwyGOHrS+Nm80VDGMA7KypEIhbRzBuJZ9Q17KgVN+WkSMwRyI0fT0/6a2gK UM7SSGlGvyO01zkerBOhoXgdvMg9XrIDZpCWH7MY41syVGTFc87ag8eEY2wh7mDHWY+C EL7f1b9vhUpMr/iJHcokLW7vCf1aqa82b06Go1jDbXRzmpGdzUic1kk718oLIkNCBGFq 6z87z4I2eacJVHZevvjOpe2/K6Fqg6ICI0pgAC9IBVjnko4BxGKdTiAwi5pYhNJ0Nlpc asTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=dVD12z7+HGBJ25hvAL2ZOLK0dszXMUkehAgzAwaZMJs=; b=meG2yx07TQie3zzLN+zWh8AQf3AH0GIQMnlb09fYjiSp1XXuYlY+E6yJsBXvepAscf oG4zmU/mpYJ/i6pZy3hekUS1e/50QdzXSHKRm49vLQhhTDVCsomshwnsMZOIlPtAiPgs PRZGEd98n5AJMreQ49DA1QArmCWAgsBGxE5cykvHtMceQNLlGzKf0+v5RwHjJiUG3P9q IVkqQGIlXoIEswm6oJeJLl1rSREVWMcpHv++iBjANnfCEEdGCMmSZig4Efc+MhCG4POi TtehPsqmTBHMI1ABoB6h34VxOTwol4qHlBRuYOYXaiLNg9CScfFB5jJiQ9BgZnTEnKEs U5UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="cXutoS/O"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k16si780372oiw.128.2020.02.27.16.11.12; Thu, 27 Feb 2020 16:11:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="cXutoS/O"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730059AbgB1AJj (ORCPT + 99 others); Thu, 27 Feb 2020 19:09:39 -0500 Received: from mail-qk1-f172.google.com ([209.85.222.172]:34804 "EHLO mail-qk1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730009AbgB1AJj (ORCPT ); Thu, 27 Feb 2020 19:09:39 -0500 Received: by mail-qk1-f172.google.com with SMTP id 11so1403764qkd.1 for ; Thu, 27 Feb 2020 16:09:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dVD12z7+HGBJ25hvAL2ZOLK0dszXMUkehAgzAwaZMJs=; b=cXutoS/O22DmUNAx0wBz5bZRKXrQW1RgDZfbwIMFcsRqCPnclyD3xtyJGyKHhgwfGD 0RK/iSQCVoJg9xufBzrPCbImzGhEcozwjkSEpVS+k4sc082pwdeU47+oPYhg8GW0KR+d T6anl3rmC8IoDy+X7fb141P5hMArecIW2oV/iScwT3xvivaPoHYzl1U55b7/LUIgsOni FLv6BJsJGd/O7c1Eb4KzTo3cSGW37eYPfyv2W0e47Hs1CqbHUDR1Bgu1ifz2popmhvmm MdwFFLqybiAlmbGPZ0B/ECKRxOxlmgUXk44fN4aMa0rFgME2+y3m4z4SUIvX4bmnlFLv /6WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dVD12z7+HGBJ25hvAL2ZOLK0dszXMUkehAgzAwaZMJs=; b=re/kLjQHDbQ5xG4BfV12ltyqLHlXqy6XuWLEX8KXn+xw39RwXryCmnHAo46dqkFlIG OsfKtu4VW/Cn5MqlZ1u6RHSjHHudSswIpt7vNks8yVSF7Rsq8npj/lryGdbDw9P7YJjg XuUXh8Cg4FYsMXMmRrE2nVojlC1MDGE3tf/pYoVnydUYAKjWCgoPSRjeG0kpYo1Ai09m D/h3KzWGqRseCTKmbZPA8ZIxHX6ZxkTPQP27YYwkeHQ52+Uc17ajarCgzJU3AxwYlBp+ wWFPFB/UFS3iv9yXhUJBORO1AhHttc9LULG+2j6CKfzJbVkyW+7aJUrjsfP3SnbFdvCB 4qoA== X-Gm-Message-State: APjAAAWw/h0cvU2yb+KgPX/ZWcyp4lx/X9WwjhUpyFA+7L4hjBgyaIvU ylHiecEC12EgXvdlOGxvBOZBDFxrfwYrCAqClw6p7Q== X-Received: by 2002:a37:a4d2:: with SMTP id n201mr2120116qke.479.1582848577901; Thu, 27 Feb 2020 16:09:37 -0800 (PST) MIME-Version: 1.0 References: <20200225201130.211124-1-heidifahim@google.com> <20200225222221.GA144971@google.com> In-Reply-To: <20200225222221.GA144971@google.com> From: Heidi Fahim Date: Thu, 27 Feb 2020 16:09:26 -0800 Message-ID: Subject: Re: [PATCH 1/2] kunit: kunit_parser: making parser more robust To: Brendan Higgins Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > > > -TAP_ENTRIES = re.compile(r'^(TAP|\t?ok|\t?not ok|\t?[0-9]+\.\.[0-9]+|\t?#).*$') > > +TAP_ENTRIES = re.compile(r'(TAP|\t?ok|\t?not ok|\t?[0-9]+\.\.[0-9]+|\t# .*?:.*?).*$') > > Since you now strip off prefixes using length, does the old TAP regex no > longer work? > Using old regex (i.e. match instead of search) still works - do you prefer this be reverted where possible or be changed to search? Search is a little more relaxed when it comes to alignment of the TAP output (i.e. some lines could have extra leading whitespaces), but right now is not necessary. > > def consume_non_diagnositic(lines: List[str]) -> None: > > - while lines and not TAP_ENTRIES.match(lines[0]): > > + while lines and not TAP_ENTRIES.search(lines[0]): > > lines.pop(0) > > > > def save_non_diagnositic(lines: List[str], test_case: TestCase) -> None: > > - while lines and not TAP_ENTRIES.match(lines[0]): > > + while lines and not TAP_ENTRIES.search(lines[0]): > > test_case.log.append(lines[0]) > > lines.pop(0) > > > > OkNotOkResult = namedtuple('OkNotOkResult', ['is_ok','description', 'text']) > > > > -OK_NOT_OK_SUBTEST = re.compile(r'^\t(ok|not ok) [0-9]+ - (.*)$') > > +OK_NOT_OK_SUBTEST = re.compile(r'\t(ok|not ok) [0-9]+ - (.*)$') > > > > -OK_NOT_OK_MODULE = re.compile(r'^(ok|not ok) [0-9]+ - (.*)$') > > +OK_NOT_OK_MODULE = re.compile(r'(ok|not ok) [0-9]+ - (.*)$') > > Same here. > > > -def parse_ok_not_ok_test_case(lines: List[str], > > - test_case: TestCase, > > - expecting_test_case: bool) -> bool: > > +def parse_ok_not_ok_test_case(lines: List[str], test_case: TestCase) -> bool: > > save_non_diagnositic(lines, test_case) > > if not lines: > > - if expecting_test_case: > > - test_case.status = TestStatus.TEST_CRASHED > > - return True > > - else: > > - return False > > + test_case.status = TestStatus.TEST_CRASHED > > + return True > > line = lines[0] > > match = OK_NOT_OK_SUBTEST.match(line) > > + while not match and lines: > > + line = lines.pop(0) > > + match = OK_NOT_OK_SUBTEST.match(line) > > if match: > > test_case.log.append(lines.pop(0)) > > test_case.name = match.group(2) > > @@ -150,12 +150,12 @@ def parse_diagnostic(lines: List[str], test_case: TestCase) -> bool: > > else: > > return False > > > > -def parse_test_case(lines: List[str], expecting_test_case: bool) -> TestCase: > > +def parse_test_case(lines: List[str]) -> TestCase: > > test_case = TestCase() > > save_non_diagnositic(lines, test_case) > > while parse_diagnostic(lines, test_case): > > pass > > - if parse_ok_not_ok_test_case(lines, test_case, expecting_test_case): > > + if parse_ok_not_ok_test_case(lines, test_case): > > return test_case > > else: > > return None > > @@ -202,7 +202,7 @@ def parse_ok_not_ok_test_suite(lines: List[str], test_suite: TestSuite) -> bool: > > test_suite.status = TestStatus.TEST_CRASHED > > return False > > line = lines[0] > > - match = OK_NOT_OK_MODULE.match(line) > > + match = OK_NOT_OK_MODULE.search(line) > > if match: > > lines.pop(0) > > if match.group(1) == 'ok': > > @@ -234,11 +234,11 @@ def parse_test_suite(lines: List[str]) -> TestSuite: > > expected_test_case_num = parse_subtest_plan(lines) > > if not expected_test_case_num: > > return None > > - test_case = parse_test_case(lines, expected_test_case_num > 0) > > - expected_test_case_num -= 1 > > - while test_case: > > + while expected_test_case_num > 0: > > + test_case = parse_test_case(lines) > > + if not test_case: > > + break > > test_suite.cases.append(test_case) > > - test_case = parse_test_case(lines, expected_test_case_num > 0) > > expected_test_case_num -= 1 > > Do we use this variable anymore? Yes, this decides whether we are expecting another test case or if we've completed the test suite > > > if parse_ok_not_ok_test_suite(lines, test_suite): > > test_suite.status = bubble_up_test_case_errors(test_suite) > > @@ -250,7 +250,7 @@ def parse_test_suite(lines: List[str]) -> TestSuite: > > print('failed to parse end of suite' + lines[0]) > > return None > > > > -TAP_HEADER = re.compile(r'^TAP version 14$') > > +TAP_HEADER = re.compile(r'TAP version 14$') > > > > def parse_tap_header(lines: List[str]) -> bool: > > consume_non_diagnositic(lines) > > Cheers > > -- > You received this message because you are subscribed to the Google Groups "KUnit Development" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kunit-dev+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kunit-dev/20200225222221.GA144971%40google.com.