Skip to content

Commit a588e49

Browse files
authored
Update tests and CI to python3 (#5095)
Update debugger and test262 tests to python3 Disable CI jobs that need ubuntu-18.04 (EOL) until they are updated JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi [email protected]
1 parent 05dbbd1 commit a588e49

File tree

6 files changed

+87
-94
lines changed

6 files changed

+87
-94
lines changed

.github/workflows/gh-actions.yml

Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,37 @@ env:
77

88
jobs:
99
Checks:
10-
runs-on: ubuntu-18.04 # needed for checker version stability
10+
runs-on: ubuntu-22.04 # needed for checker version stability
1111
steps:
1212
- uses: actions/checkout@v2
1313
with:
1414
fetch-depth: 0
1515
- uses: actions/setup-python@v2
1616
with:
17-
python-version: '3.8'
17+
python-version: '3.10'
1818
- run: sudo apt update
19-
- run: sudo apt install doxygen clang-format-10 cppcheck pylint python-serial
19+
# TODO: update checkers to current versions available in ubuntu 22.04
20+
# - run: sudo apt install doxygen clang-format-10 cppcheck pylint python-serial
2021
- run: $RUNNER --check-signed-off=gh-actions
2122
if: ${{ always() }}
22-
- run: $RUNNER --check-doxygen
23-
if: ${{ always() }}
24-
- run: $RUNNER --check-format
25-
if: ${{ always() }}
23+
# - run: $RUNNER --check-doxygen
24+
# if: ${{ always() }}
25+
# - run: $RUNNER --check-format
26+
# if: ${{ always() }}
2627
- run: $RUNNER --check-license
2728
if: ${{ always() }}
28-
- run: $RUNNER --check-strings
29-
if: ${{ always() }}
30-
- run: $RUNNER --check-pylint
31-
if: ${{ always() }}
32-
- run: $RUNNER --check-cppcheck
33-
if: ${{ always() }}
29+
# - run: $RUNNER --check-strings
30+
# if: ${{ always() }}
31+
# - run: $RUNNER --check-pylint
32+
# if: ${{ always() }}
33+
# - run: $RUNNER --check-cppcheck
34+
# if: ${{ always() }}
3435

3536
Linux_x86-64_Build_Correctness_Debugger_Tests:
3637
runs-on: ubuntu-latest
3738
steps:
3839
- uses: actions/checkout@v2
3940
- uses: actions/setup-python@v2
40-
with:
41-
python-version: '2.7' # needed by jerry-debugger
4241
- run: $RUNNER -q --jerry-tests
4342
- run: $RUNNER -q --jerry-tests --build-debug
4443
- run: $RUNNER -q --jerry-debugger
@@ -79,8 +78,6 @@ jobs:
7978
runs-on: ubuntu-latest
8079
steps:
8180
- uses: actions/checkout@v2
82-
- run: sudo apt update
83-
- run: sudo apt install python2
8481
- run: $RUNNER --test262 update
8582
- uses: actions/upload-artifact@v2
8683
if: success() || failure()
@@ -93,8 +90,6 @@ jobs:
9390
runs-on: ubuntu-latest
9491
steps:
9592
- uses: actions/checkout@v2
96-
- run: sudo apt update
97-
- run: sudo apt install python2
9893
- run: $RUNNER --test262 update --build-debug --test262-test-list=built-ins,annexB,harness,intl402
9994
- uses: actions/upload-artifact@v2
10095
if: success() || failure()
@@ -107,8 +102,6 @@ jobs:
107102
runs-on: ubuntu-latest
108103
steps:
109104
- uses: actions/checkout@v2
110-
- run: sudo apt update
111-
- run: sudo apt install python2
112105
- run: $RUNNER --test262 update --build-debug --test262-test-list=language
113106
- uses: actions/upload-artifact@v2
114107
if: success() || failure()
@@ -231,18 +224,19 @@ jobs:
231224
$RUNNER -q --jerry-tests --build-debug
232225
--buildoptions=--toolchain=cmake/toolchain_linux_aarch64.cmake,--linker-flag=-static
233226
234-
MbedOS_K64F_Build_Test:
235-
runs-on: ubuntu-18.04 # needed due to ppa:team-gcc-arm-embedded/ppa
236-
steps:
237-
- uses: actions/checkout@v2
238-
- uses: actions/setup-python@v2
239-
with:
240-
python-version: '3.8' # needed due to 'intelhex' module
241-
- run: sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
242-
- run: sudo apt update
243-
- run: sudo apt install gcc-arm-embedded python3-setuptools mercurial
244-
- run: make -f ./targets/os/mbedos/Makefile.travis install
245-
- run: make -f ./targets/os/mbedos/Makefile.travis script
227+
# TODO: update to ubuntu-22.04
228+
# MbedOS_K64F_Build_Test:
229+
# runs-on: ubuntu-18.04 # needed due to ppa:team-gcc-arm-embedded/ppa
230+
# steps:
231+
# - uses: actions/checkout@v2
232+
# - uses: actions/setup-python@v2
233+
# with:
234+
# python-version: '3.8' # needed due to 'intelhex' module
235+
# - run: sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
236+
# - run: sudo apt update
237+
# - run: sudo apt install gcc-arm-embedded python3-setuptools mercurial
238+
# - run: make -f ./targets/os/mbedos/Makefile.travis install
239+
# - run: make -f ./targets/os/mbedos/Makefile.travis script
246240

247241
Zephyr_STM32F4_Build_Test:
248242
runs-on: ubuntu-latest
@@ -265,17 +259,18 @@ jobs:
265259
- run: make -f ./targets/os/nuttx/Makefile.travis install-noapt
266260
- run: make -f ./targets/os/nuttx/Makefile.travis script
267261

268-
RIOT_STM32F4_Build_Test:
269-
runs-on: ubuntu-18.04 # needed due to ppa:team-gcc-arm-embedded/ppa
270-
env:
271-
CC: clang
272-
steps:
273-
- uses: actions/checkout@v2
274-
- run: sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
275-
- run: sudo apt update
276-
- run: sudo apt install clang gcc-arm-embedded gcc-multilib
277-
- run: make -f ./targets/os/riot/Makefile.travis install-noapt
278-
- run: make -f ./targets/os/riot/Makefile.travis script
262+
# TODO: update to ubuntu-22.04
263+
# RIOT_STM32F4_Build_Test:
264+
# runs-on: ubuntu-18.04 # needed due to ppa:team-gcc-arm-embedded/ppa
265+
# env:
266+
# CC: clang
267+
# steps:
268+
# - uses: actions/checkout@v2
269+
# - run: sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
270+
# - run: sudo apt update
271+
# - run: sudo apt install clang gcc-arm-embedded gcc-multilib
272+
# - run: make -f ./targets/os/riot/Makefile.travis install-noapt
273+
# - run: make -f ./targets/os/riot/Makefile.travis script
279274

280275
ESP8266_RTOS_SDK_Build_Test:
281276
runs-on: ubuntu-latest

jerry-debugger/jerry_client_main.py

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
JERRY_DEBUGGER_VALUE_ARRAY = 8
114114
JERRY_DEBUGGER_VALUE_OBJECT = 9
115115

116+
116117
def arguments_parse():
117118
parser = argparse.ArgumentParser(description="JerryScript debugger client")
118119

@@ -290,8 +291,8 @@ def __init__(self, channel):
290291
self.src_offset = 0
291292
self.src_offset_diff = 0
292293
self.non_interactive = False
293-
self.current_out = b""
294-
self.current_log = b""
294+
self.current_out = ""
295+
self.current_log = ""
295296
self.channel = channel
296297

297298
config_size = 8
@@ -303,12 +304,12 @@ def __init__(self, channel):
303304
# cpointer_size [1]
304305
result = self.channel.connect(config_size)
305306

306-
if len(result) != config_size or ord(result[0]) != JERRY_DEBUGGER_CONFIGURATION:
307+
if len(result) != config_size or result[0] != JERRY_DEBUGGER_CONFIGURATION:
307308
raise Exception("Unexpected configuration")
308309

309-
self.little_endian = ord(result[1]) & JERRY_DEBUGGER_LITTLE_ENDIAN
310-
self.max_message_size = ord(result[6])
311-
self.cp_size = ord(result[7])
310+
self.little_endian = result[1] & JERRY_DEBUGGER_LITTLE_ENDIAN
311+
self.max_message_size = result[6]
312+
self.cp_size = result[7]
312313

313314
if self.little_endian:
314315
self.byte_order = "<"
@@ -396,7 +397,7 @@ def delete(self, args):
396397
"to clear all the given breakpoints\n "
397398
elif args in ['all', 'pending', 'active']:
398399
if args != "pending":
399-
for i in self.active_breakpoint_list.values():
400+
for i in list(self.active_breakpoint_list.values()):
400401
breakpoint = self.active_breakpoint_list[i.active_index]
401402
del self.active_breakpoint_list[i.active_index]
402403
breakpoint.active_index = -1
@@ -557,6 +558,7 @@ def memstats(self):
557558
self._exec_command(JERRY_DEBUGGER_MEMSTATS)
558559

559560
def _send_string(self, args, message_type, index=0):
561+
args = args.encode('utf8')
560562

561563
# 1: length of type byte
562564
# 4: length of an uint32 value
@@ -680,7 +682,7 @@ def process_messages(self):
680682
if not data: # Break the while loop if there is no more data.
681683
return DebuggerAction(DebuggerAction.END, "")
682684

683-
buffer_type = ord(data[0])
685+
buffer_type = data[0]
684686
buffer_size = len(data) -1
685687

686688
logging.debug("Main buffer type: %d, message size: %d", buffer_type, buffer_size)
@@ -733,11 +735,8 @@ def process_messages(self):
733735
self.prompt = True
734736
return DebuggerAction(DebuggerAction.TEXT, result)
735737

736-
elif buffer_type == JERRY_DEBUGGER_EXCEPTION_STR:
737-
self.exception_string += data[1:]
738-
739-
elif buffer_type == JERRY_DEBUGGER_EXCEPTION_STR_END:
740-
self.exception_string += data[1:]
738+
elif buffer_type in [JERRY_DEBUGGER_EXCEPTION_STR, JERRY_DEBUGGER_EXCEPTION_STR_END]:
739+
self.exception_string += data[1:].decode('utf8')
741740

742741
elif buffer_type == JERRY_DEBUGGER_BACKTRACE_TOTAL:
743742
total = struct.unpack(self.byte_order + self.idx_format, data[1:])[0]
@@ -804,7 +803,7 @@ def process_messages(self):
804803
return DebuggerAction(DebuggerAction.TEXT, result)
805804

806805
elif buffer_type in [JERRY_DEBUGGER_SCOPE_VARIABLES, JERRY_DEBUGGER_SCOPE_VARIABLES_END]:
807-
self.scope_vars += "".join(data[1:])
806+
self.scope_vars += data[1:].decode('utf8')
808807

809808
if buffer_type == JERRY_DEBUGGER_SCOPE_VARIABLES_END:
810809
result = self._process_scope_variables()
@@ -860,9 +859,9 @@ def print_source(self, line_num, offset):
860859

861860
# pylint: disable=too-many-branches,too-many-locals,too-many-statements
862861
def _parse_source(self, data):
863-
source_code = ""
864-
source_code_name = ""
865-
function_name = ""
862+
source_code = b""
863+
source_code_name = b""
864+
function_name = b""
866865
stack = [{"line": 1,
867866
"column": 1,
868867
"name": "",
@@ -875,7 +874,7 @@ def _parse_source(self, data):
875874
if data is None:
876875
return "Error: connection lost during source code receiving"
877876

878-
buffer_type = ord(data[0])
877+
buffer_type = data[0]
879878
buffer_size = len(data) - 1
880879

881880
logging.debug("Parser buffer type: %d, message size: %d", buffer_type, buffer_size)
@@ -894,19 +893,20 @@ def _parse_source(self, data):
894893
function_name += data[1:]
895894

896895
elif buffer_type == JERRY_DEBUGGER_PARSE_FUNCTION:
897-
logging.debug("Source name: %s, function name: %s", source_code_name, function_name)
896+
logging.debug("Source name: %s, function name: %s", source_code_name.decode('utf8'),
897+
function_name.decode('utf8'))
898898

899899
position = struct.unpack(self.byte_order + self.idx_format + self.idx_format,
900900
data[1: 1 + 4 + 4])
901901

902-
stack.append({"source": source_code,
903-
"source_name": source_code_name,
902+
stack.append({"source": source_code.decode('utf8'),
903+
"source_name": source_code_name.decode('utf8'),
904904
"line": position[0],
905905
"column": position[1],
906-
"name": function_name,
906+
"name": function_name.decode('utf8'),
907907
"lines": [],
908908
"offsets": []})
909-
function_name = ""
909+
function_name = b""
910910

911911
elif buffer_type in [JERRY_DEBUGGER_BREAKPOINT_LIST, JERRY_DEBUGGER_BREAKPOINT_OFFSET_LIST]:
912912
name = "lines"
@@ -933,8 +933,8 @@ def _parse_source(self, data):
933933

934934
# We know the last item in the list is the general byte code.
935935
if not stack:
936-
func_desc["source"] = source_code
937-
func_desc["source_name"] = source_code_name
936+
func_desc["source"] = source_code.decode('utf8')
937+
func_desc["source_name"] = source_code_name.decode('utf8')
938938

939939
function = JerryFunction(stack,
940940
byte_code_cp,
@@ -985,7 +985,7 @@ def _parse_source(self, data):
985985
logging.debug("Pending breakpoints available")
986986
bp_list = self.pending_breakpoint_list
987987

988-
for breakpoint_index, breakpoint in bp_list.items():
988+
for breakpoint_index, breakpoint in list(bp_list.items()):
989989
source_lines = 0
990990
for src in new_function_list.values():
991991
if (src.source_name == breakpoint.source_name or
@@ -1123,19 +1123,19 @@ def _get_breakpoint(self, breakpoint_data):
11231123
return (function.offsets[nearest_offset], False)
11241124

11251125
def _process_incoming_text(self, buffer_type, data):
1126-
message = b""
1126+
message = ""
11271127
msg_type = buffer_type
11281128
while True:
11291129
if buffer_type in [JERRY_DEBUGGER_EVAL_RESULT_END,
11301130
JERRY_DEBUGGER_OUTPUT_RESULT_END]:
1131-
subtype = ord(data[-1])
1132-
message += data[1:-1]
1131+
subtype = data[-1]
1132+
message += data[1:-1].decode('utf8')
11331133
break
11341134
else:
1135-
message += data[1:]
1135+
message += data[1:].decode('utf8')
11361136

11371137
data = self.channel.get_message(True)
1138-
buffer_type = ord(data[0])
1138+
buffer_type = data[0]
11391139
# Checks if the next frame would be an invalid data frame.
11401140
# If it is not the message type, or the end type of it, an exception is thrown.
11411141
if buffer_type not in [msg_type, msg_type + 1]:
@@ -1176,17 +1176,17 @@ def _process_scope_variables(self):
11761176

11771177
while buff_pos != buff_size:
11781178
# Process name
1179-
name_length = ord(self.scope_vars[buff_pos:buff_pos + 1])
1179+
name_length = ord(self.scope_vars[buff_pos])
11801180
buff_pos += 1
11811181
name = self.scope_vars[buff_pos:buff_pos + name_length]
11821182
buff_pos += name_length
11831183

11841184
# Process type
1185-
value_type = ord(self.scope_vars[buff_pos:buff_pos + 1])
1185+
value_type = ord(self.scope_vars[buff_pos])
11861186

11871187
buff_pos += 1
11881188

1189-
value_length = ord(self.scope_vars[buff_pos:buff_pos + 1])
1189+
value_length = ord(self.scope_vars[buff_pos])
11901190
buff_pos += 1
11911191
value = self.scope_vars[buff_pos: buff_pos + value_length]
11921192
buff_pos += value_length
@@ -1217,16 +1217,16 @@ def _process_scope(self):
12171217
table = [['level', 'type']]
12181218

12191219
for i, level in enumerate(self.scope_data):
1220-
if ord(level) == JERRY_DEBUGGER_SCOPE_WITH:
1220+
if level == JERRY_DEBUGGER_SCOPE_WITH:
12211221
table.append([str(i), 'with'])
1222-
elif ord(level) == JERRY_DEBUGGER_SCOPE_GLOBAL:
1222+
elif level == JERRY_DEBUGGER_SCOPE_GLOBAL:
12231223
table.append([str(i), 'global'])
1224-
elif ord(level) == JERRY_DEBUGGER_SCOPE_NON_CLOSURE:
1224+
elif level == JERRY_DEBUGGER_SCOPE_NON_CLOSURE:
12251225
# Currently it is only marks the catch closure.
12261226
table.append([str(i), 'catch'])
1227-
elif ord(level) == JERRY_DEBUGGER_SCOPE_LOCAL:
1227+
elif level == JERRY_DEBUGGER_SCOPE_LOCAL:
12281228
table.append([str(i), 'local'])
1229-
elif ord(level) == JERRY_DEBUGGER_SCOPE_CLOSURE:
1229+
elif level == JERRY_DEBUGGER_SCOPE_CLOSURE:
12301230
table.append([str(i), 'closure'])
12311231
else:
12321232
raise Exception("Unexpected scope chain element")

jerry-debugger/jerry_client_rawpacket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def get_message(self, blocking):
7070

7171
while True:
7272
if len(self.data_buffer) >= 1:
73-
size = ord(self.data_buffer[0])
73+
size = self.data_buffer[0]
7474
if size == 0:
7575
raise Exception("Unexpected data frame")
7676

jerry-debugger/jerry_client_websocket.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def send_message(self, byte_order, packed_data):
9292
""" Send message. """
9393
message = struct.pack(byte_order + "BBI",
9494
WEBSOCKET_BINARY_FRAME | WEBSOCKET_FIN_BIT,
95-
WEBSOCKET_FIN_BIT + struct.unpack(byte_order + "B", packed_data[0])[0],
95+
WEBSOCKET_FIN_BIT + struct.unpack(byte_order + "B", packed_data[0].to_bytes())[0],
9696
0) + packed_data[1:]
9797

9898
self.__send_data(message)
@@ -110,10 +110,10 @@ def get_message(self, blocking):
110110

111111
while True:
112112
if len(self.data_buffer) >= 2:
113-
if ord(self.data_buffer[0]) != WEBSOCKET_BINARY_FRAME | WEBSOCKET_FIN_BIT:
113+
if self.data_buffer[0] != WEBSOCKET_BINARY_FRAME | WEBSOCKET_FIN_BIT:
114114
raise Exception("Unexpected data frame")
115115

116-
size = ord(self.data_buffer[1])
116+
size = self.data_buffer[1]
117117
if size == 0 or size >= 126:
118118
raise Exception("Unexpected data frame")
119119

0 commit comments

Comments
 (0)