Skip to content

Commit

Permalink
tests/docs: Add test for --consider-mtime
Browse files Browse the repository at this point in the history
  • Loading branch information
sahib committed Nov 17, 2016
1 parent 8f38c6e commit fdd120d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/rmlint.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,11 @@ Rarely used, miscellaneous options
Also it might be useful for approximate comparison where it suffices when
the file is the same in the middle part.

:``-z --consider-mtime`` / ``-Z --ignore-mtime`` (**default**):

Only consider those files as duplicates that have the same content and
the same modification time (mtime).

:``--with-fiemap`` (**default**) / ``--without-fiemap``:

Enable or disable reading the file extents on rotational disk in order to
Expand Down
35 changes: 35 additions & 0 deletions tests/test_options/test_consider_mtime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python3
# encoding: utf-8
from nose import with_setup
from tests.utils import *

import os
import subprocess


@with_setup(usual_setup_func, usual_teardown_func)
def test_consider_mtime():
create_file('xxx', 'a')
create_file('xxx', 'b')
create_file('xxx', 'c')

def set_mtime(path, mtime):
full_path = os.path.join(TESTDIR_NAME, path)
subprocess.call(['touch', '-m', '-d', str(mtime), full_path])

set_mtime('a', '2004-02-29 16:21:42')
set_mtime('b', '2004-02-29 16:21:42')
set_mtime('c', '2004-02-29 16:21:43')

head, *data, footer = run_rmlint('--ignore-mtime')
assert len(data) == 3
assert footer['total_files'] == 3
assert footer['total_lint_size'] == 6
assert footer['duplicates'] == 2

head, *data, footer = run_rmlint('--consider-mtime')

assert len(data) == 2
assert footer['total_files'] == 3
assert footer['total_lint_size'] == 3
assert footer['duplicates'] == 1

0 comments on commit fdd120d

Please sign in to comment.