aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2022-01-31 08:25:44 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2022-02-01 00:05:51 +0100
commitfbe7f9c2912e058b419848af5e45ca8c7ff4b601 (patch)
tree110f20246a81f5cfb9ed2c8cfa6b9ac9aa4cd4e6 /org.eclipse.jgit.test
parent1fd15e40cc7bf67c30849abc3030de8568246a4e (diff)
downloadjgit-fbe7f9c2912e058b419848af5e45ca8c7ff4b601.tar.gz
jgit-fbe7f9c2912e058b419848af5e45ca8c7ff4b601.zip
[test] RepoCommandTest: guard tests for executable files
On Windows, java.io.File.canExecute is always true. Guard assertions testing the executable bit with FS.DETECTED.supportsExecute(). Bug: 550111 Change-Id: I2704d122f5b1086d01a0503a8c047a02ecbc1d4a Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java21
1 files changed, 14 insertions, 7 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java
index 509adc2cb2..3e6d13a67e 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java
@@ -15,6 +15,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
@@ -546,24 +547,29 @@ public class RepoCommandTest extends RepositoryTestCase {
// The original file should exist
File hello = new File(localDb.getWorkTree(), "foo/hello.txt");
assertTrue("The original file should exist", hello.exists());
- assertFalse("The original file should not be executable",
- hello.canExecute());
+ if (FS.DETECTED.supportsExecute()) {
+ assertFalse("The original file should not be executable",
+ FS.DETECTED.canExecute(hello));
+ }
assertContents(hello.toPath(), "master world");
// The dest file should also exist
hello = new File(localDb.getWorkTree(), "Hello");
assertTrue("The destination file should exist", hello.exists());
- assertFalse("The destination file should not be executable",
- hello.canExecute());
+ if (FS.DETECTED.supportsExecute()) {
+ assertFalse("The destination file should not be executable",
+ FS.DETECTED.canExecute(hello));
+ }
assertContents(hello.toPath(), "master world");
}
@Test
public void testRepoManifestCopyFile_executable() throws Exception {
+ assumeTrue(FS.DETECTED.supportsExecute());
try (Git git = new Git(defaultDb)) {
git.checkout().setName("master").call();
File f = JGitTestUtil.writeTrashFile(defaultDb, "hello.sh",
"content of the executable file");
- f.setExecutable(true);
+ FS.DETECTED.setExecute(f, true);
git.add().addFilepattern("hello.sh").call();
git.commit().setMessage("Add binary file").call();
}
@@ -588,7 +594,8 @@ public class RepoCommandTest extends RepositoryTestCase {
// The original file should exist and be an executable
File hello = new File(localDb.getWorkTree(), "foo/hello.sh");
assertTrue("The original file should exist", hello.exists());
- assertTrue("The original file must be executable", hello.canExecute());
+ assertTrue("The original file must be executable",
+ FS.DETECTED.canExecute(hello));
try (BufferedReader reader = Files.newBufferedReader(hello.toPath(),
UTF_8)) {
String content = reader.readLine();
@@ -600,7 +607,7 @@ public class RepoCommandTest extends RepositoryTestCase {
hello = new File(localDb.getWorkTree(), "copy-hello.sh");
assertTrue("The destination file should exist", hello.exists());
assertTrue("The destination file must be executable",
- hello.canExecute());
+ FS.DETECTED.canExecute(hello));
try (BufferedReader reader = Files.newBufferedReader(hello.toPath(),
UTF_8)) {
String content = reader.readLine();