Abhijeet Sonar <abhijeet.nkt@xxxxxxxxx> writes: > I would like to change the owner of a file > in the test case I am writing -- an operation > that requires super-user privileges. I am not > sure if it is okay to do that in tests. Since > that would require running tests with `sudo`. What is the reason why you want to change the owner of a file in your test? If it is merely to make sure you cannot write to the .git/index file, temporarily doing chmod of the .git directory in a test (with POSIXPERM prerequisite) may be one way to do so, and you do not need the second user in the system test is running. Or if you pretend that you have a second process that is holding the lock in .git/index by creating .git/index.lock file yourself, that would also prevent your tested command from touching the index. The latter approach would result in a test that may look like so (I am writing this in my mail client, and I expect there may be some fix ups needed): test_expect_success 'see what --broken does upon unwritable index' ' test_when_finished "rm -f .git/index.lock" && test_commit A A.file && echo changed >>A.file && >.git/index.lock && test_must_fail git describe --dirty >actual 2>error && test_grep "could not write index" error && git describe --broken --dirty >actual 2>error && test_grep ! "could not write index" error && echo ...expected.describe.result... >expect && test_cmp expect actual ' HTH.