示例#1
0
def test_content(differences):
    output_text(differences[0], print_func=print)
    assert differences[0].source1 == 'dir/text'
    expected_diff = open(
        os.path.join(os.path.dirname(__file__),
                     '../data/text_ascii_expected_diff')).read()
    assert differences[0].unified_diff == expected_diff
示例#2
0
def test_dot_changes_compare_non_existing(monkeypatch, dot_changes1):
    monkeypatch.setattr(Config.general, 'new_file', True)
    difference = dot_changes1.compare(
        NonExistingFile('/nonexisting', dot_changes1))
    output_text(difference, print_func=print)
    assert difference.source2 == '/nonexisting'
    assert difference.details[-1].source2 == '/dev/null'
示例#3
0
def test_differences_with_dbgsym(dbgsym_differences):
    output_text(dbgsym_differences, print)
    assert dbgsym_differences.details[2].source1 == 'data.tar.xz'
    bin_details = dbgsym_differences.details[2].details[0].details[0]
    assert bin_details.source1 == './usr/bin/test'
    assert bin_details.details[1].source1.startswith('objdump')
    assert 'test-cases/dbgsym/package/test.c:2' in bin_details.details[1].unified_diff
示例#4
0
def run_diffoscope(parsed_args):
    if not tlsh and Config.general.fuzzy_threshold != parsed_args.fuzzy_threshold:
        logger.warning('Fuzzy-matching is currently disabled as the “tlsh” module is unavailable.')
    Config.general.max_diff_block_lines = parsed_args.max_diff_block_lines
    Config.general.max_diff_input_lines = parsed_args.max_diff_input_lines
    Config.general.max_report_size = parsed_args.max_report_size
    Config.general.separate_file_diff_size = parsed_args.separate_file_diff_size
    Config.general.fuzzy_threshold = parsed_args.fuzzy_threshold
    Config.general.new_file = parsed_args.new_file
    if parsed_args.debug:
        logger.setLevel(logging.DEBUG)
    set_locale()
    difference = diffoscope.comparators.compare_root_paths(
        parsed_args.file1, parsed_args.file2)
    if difference:
        # no output desired? print text
        if not any((parsed_args.text_output, parsed_args.html_output, parsed_args.html_output_directory)):
            parsed_args.text_output = "-"
        if parsed_args.html_output:
            with make_printer(parsed_args.html_output) as print_func:
                output_html(difference, css_url=parsed_args.css_url, print_func=print_func)
        if parsed_args.html_output_directory:
                output_html_directory(parsed_args.html_output_directory, difference, css_url=parsed_args.css_url, jquery_url=parsed_args.jquery_url)
        if parsed_args.text_output:
            with make_printer(parsed_args.text_output or '-') as print_func:
                output_text(difference, print_func=print_func)
        return 1
    return 0
示例#5
0
def run_diffoscope(parsed_args):
    if not tlsh and Config.general.fuzzy_threshold != parsed_args.fuzzy_threshold:
        logger.warning('Fuzzy-matching is currently disabled as the “tlsh” module is unavailable.')
    Config.general.max_diff_block_lines = parsed_args.max_diff_block_lines
    Config.general.max_diff_input_lines = parsed_args.max_diff_input_lines
    Config.general.max_report_size = parsed_args.max_report_size
    Config.general.separate_file_diff_size = parsed_args.separate_file_diff_size
    Config.general.fuzzy_threshold = parsed_args.fuzzy_threshold
    Config.general.new_file = parsed_args.new_file
    if parsed_args.debug:
        logger.setLevel(logging.DEBUG)
    set_locale()
    difference = diffoscope.comparators.compare_root_paths(
        parsed_args.file1, parsed_args.file2)
    if difference:
        # no output desired? print text
        if not any((parsed_args.text_output, parsed_args.html_output, parsed_args.html_output_directory)):
            parsed_args.text_output = "-"
        if parsed_args.html_output:
            with make_printer(parsed_args.html_output) as print_func:
                output_html(difference, css_url=parsed_args.css_url, print_func=print_func)
        if parsed_args.html_output_directory:
                output_html_directory(parsed_args.html_output_directory, difference, css_url=parsed_args.css_url, jquery_url=parsed_args.jquery_url)
        if parsed_args.text_output:
            with make_printer(parsed_args.text_output or '-') as print_func:
                output_text(difference, print_func=print_func)
        return 1
    return 0
示例#6
0
def test_differences_with_dbgsym(dbgsym_differences):
    output_text(dbgsym_differences, print)
    assert dbgsym_differences.details[2].source1 == 'data.tar.xz'
    bin_details = dbgsym_differences.details[2].details[0].details[0]
    assert bin_details.source1 == './usr/bin/test'
    assert bin_details.details[1].source1.startswith('objdump')
    assert 'test-cases/dbgsym/package/test.c:2' in bin_details.details[
        1].unified_diff
def test_content(differences):
    output_text(differences[0], print_func=print)
    assert differences[0].source1 == 'dir/text'
    expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/text_ascii_expected_diff')).read()
    assert differences[0].unified_diff == expected_diff
示例#8
0
def test_stat(differences):
    output_text(differences[0], print_func=print)
    assert 'stat' in differences[0].details[0].source1
示例#9
0
def test_dot_changes_compare_non_existing(monkeypatch, dot_changes1):
    monkeypatch.setattr(Config.general, 'new_file', True)
    difference = dot_changes1.compare(NonExistingFile('/nonexisting', dot_changes1))
    output_text(difference, print_func=print)
    assert difference.source2 == '/nonexisting'
    assert difference.details[-1].source2 == '/dev/null'
示例#10
0
def dot_changes_differences(dot_changes1, dot_changes2):
    difference = dot_changes1.compare(dot_changes2)
    output_text(difference, print_func=print)
    return difference.details
示例#11
0
def dot_dsc_differences(dot_dsc1, dot_dsc2):
    difference = dot_dsc1.compare(dot_dsc2)
    output_text(difference, print_func=print)
    return difference.details
示例#12
0
def test_dot_dsc_compare_non_existing(monkeypatch, dot_dsc1):
    monkeypatch.setattr(Config.general, "new_file", True)
    difference = dot_dsc1.compare(NonExistingFile("/nonexisting", dot_dsc1))
    output_text(difference, print_func=print)
    assert difference.source2 == "/nonexisting"
    assert difference.details[-1].source2 == "/dev/null"
示例#13
0
def differences(rom1, rom2):
    difference = rom1.compare(rom2)
    output_text(difference, print_func=print)
    return difference.details
示例#14
0
def dot_changes_differences(dot_changes1, dot_changes2):
    difference = dot_changes1.compare(dot_changes2)
    output_text(difference, print_func=print)
    return difference.details
示例#15
0
def dot_dsc_differences(dot_dsc1, dot_dsc2):
    difference = dot_dsc1.compare(dot_dsc2)
    output_text(difference, print_func=print)
    return difference.details
示例#16
0
def test_stat(differences):
    output_text(differences[0], print_func=print)
    assert 'stat' in differences[0].details[0].source1
示例#17
0
def dot_buildinfo_differences(dot_buildinfo1, dot_buildinfo2):
    difference = dot_buildinfo1.compare(dot_buildinfo2)
    output_text(difference, print_func=print)
    return difference.details
示例#18
0
def dot_buildinfo_differences(dot_buildinfo1, dot_buildinfo2):
    difference = dot_buildinfo1.compare(dot_buildinfo2)
    output_text(difference, print_func=print)
    return difference.details