@@ -101,7 +101,7 @@ public void testTouch() throws Exception {
101101 {
102102 assertThat (
103103 "Expected successful touch on a non-existent file with -c option" ,
104- shellRun ("-touch" , "-c" , newFileName ), is (not ( 0 ) ));
104+ shellRun ("-touch" , "-c" , newFileName ), is (0 ));
105105 assertThat (lfs .exists (newFile ), is (false ));
106106 }
107107
@@ -140,7 +140,7 @@ public void testTouch() throws Exception {
140140 Date dateObj = parseTimestamp (strTime );
141141
142142 assertThat (
143- "Expected successful touch with a specified modificatiom time" ,
143+ "Expected successful touch with a specified modification time" ,
144144 shellRun ("-touch" , "-m" , "-t" , strTime , newFileName ), is (0 ));
145145 // Verify if modification time is recorded correctly (and access time
146146 // remains unchanged).
@@ -179,6 +179,16 @@ public void testTouch() throws Exception {
179179 assertThat ("Expected failed touch with a missing timestamp" ,
180180 shellRun ("-touch" , "-t" , newFileName ), is (not (0 )));
181181 }
182+
183+ // Verify -c option when file exists.
184+ String strTime = formatTimestamp (System .currentTimeMillis ());
185+ Date dateObj = parseTimestamp (strTime );
186+ assertThat (
187+ "Expected successful touch on a non-existent file with -c option" ,
188+ shellRun ("-touch" , "-c" , "-t" , strTime , newFileName ), is (0 ));
189+ FileStatus fileStatus = lfs .getFileStatus (newFile );
190+ assertThat (fileStatus .getAccessTime (), is (dateObj .getTime ()));
191+ assertThat (fileStatus .getModificationTime (), is (dateObj .getTime ()));
182192 }
183193
184194 private String formatTimestamp (long timeInMillis ) {
0 commit comments