Changeset 122cac7


Ignore:
Timestamp:
Jun 21, 2016, 3:05:59 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
48a8127
Parents:
7ba3a25
Message:

fixed python script to work regardless of makelevel

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/test.py

    r7ba3a25 r122cac7  
    22from __future__ import print_function
    33
    4 from os import listdir
     4from os import listdir, environ
    55from os.path import isfile, join, splitext
    66from subprocess import Popen, PIPE, STDOUT
    77
    88import argparse
     9import os
     10import re
    911import sys
    1012
     
    2729                proc.communicate()
    2830                return proc.returncode
     31
     32def file_replace(fname, pat, s_after):
     33    # first, see if the pattern is even in the file.
     34    with open(fname) as f:
     35        if not any(re.search(pat, line) for line in f):
     36            return # pattern does not occur in file so we are done.
     37
     38    # pattern is in the file, so perform replace operation.
     39    with open(fname) as f:
     40        out_fname = fname + ".tmp"
     41        out = open(out_fname, "w")
     42        for line in f:
     43            out.write(re.sub(pat, s_after, line))
     44        out.close()
     45        os.rename(out_fname, fname)
     46
     47def fix_MakeLevel(file) :
     48        if environ.get('MAKELEVEL') :
     49                file_replace(file, "make\[%i\]" % int(environ.get('MAKELEVEL')), 'make' )
     50
    2951
    3052################################################################################
     
    4971
    5072        retcode = 0
     73
     74        fix_MakeLevel(out_file)
     75
    5176        if not generate :
    5277                # diff the output of the files
Note: See TracChangeset for help on using the changeset viewer.