Changeset f0e9ee1


Ignore:
Timestamp:
2021-03-26T11:03:36Z (3 weeks ago)
Author:
/ <>
Children:
a3a966a
Parents:
4b15a9a
Message:

asan in jabbertest

File:
1 edited

Legend:

Unmodified
Added
Removed
  • .tests/test1.py

    r4b15a9a rf0e9ee1  
    9696    return received
    9797
    98 def perform_test(failed, clis, test_function, test_name):
    99     fail = False
     98def debug_check(debug_file):
     99    error_found = False
     100    debug_log = ''
     101    while True:
     102        line = readline(debug_file)
     103        if len(line) == 0:
     104            break
     105        debug_log += line
     106        error_found = error_found or (line.lower().find('error') != -1)
     107    return error_found, debug_log
     108
     109def perform_test(failed, clis, test_function, test_name, debug_file):
    100110    for cli in clis:
    101111        cli.tmplog=""
     
    104114    print("Test: "+test_name)
    105115
    106     if test_function(clis):
    107         print("Test passed")
    108     else:
     116    fail = not test_function(clis)
     117
     118    debug_error, debug_log = debug_check(debug_file)
     119
     120    fail = fail or debug_error
     121
     122    if fail:
    109123        print("Test failed")
    110124        failed += [test_name]
    111         fail = True
     125    else:
     126        print("Test passed")
     127
    112128    for cli in clis:
    113129        cli.receive()
     
    119135                print("Test Log "+ cli.nick+":")
    120136                print(cli.tmplog)
     137
     138    if debug_error:
     139        print(SMOLPARATOR)
     140        print("Debug Log:")
     141        print(debug_log)
     142
    121143    print(SEPARATOR)
    122144
     
    250272
    251273def run_tests(failed):
     274    debug_file = open('debuglog','r')
    252275    clis = []
    253276    clis += [IrcClient('test1', 'asd')]
     
    256279        cli.connect()
    257280
    258     perform_test(failed, clis, yes_test, "Yes")
     281    perform_test(failed, clis, yes_test, "Yes", debug_file)
    259282
    260283    print("")
     
    262285        cli.jabber_login()
    263286
    264     perform_test(failed, clis, add_buddy_test, "Add/remove buddy")
    265     perform_test(failed, clis, message_test, "Send message")
    266     #perform_test(failed, clis, block_test, "Block user")
    267     perform_test(failed, clis, rename_test, "Rename user")
    268     perform_test(failed, clis, status_test, "Change status")
    269     perform_test(failed, clis, offline_test, "Go offline")
    270     perform_test(failed, clis, default_target_test, "Change default target")
    271     perform_test(failed, clis, help_test, "Ask for help")
     287    perform_test(failed, clis, add_buddy_test, "Add/remove buddy", debug_file)
     288    perform_test(failed, clis, message_test, "Send message", debug_file)
     289    #perform_test(failed, clis, block_test, "Block user", debug_file)
     290    perform_test(failed, clis, rename_test, "Rename user", debug_file)
     291    perform_test(failed, clis, status_test, "Change status", debug_file)
     292    perform_test(failed, clis, offline_test, "Go offline", debug_file)
     293    perform_test(failed, clis, default_target_test, "Change default target", debug_file)
     294    perform_test(failed, clis, help_test, "Ask for help", debug_file)
    272295
    273296    if failed or SHOWLOG:
     
    286309        print("\n" + SEPARATOR + "\nAll tests have passed")
    287310   
     311    debug_file.close()
     312   
    288313if __name__ == "__main__":
    289314    failed = []
Note: See TracChangeset for help on using the changeset viewer.