Changeset a35b458 in mainline for tools/checkers/stanse.py


Ignore:
Timestamp:
2018-03-02T20:10:49Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/checkers/stanse.py

    r3061bc1 ra35b458  
    4747def stanse(root, job):
    4848        "Run Stanse on a jobfile"
    49        
     49
    5050        # Convert generic jobfile to Stanse-specific jobfile format
    51        
     51
    5252        inname = os.path.join(root, job)
    5353        outname = os.path.join(root, "_%s" % os.path.basename(job))
    54        
     54
    5555        if (not os.path.isfile(inname)):
    5656                print("Unable to open %s" % inname)
    5757                print("Did you run \"make precheck\" on the source tree?")
    5858                return False
    59        
     59
    6060        inf = open(inname, "r")
    6161        records = inf.read().splitlines()
    6262        inf.close()
    63        
     63
    6464        output = []
    6565        for record in records:
     
    6767                if (not arg):
    6868                        return False
    69                
     69
    7070                if (len(arg) < 6):
    7171                        print("Not enough jobfile record arguments")
    7272                        return False
    73                
     73
    7474                srcfname = arg[0]
    7575                tgtfname = arg[1]
     
    7878                base = arg[4]
    7979                options = arg[5]
    80                
     80
    8181                srcfqname = os.path.join(base, srcfname)
    8282                if (not os.path.isfile(srcfqname)):
    8383                        print("Source %s not found" % srcfqname)
    8484                        return False
    85                
     85
    8686                # Only C files are interesting for us
    8787                if (tool != "cc"):
    8888                        continue
    89                
     89
    9090                output.append([srcfname, tgtfname, base, options])
    91        
     91
    9292        outf = open(outname, "w")
    9393        for record in output:
    9494                outf.write("{%s},{%s},{%s},{%s}\n" % (record[0], record[1], record[2], record[3]))
    9595        outf.close()
    96        
     96
    9797        # Run Stanse
    98        
     98
    9999        retval = subprocess.Popen(['stanse', '--checker', 'ReachabilityChecker', '--jobfile', outname]).wait()
    100        
     100
    101101        # Cleanup
    102        
     102
    103103        os.remove(outname)
    104104        for record in output:
     
    106106                if (os.path.isfile(tmpfile)):
    107107                        os.remove(tmpfile)
    108        
     108
    109109        if (retval == 0):
    110110                return True
    111        
     111
    112112        return False
    113113
     
    116116                usage(sys.argv[0])
    117117                return
    118        
     118
    119119        rootdir = os.path.abspath(sys.argv[1])
    120120        config = os.path.join(rootdir, "HelenOS.config")
    121        
     121
    122122        if (not os.path.isfile(config)):
    123123                print("%s not found." % config)
    124124                print("Please specify the path to HelenOS build tree root as the first argument.")
    125125                return
    126        
     126
    127127        for job in jobs:
    128128                if (not stanse(rootdir, job)):
     
    130130                        print("Failed job: %s" % job)
    131131                        return
    132        
     132
    133133        print
    134134        print("All jobs passed")
Note: See TracChangeset for help on using the changeset viewer.