X-Git-Url: https://git.cworth.org/git?p=apitrace-tests;a=blobdiff_plain;f=cli_driver.py;h=6c1bfd05ae28424e4a2ed8269e8b395b292ce894;hp=5139b1de27c6c7bdbc22e5449375fb7f711c4031;hb=8351c1e187d8f65477db05a07bacd5d184c2b950;hpb=5c6bd4339bdd7c803e30bdab765730bc7f2bd358 diff --git a/cli_driver.py b/cli_driver.py index 5139b1d..6c1bfd0 100644 --- a/cli_driver.py +++ b/cli_driver.py @@ -24,7 +24,11 @@ '''Test driver for scripts in the cli directory.''' -import json, errno, shutil, subprocess +import json +import errno +import shutil +import subprocess +import difflib from base_driver import * @@ -47,9 +51,12 @@ class CliDriver(Driver): fail("Command failed (returned non-zero):\n " + " ".join(cmd)) def do_expect(self, args): - expected = json.loads(args) + expected = eval(args) if (self.output != expected): - fail("Unexpected output:\n Expected: %s\n Received: %s\n" % (expected, self.output)) + differ = difflib.Differ() + diff = differ.compare(expected.splitlines(1), self.output.splitlines(1)) + diff = ''.join(diff) + fail("Unexpected output:\n%s\n" % diff) def do_rm_and_mkdir(self, args): @@ -94,6 +101,11 @@ class CliDriver(Driver): if " " in line: (cmd, args) = line.split(None,1) + if args.startswith('r"""'): + while not line.endswith('"""'): + line = script.readline() + line = line.rstrip() + args += '\n' + line else: cmd = line args = ''