Commit f6de43de authored by bst-marge-bot's avatar bst-marge-bot

Merge branch 'jennis/track_is_overworking' into 'master'

Write test to ensure that track does not needlessly rewrite

See merge request !1235
parents bef450dd 69024535
Pipeline #54072742 passed with stages
in 99 minutes and 4 seconds
......@@ -355,3 +355,43 @@ def test_track_error_cannot_write_file(cli, tmpdir, datafiles):
result.assert_task_error(ErrorDomain.SOURCE, 'save-ref-error')
os.chmod(element_path, stat.S_IMODE(st.st_mode))
def test_no_needless_overwrite(cli, tmpdir, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename)
dev_files_path = os.path.join(project, 'files', 'dev-files')
element_path = os.path.join(project, 'elements')
target = 'track-test-target.bst'
# Create our repo object of the given source type with
# the dev files, and then collect the initial ref.
repo = create_repo('git', str(tmpdir))
# Write out our test target and assert it exists
generate_element(repo, os.path.join(element_path, target))
path_to_target = os.path.join(element_path, target)
assert os.path.exists(path_to_target)
creation_mtime = os.path.getmtime(path_to_target)
# Assert tracking is needed
states = cli.get_element_states(project, [target])
assert states[target] == 'no reference'
# Perform the track
result =, args=['source', 'track', target])
track1_mtime = os.path.getmtime(path_to_target)
assert creation_mtime != track1_mtime
# Now (needlessly) track again
result =, args=['source', 'track', target])
track2_mtime = os.path.getmtime(path_to_target)
assert track1_mtime == track2_mtime
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment