Patchwork [1,of,2] check-code: do not abort on an unreadable file, only report this

login
register
mail settings
Submitter Simon Heimberg
Date July 15, 2013, 11:24 p.m.
Message ID <6b87c9fb68dcb34bb20e.1373930656@lapsi.heimberg.home>
Download mbox | patch
Permalink /patch/1906/
State Superseded
Commit 3119dc155ac276e45d3c223453940e5c1009756c
Headers show

Comments

Simon Heimberg - July 15, 2013, 11:24 p.m.
# HG changeset patch
# User Simon Heimberg <simohe@besonet.ch>
# Date 1373749856 -7200
# Node ID 6b87c9fb68dcb34bb20eb678ee83dae802ec4729
# Parent  3af3a165db18ed093394fe661e797bea296dc602
check-code: do not abort on an unreadable file, only report this

Patch

diff -r 3af3a165db18 -r 6b87c9fb68dc contrib/check-code.py
--- a/contrib/check-code.py	Sam Jun 29 14:27:53 2013 +0400
+++ b/contrib/check-code.py	Sam Jul 13 23:10:56 2013 +0200
@@ -407,7 +407,11 @@ 
                 print "Skipping %s for %s it doesn't match %s" % (
                        name, match, f)
             continue
-        fp = open(f)
+        try:
+            fp = open(f)
+        except IOError, e:
+            print "Skipping %s, %s" % (f, str(e).split(':', 1)[0])
+            continue
         pre = post = fp.read()
         fp.close()
         if "no-" "check-code" in pre:
diff -r 3af3a165db18 -r 6b87c9fb68dc tests/test-check-code.t
--- a/tests/test-check-code.t	Sam Jun 29 14:27:53 2013 +0400
+++ b/tests/test-check-code.t	Sam Jul 13 23:10:56 2013 +0200
@@ -177,8 +177,10 @@ 
   > # this next line is okay
   > raise SomeException(arg1, arg2)
   > EOF
-  $ "$check_code" raise-format.py
+  $ "$check_code" not-existing.py raise-format.py
+  Skipping*not-existing.py* (glob)
   raise-format.py:1:
    > raise SomeException, message
    don't use old-style two-argument raise, use Exception(message)
   [1]
+