comparison tests/run-tests.py @ 25035:1203ca7005fa

run-tests: use bytes when constructing shell script
author Augie Fackler <augie@google.com>
date Sat, 11 Apr 2015 18:28:32 -0400
parents af6e6a0781d7
children 61fc2cdbc57c
comparison
equal deleted inserted replaced
25034:af6e6a0781d7 25035:1203ca7005fa
921 script.append('set -x\n') 921 script.append('set -x\n')
922 if os.getenv('MSYSTEM'): 922 if os.getenv('MSYSTEM'):
923 script.append('alias pwd="pwd -W"\n') 923 script.append('alias pwd="pwd -W"\n')
924 924
925 for n, l in enumerate(lines): 925 for n, l in enumerate(lines):
926 if not l.endswith('\n'): 926 if not l.endswith(b'\n'):
927 l += '\n' 927 l += b'\n'
928 if l.startswith('#require'): 928 if l.startswith(b'#require'):
929 lsplit = l.split() 929 lsplit = l.split()
930 if len(lsplit) < 2 or lsplit[0] != '#require': 930 if len(lsplit) < 2 or lsplit[0] != b'#require':
931 after.setdefault(pos, []).append(' !!! invalid #require\n') 931 after.setdefault(pos, []).append(' !!! invalid #require\n')
932 if not self._hghave(lsplit[1:]): 932 if not self._hghave(lsplit[1:]):
933 script = ["exit 80\n"] 933 script = ["exit 80\n"]
934 break 934 break
935 after.setdefault(pos, []).append(l) 935 after.setdefault(pos, []).append(l)
936 elif l.startswith('#if'): 936 elif l.startswith(b'#if'):
937 lsplit = l.split() 937 lsplit = l.split()
938 if len(lsplit) < 2 or lsplit[0] != '#if': 938 if len(lsplit) < 2 or lsplit[0] != b'#if':
939 after.setdefault(pos, []).append(' !!! invalid #if\n') 939 after.setdefault(pos, []).append(' !!! invalid #if\n')
940 if skipping is not None: 940 if skipping is not None:
941 after.setdefault(pos, []).append(' !!! nested #if\n') 941 after.setdefault(pos, []).append(' !!! nested #if\n')
942 skipping = not self._hghave(lsplit[1:]) 942 skipping = not self._hghave(lsplit[1:])
943 after.setdefault(pos, []).append(l) 943 after.setdefault(pos, []).append(l)
944 elif l.startswith('#else'): 944 elif l.startswith(b'#else'):
945 if skipping is None: 945 if skipping is None:
946 after.setdefault(pos, []).append(' !!! missing #if\n') 946 after.setdefault(pos, []).append(' !!! missing #if\n')
947 skipping = not skipping 947 skipping = not skipping
948 after.setdefault(pos, []).append(l) 948 after.setdefault(pos, []).append(l)
949 elif l.startswith('#endif'): 949 elif l.startswith(b'#endif'):
950 if skipping is None: 950 if skipping is None:
951 after.setdefault(pos, []).append(' !!! missing #if\n') 951 after.setdefault(pos, []).append(' !!! missing #if\n')
952 skipping = None 952 skipping = None
953 after.setdefault(pos, []).append(l) 953 after.setdefault(pos, []).append(l)
954 elif skipping: 954 elif skipping:
955 after.setdefault(pos, []).append(l) 955 after.setdefault(pos, []).append(l)
956 elif l.startswith(' >>> '): # python inlines 956 elif l.startswith(b' >>> '): # python inlines
957 after.setdefault(pos, []).append(l) 957 after.setdefault(pos, []).append(l)
958 prepos = pos 958 prepos = pos
959 pos = n 959 pos = n
960 if not inpython: 960 if not inpython:
961 # We've just entered a Python block. Add the header. 961 # We've just entered a Python block. Add the header.
962 inpython = True 962 inpython = True
963 addsalt(prepos, False) # Make sure we report the exit code. 963 addsalt(prepos, False) # Make sure we report the exit code.
964 script.append('%s -m heredoctest <<EOF\n' % PYTHON) 964 script.append('%s -m heredoctest <<EOF\n' % PYTHON)
965 addsalt(n, True) 965 addsalt(n, True)
966 script.append(l[2:]) 966 script.append(l[2:])
967 elif l.startswith(' ... '): # python inlines 967 elif l.startswith(b' ... '): # python inlines
968 after.setdefault(prepos, []).append(l) 968 after.setdefault(prepos, []).append(l)
969 script.append(l[2:]) 969 script.append(l[2:])
970 elif l.startswith(' $ '): # commands 970 elif l.startswith(b' $ '): # commands
971 if inpython: 971 if inpython:
972 script.append('EOF\n') 972 script.append('EOF\n')
973 inpython = False 973 inpython = False
974 after.setdefault(pos, []).append(l) 974 after.setdefault(pos, []).append(l)
975 prepos = pos 975 prepos = pos
977 addsalt(n, False) 977 addsalt(n, False)
978 cmd = l[4:].split() 978 cmd = l[4:].split()
979 if len(cmd) == 2 and cmd[0] == 'cd': 979 if len(cmd) == 2 and cmd[0] == 'cd':
980 l = ' $ cd %s || exit 1\n' % cmd[1] 980 l = ' $ cd %s || exit 1\n' % cmd[1]
981 script.append(l[4:]) 981 script.append(l[4:])
982 elif l.startswith(' > '): # continuations 982 elif l.startswith(b' > '): # continuations
983 after.setdefault(prepos, []).append(l) 983 after.setdefault(prepos, []).append(l)
984 script.append(l[4:]) 984 script.append(l[4:])
985 elif l.startswith(' '): # results 985 elif l.startswith(b' '): # results
986 # Queue up a list of expected results. 986 # Queue up a list of expected results.
987 expected.setdefault(pos, []).append(l[2:]) 987 expected.setdefault(pos, []).append(l[2:])
988 else: 988 else:
989 if inpython: 989 if inpython:
990 script.append('EOF\n') 990 script.append('EOF\n')