Changeset 84d4d6f


Ignore:
Timestamp:
Jun 30, 2016, 10:58:22 AM (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:
ca35c51, f80e021
Parents:
177a5ce
Message:

python script can now regenerate expected for any tests that has a make target

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/test.py

    r177a5ce r84d4d6f  
    4949                file_replace(file, "make\[%i\]" % int(environ.get('MAKELEVEL')), 'make' )
    5050
     51def fileContainsOnly(file, text) :
     52        with open(file) as f:
     53                ff = f.read().strip()
     54                result = ff == text.strip()
     55                #
     56                # print("Comparing :\n\t'%s'\nWith:\n\t'%s'" % (ff, text))
     57                # print("Result is : \n\t", end="")
     58                # print(result)
     59
     60                return result;
     61
    5162
    5263################################################################################
     
    7586        fix_MakeLevel(out_file)
    7687
    77         if not generate :
     88        if generate :
     89                if not dry_run and fileContainsOnly(out_file, "make: *** No rule to make target `%s'.  Stop." % test) :
     90                        retcode = 1;
     91                        error = "\t\tNo make target for test %s!" % test
     92                        sh("rm %s" % out_file, False)
     93
     94        else :
    7895                # diff the output of the files
    7996                diff_cmd = ("diff --old-group-format='\t\tmissing lines :\n"
     
    112129                failed = test_failed or failed
    113130
    114                 if not generate :
    115                         print("FAILED" if test_failed else "PASSED")
    116                         if error :
    117                                 print(error)
     131                if generate :
     132                        failed_txt = "ERROR"
     133                        success_txt = "Done"
    118134                else :
    119                         print( "Done" )
     135                        failed_txt = "FAILED"
     136                        success_txt = "PASSED"
     137
     138                print(failed_txt if test_failed else success_txt)
     139                if error :
     140                        print(error, file=sys.stderr)
    120141
    121142        sh("%s clean > /dev/null 2>&1" % make_cmd, dry_run)
Note: See TracChangeset for help on using the changeset viewer.