Move T0007_Index to exttst
This test depends upon the external git binary, and this isn't really a pure Java test like our module tries to claim itself is. So we move it out to exttst with other tests that require additional external resources and/or executable code. Change-Id: Ic9be0280c8bb50a5768336c64de794eb0a492b3d Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
parent
1e84e8ad93
commit
b28aadf10f
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2007-2008, Robin Rosenberg <robin.rosenberg@dewire.com>
|
* Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
|
||||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||||
* and other copyright owners as documented in the project's IP log.
|
* and other copyright owners as documented in the project's IP log.
|
||||||
*
|
*
|
||||||
|
@ -45,16 +45,16 @@
|
||||||
package org.eclipse.jgit.lib;
|
package org.eclipse.jgit.lib;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase;
|
||||||
import org.eclipse.jgit.lib.GitIndex.Entry;
|
import org.eclipse.jgit.lib.GitIndex.Entry;
|
||||||
import org.eclipse.jgit.util.FS;
|
import org.eclipse.jgit.util.FS;
|
||||||
|
|
||||||
public class T0007_Index extends RepositoryTestCase {
|
public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase {
|
||||||
|
|
||||||
static boolean canrungitstatus;
|
static boolean canrungitstatus;
|
||||||
static {
|
static {
|
||||||
|
@ -108,6 +108,17 @@ public void run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Repository db;
|
||||||
|
|
||||||
|
private File trash;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
db = createWorkRepository();
|
||||||
|
trash = db.getWorkDir();
|
||||||
|
}
|
||||||
|
|
||||||
public void testCreateEmptyIndex() throws Exception {
|
public void testCreateEmptyIndex() throws Exception {
|
||||||
GitIndex index = new GitIndex(db);
|
GitIndex index = new GitIndex(db);
|
||||||
index.write();
|
index.write();
|
||||||
|
@ -317,9 +328,9 @@ public void testCheckout() throws Exception {
|
||||||
"c696abc3ab8e091c665f49d00eb8919690b3aec3")));
|
"c696abc3ab8e091c665f49d00eb8919690b3aec3")));
|
||||||
|
|
||||||
index2.checkout(trash);
|
index2.checkout(trash);
|
||||||
assertEquals("data:a/b", content(aslashb));
|
assertEquals("data:a/b", read(aslashb));
|
||||||
assertEquals("data:a:b", content(acolonb));
|
assertEquals("data:a:b", read(acolonb));
|
||||||
assertEquals("data:a.b", content(adotb));
|
assertEquals("data:a.b", read(adotb));
|
||||||
|
|
||||||
if (canrungitstatus)
|
if (canrungitstatus)
|
||||||
assertEquals(0, system(trash, "git status"));
|
assertEquals(0, system(trash, "git status"));
|
||||||
|
@ -436,20 +447,14 @@ public void test031_executeBit_coreModeFalse() throws IllegalArgumentException,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String content(File f) throws IOException {
|
|
||||||
byte[] buf = new byte[(int) f.length()];
|
|
||||||
FileInputStream is = new FileInputStream(f);
|
|
||||||
try {
|
|
||||||
int read = is.read(buf);
|
|
||||||
assertEquals(f.length(), read);
|
|
||||||
return new String(buf, 0);
|
|
||||||
} finally {
|
|
||||||
is.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void delete(File f) throws IOException {
|
private void delete(File f) throws IOException {
|
||||||
if (!f.delete())
|
if (!f.delete())
|
||||||
throw new IOException("Failed to delete f");
|
throw new IOException("Failed to delete f");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private File writeTrashFile(String name, String body) throws IOException {
|
||||||
|
final File path = new File(trash, name);
|
||||||
|
write(path, body);
|
||||||
|
return path;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue