Exemplo n.º 1
0
#!/usr/bin/env python

""" Development utility to replay the most recent trace file, and output it
as protocol strings. This assumes that the trace file is in ~/.als/in.txt

To use this, do

   replay.py > log

then you can replay at will with

  ada_language_server < log
"""

import os
from json_transformations import python_to_protocol_string, traces_to_test

als_dir = os.path.join(os.path.expanduser('~'), '.als')
inout_file = os.path.join(als_dir, 'inout.txt')
test = traces_to_test(inout_file, None, True)
result = ""
for x in test:
    if "send" in x:
        result += python_to_protocol_string([x["send"]["request"]])
print(result + "\r")
Exemplo n.º 2
0
#!/usr/bin/env python
""" Development utility to replay the most recent trace file, and output it
as protocol strings. This assumes that the trace file is in ~/.als/in.txt

To use this, do

   replay.py > log

then you can replay at will with

  ada_language_server < log
"""

import os
from json_transformations import python_to_protocol_string, traces_to_test

als_dir = os.path.join(os.path.expanduser('~'), '.als')
in_file = os.path.join(als_dir, 'in.txt')
out_file = os.path.join(als_dir, 'out.txt')
test = traces_to_test(in_file, out_file, None)
result = ""
for x in test:
    if "send" in x:
        result += python_to_protocol_string([x["send"]["request"]])
print result + "\r"
"""

import sys
import os
import json
from json_transformations import python_to_protocol_string, traces_to_test

testname = sys.argv[1]
root = os.path.abspath(
    os.path.abspath(os.path.join('testsuite', 'ada_lsp', testname)))

if len(sys.argv) > 2:
    inout_file = sys.argv[2]
else:
    als_dir = os.path.join(os.path.expanduser('~'), '.als')
    inout_file = os.path.join(als_dir, 'inout.txt')

test = traces_to_test(inout_file, root)

test_yaml_file = os.path.join(root, 'test.yaml')
print("generating {}".format(test_yaml_file))
with open(test_yaml_file, "w") as f:
    f.write("title: '{}'\n".format(testname))

testfile = os.path.join(root, 'test.json')
print("generating {}".format(testfile))

with open(testfile, "w") as f:
    f.write(json.dumps(test, indent=3))
Exemplo n.º 4
0
#!/usr/bin/env python
""" Development utility to grab the most recent trace files and make
    a testcase out of them.

To use this, do

   traces_to_test.py > name_of_test_driver.json

Note: this needs to be called from the PATH where the test project
resides.
"""

import os
import json
from json_transformations import python_to_protocol_string, traces_to_test

als_dir = os.path.join(os.path.expanduser('~'), '.als')
in_file = os.path.join(als_dir, 'in.txt')
out_file = os.path.join(als_dir, 'out.txt')
test = traces_to_test(in_file, out_file, os.getcwd())
print json.dumps(test, indent=3)