• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 the V8 project authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import difflib
6
7from . import base
8
9
10class OutProc(base.OutProc):
11  def __init__(self, expected_outcomes, expected_path):
12    super(OutProc, self).__init__(expected_outcomes)
13    self._expected_path = expected_path
14
15  def _is_failure_output(self, output):
16    with open(self._expected_path) as f:
17      expected = f.read()
18    expected_lines = expected.splitlines()
19    actual_lines = output.stdout.splitlines()
20    diff = difflib.unified_diff(expected_lines, actual_lines, lineterm="",
21                                fromfile="expected_path")
22    diffstring = '\n'.join(diff)
23    if diffstring is not "":
24      if "generated from a non-shipping build" in output.stdout:
25        return False
26      if not "generated from a shipping build" in output.stdout:
27        output.stdout = "Unexpected output:\n\n" + output.stdout
28        return True
29      output.stdout = diffstring
30      return True
31    return False
32