summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbst-marge-bot <marge-bot@buildstream.build>2019-03-28 14:04:33 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2019-03-28 14:04:33 +0000
commitf6de43de09681dcbfe3b4071c680240f0ffc5e64 (patch)
tree85c23bb35a1f6c8d7488f17f455f5602f656c64d
parentbef450dd6f31a8ff5e9084b71983a34676abce15 (diff)
parent69024535dd2ff2c95555f9ed47089ebe12345878 (diff)
downloadbuildstream-f6de43de09681dcbfe3b4071c680240f0ffc5e64.tar.gz
Merge branch 'jennis/track_is_overworking' into 'master'
Write test to ensure that track does not needlessly rewrite See merge request BuildStream/buildstream!1235
-rw-r--r--tests/frontend/track.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/frontend/track.py b/tests/frontend/track.py
index 13d1d4646..46f5bcf67 100644
--- a/tests/frontend/track.py
+++ b/tests/frontend/track.py
@@ -355,3 +355,43 @@ def test_track_error_cannot_write_file(cli, tmpdir, datafiles):
result.assert_task_error(ErrorDomain.SOURCE, 'save-ref-error')
finally:
os.chmod(element_path, stat.S_IMODE(st.st_mode))
+
+
+@pytest.mark.datafiles(DATA_DIR)
+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))
+ repo.create(dev_files_path)
+
+ # 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 = cli.run(project=project, args=['source', 'track', target])
+ result.assert_success()
+
+ track1_mtime = os.path.getmtime(path_to_target)
+
+ assert creation_mtime != track1_mtime
+
+ # Now (needlessly) track again
+ result = cli.run(project=project, args=['source', 'track', target])
+ result.assert_success()
+
+ track2_mtime = os.path.getmtime(path_to_target)
+
+ assert track1_mtime == track2_mtime