From patchwork Sun Oct 31 23:05:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Reutner-Fischer X-Patchwork-Id: 1548894 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=D3BISaHv; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HjBcC3HtQz9sXM for ; Mon, 1 Nov 2021 10:06:16 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6F9113857823 for ; Sun, 31 Oct 2021 23:06:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6F9113857823 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635721570; bh=HrGVAKSZDz9bAOCyuiw5GfpIc3xZiUx6brzWck+GN40=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=D3BISaHvuou2b8xek9huQFI54TvEtTn+vu7idVqUh61VLe1oTHKFfLzM1S+nxbBn7 BLurutrUx47Mn+yqNuv1nqHgFO7e8EfGIjcMi9prf6lOnAygEgwpvfqRzVeVCKrKWh s0j2mNxdyYoO3JrlA5cRuncvSoDGIjYK17a7UP78= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id A071F3858422; Sun, 31 Oct 2021 23:05:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A071F3858422 Received: by mail-wm1-x335.google.com with SMTP id b71so742555wmd.2; Sun, 31 Oct 2021 16:05:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HrGVAKSZDz9bAOCyuiw5GfpIc3xZiUx6brzWck+GN40=; b=wfi6tmGmYqokSnc5DvyTBlaIVAOWDNIeQw2XpzA56WMG6T9h8b1/gHRXMO7LM3Pn7/ kYzvD5MfFnm790LzCDm7V4sm5xRq2Q/iec5YurHk5l6dglld0ch0aZWBMt5cgo/KPVDy qruVLEtQzNR23exnY7Rm6Sz2bpS8VrX/pyPKT/83FBjAWrafgyPR5u8ACKeRRlVyOFys dB6jHQuCIYdOmq86Nnl5ZEotD3V1EgWVGGFeTC+PrcGYVolcto0ULPKFAsKcsYNgkhcg ZyxvcDHW2+Ab4MJ1+biAoU8kJ5ualstGXAZJW22YFgSmH8CDmqklPglhXwIXyH/jRsBb dLmA== X-Gm-Message-State: AOAM530gj2gCAVfGeaUfrqLi8uL1TETeeLDsXljWIaU8Iv+D8h89E2sF vcGS4B/vX/4jP+0tqjZlpa8= X-Google-Smtp-Source: ABdhPJwoOYPcDM9/4T+zD77GQ0d3K5m0NyrV1CcUmlNpFUXBToQwpOzEOf0d3981j12VXtAsoAe38w== X-Received: by 2002:a05:600c:354a:: with SMTP id i10mr35495061wmq.70.1635721527600; Sun, 31 Oct 2021 16:05:27 -0700 (PDT) Received: from nbbrfq.weghof (dynamic-2bq7di4u2lfl4qjka9-pd01.res.v6.highway.a1.net. [2001:871:227:33a8:f6a3:c58c:7641:e771]) by smtp.gmail.com with ESMTPSA id n7sm12249268wra.37.2021.10.31.16.05.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 16:05:27 -0700 (PDT) Received: from b by nbbrfq.weghof with local (Exim 4.95) (envelope-from ) id 1mhJtG-00C8y6-Bs; Mon, 01 Nov 2021 00:05:26 +0100 To: gcc-patches@gcc.gnu.org, Diego Novillo Subject: [PATCH] contrib: testsuite-management: Update to be python3 compatible Date: Mon, 1 Nov 2021 00:05:24 +0100 Message-Id: <20211031230524.2894401-1-rep.dot.nop@gmail.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Bernhard Reutner-Fischer via Gcc-patches From: Bernhard Reutner-Fischer Reply-To: Bernhard Reutner-Fischer Cc: Bernhard Reutner-Fischer , Bernhard Reutner-Fischer Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" From: Bernhard Reutner-Fischer contrib/ChangeLog: * testsuite-management/validate_failures.py: 2to3 --- Tested with python-3.9.7 where it now works again. --- .../testsuite-management/validate_failures.py | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/contrib/testsuite-management/validate_failures.py b/contrib/testsuite-management/validate_failures.py index 2779050468d..e11a6e40634 100755 --- a/contrib/testsuite-management/validate_failures.py +++ b/contrib/testsuite-management/validate_failures.py @@ -82,7 +82,7 @@ _MANIFEST_PATH_PATTERN = '%s/%s/%s.xfail' _OPTIONS = None def Error(msg): - print >>sys.stderr, 'error: %s' % msg + print('error: %s' % msg, file=sys.stderr) sys.exit(1) @@ -126,7 +126,7 @@ class TestResult(object): self.description) = re.match(r'([A-Z]+):\s*(\S+)\s*(.*)', summary_line).groups() except: - print 'Failed to parse summary line: "%s"' % summary_line + print('Failed to parse summary line: "%s"' % summary_line) raise self.ordinal = ordinal except ValueError: @@ -180,7 +180,7 @@ class TestResult(object): def GetMakefileValue(makefile_name, value_name): if os.path.exists(makefile_name): - makefile = open(makefile_name) + makefile = open(makefile_name, encoding='latin-1', mode='r') for line in makefile: if line.startswith(value_name): (_, value) = line.split('=', 1) @@ -246,8 +246,8 @@ def GetNegativeResult(line): def ParseManifestWorker(result_set, manifest_path): """Read manifest_path, adding the contents to result_set.""" if _OPTIONS.verbosity >= 1: - print 'Parsing manifest file %s.' % manifest_path - manifest_file = open(manifest_path) + print('Parsing manifest file %s.' % manifest_path) + manifest_file = open(manifest_path, encoding='latin-1', mode='r') for line in manifest_file: line = line.strip() if line == "": @@ -278,7 +278,7 @@ def ParseSummary(sum_fname): # ordinal is used when sorting the results so that tests within each # .exp file are kept sorted. ordinal=0 - sum_file = open(sum_fname) + sum_file = open(sum_fname, encoding='latin-1', mode='r') for line in sum_file: if IsInterestingResult(line): result = TestResult(line, ordinal) @@ -287,7 +287,7 @@ def ParseSummary(sum_fname): # Tests that have expired are not added to the set of expected # results. If they are still present in the set of actual results, # they will cause an error to be reported. - print 'WARNING: Expected failure "%s" has expired.' % line.strip() + print('WARNING: Expected failure "%s" has expired.' % line.strip()) continue result_set.add(result) sum_file.close() @@ -324,7 +324,7 @@ def GetResults(sum_files): """Collect all the test results from the given .sum files.""" build_results = set() for sum_fname in sum_files: - print '\t%s' % sum_fname + print('\t%s' % sum_fname) build_results |= ParseSummary(sum_fname) return build_results @@ -387,23 +387,23 @@ def GetBuildData(): return None, None srcdir = GetMakefileValue('%s/Makefile' % _OPTIONS.build_dir, 'srcdir =') target = GetMakefileValue('%s/Makefile' % _OPTIONS.build_dir, 'target_alias=') - print 'Source directory: %s' % srcdir - print 'Build target: %s' % target + print('Source directory: %s' % srcdir) + print('Build target: %s' % target) return srcdir, target def PrintSummary(msg, summary): - print '\n\n%s' % msg + print('\n\n%s' % msg) for result in sorted(summary): - print result + print(result) def GetSumFiles(results, build_dir): if not results: - print 'Getting actual results from build directory %s' % build_dir + print('Getting actual results from build directory %s' % build_dir) sum_files = CollectSumFiles(build_dir) else: - print 'Getting actual results from user-provided results' + print('Getting actual results from user-provided results') sum_files = results.split() return sum_files @@ -425,7 +425,7 @@ def PerformComparison(expected, actual, ignore_missing_failures): expected_vs_actual) if tests_ok: - print '\nSUCCESS: No unexpected failures.' + print('\nSUCCESS: No unexpected failures.') return tests_ok @@ -433,7 +433,7 @@ def PerformComparison(expected, actual, ignore_missing_failures): def CheckExpectedResults(): srcdir, target = GetBuildData() manifest_path = GetManifestPath(srcdir, target, True) - print 'Manifest: %s' % manifest_path + print('Manifest: %s' % manifest_path) manifest = GetManifest(manifest_path) sum_files = GetSumFiles(_OPTIONS.results, _OPTIONS.build_dir) actual = GetResults(sum_files) @@ -448,16 +448,16 @@ def CheckExpectedResults(): def ProduceManifest(): (srcdir, target) = GetBuildData() manifest_path = GetManifestPath(srcdir, target, False) - print 'Manifest: %s' % manifest_path + print('Manifest: %s' % manifest_path) if os.path.exists(manifest_path) and not _OPTIONS.force: Error('Manifest file %s already exists.\nUse --force to overwrite.' % manifest_path) sum_files = GetSumFiles(_OPTIONS.results, _OPTIONS.build_dir) actual = GetResults(sum_files) - manifest_file = open(manifest_path, 'w') + manifest_file = open(manifest_path, encoding='latin-1', mode='w') for result in sorted(actual): - print result + print(result) manifest_file.write('%s\n' % result) manifest_file.close()