Skip to content

Commit

Permalink
Unify assume messages for selectively skipped tests
Browse files Browse the repository at this point in the history
The messages provided in assumeTrue/assumeFalse statements to
selectively skip tests on specific environments differ significantly and
in some cases no message is provided at all, leading to non-helpful
outputs like "Aborted, got: <false>, expected: is <true>".
This change adds missing messages and unifies the existing messages.
  • Loading branch information
HeikoKlare committed Dec 18, 2023
1 parent c2165a3 commit 641757e
Show file tree
Hide file tree
Showing 24 changed files with 81 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;

import java.io.File;
import java.io.IOException;
Expand All @@ -56,7 +58,6 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.tests.resources.WorkspaceTestRule;
import org.eclipse.osgi.util.NLS;
import org.junit.Assume;
import org.junit.Rule;
import org.junit.Test;

Expand Down Expand Up @@ -146,8 +147,8 @@ public void testCopyAcrossVolumes() throws Throwable {
IFileStore[] tempDirectories = getFileStoresOnTwoVolumes();

/* test if we are in the adequate environment */
Assume.assumeFalse(tempDirectories == null || tempDirectories.length < 2 || tempDirectories[0] == null
|| tempDirectories[1] == null);
assumeFalse("only executable if at least two volumes are present", tempDirectories == null
|| tempDirectories.length < 2 || tempDirectories[0] == null || tempDirectories[1] == null);

/* build scenario */
// create source root folder
Expand Down Expand Up @@ -231,7 +232,7 @@ public void testCopyDirectoryParentMissing() throws Throwable {
public void testCaseInsensitive() throws Throwable {
IFileStore temp = createDir(getWorkspace().getRoot().getLocation().append("temp").toString(), true);
boolean isCaseSensitive = temp.getFileSystem().isCaseSensitive();
Assume.assumeFalse("Skipping copy test on caseSensitive System", isCaseSensitive);
assumeFalse("only relevant for platforms with case-sensitive file system", isCaseSensitive);

// create a file
String content = "this is just a simple content \n to a simple file \n to test a 'simple' copy";
Expand Down Expand Up @@ -320,8 +321,8 @@ public void testCopyFileAcrossVolumes() throws Throwable {
IFileStore[] tempDirectories = getFileStoresOnTwoVolumes();

/* test if we are in the adequate environment */
Assume.assumeFalse(tempDirectories == null || tempDirectories.length < 2 || tempDirectories[0] == null
|| tempDirectories[1] == null);
assumeFalse("only executable if at least two volumes are present", tempDirectories == null
|| tempDirectories.length < 2 || tempDirectories[0] == null || tempDirectories[1] == null);

/* build scenario */
/* get the source folder */
Expand Down Expand Up @@ -474,8 +475,8 @@ public void testMoveAcrossVolumes() throws Throwable {
IFileStore[] tempDirectories = getFileStoresOnTwoVolumes();

/* test if we are in the adequate environment */
Assume.assumeFalse(tempDirectories == null || tempDirectories.length < 2 || tempDirectories[0] == null
|| tempDirectories[1] == null);
assumeFalse("only executable if at least two volumes are present", tempDirectories == null
|| tempDirectories.length < 2 || tempDirectories[0] == null || tempDirectories[1] == null);

/* build scenario */
/* get the source folder */
Expand Down Expand Up @@ -590,7 +591,7 @@ public void testPermissions() throws Exception {
}

private void testAttribute(int attribute) throws Exception {
Assume.assumeTrue(isAttributeSupported(attribute));
assumeTrue("only relevant for platforms supporting attribute: " + attribute, isAttributeSupported(attribute));

IPath root = getWorkspace().getRoot().getLocation().append("" + new Date().getTime());
IFileStore targetFolder = createDir(root.toString(), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;

import java.io.IOException;
Expand All @@ -37,9 +38,9 @@
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Platform.OS;
import org.eclipse.core.tests.filesystem.FileStoreCreationRule.FileSystemType;
import org.eclipse.core.tests.harness.FileSystemHelper;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand All @@ -65,7 +66,7 @@ public class SymlinkTest {

@Before
public void assumeSymbolicLinksAvailable() throws Exception {
assumeTrue("Can't create symbolic links in this platform: " + Platform.getOS(),
assumeTrue("only relevant for platforms supporting symbolic links",
FileSystemHelper.canCreateSymLinks());
}

Expand Down Expand Up @@ -377,8 +378,7 @@ public void _testSymlinkExtendedChars() throws Exception {

@Test
public void testSymlinkPutLastModified() throws Exception {
// flag EFS.SET_LAST_MODIFIED is set by java.io and it fails on Mac OS
Assume.assumeFalse(Platform.OS_MACOSX.equals(Platform.getOS()));
assumeFalse("setting EFS.SET_LAST_MODIFIED fails on Mac", OS.isMac());

//check that putInfo() "writes through" the symlink
makeLinkStructure();
Expand Down Expand Up @@ -441,7 +441,8 @@ public void testSymlinkPutReadOnly() throws Exception {

@Test
public void testSymlinkPutExecutable() throws Exception {
Assume.assumeTrue(isAttributeSupported(EFS.ATTRIBUTE_EXECUTABLE));
assumeTrue("only relevant for platforms supporting hidden attribute",
isAttributeSupported(EFS.ATTRIBUTE_EXECUTABLE));

//check that putInfo() "writes through" the symlink
makeLinkStructure();
Expand All @@ -466,7 +467,8 @@ public void testSymlinkPutExecutable() throws Exception {

@Test
public void testSymlinkPutHidden() throws Exception {
Assume.assumeTrue(isAttributeSupported(EFS.ATTRIBUTE_HIDDEN));
assumeTrue("only relevant for platforms supporting hidden attribute",
isAttributeSupported(EFS.ATTRIBUTE_HIDDEN));

// Check that putInfo() applies the attribute to the symlink itself.
makeLinkStructure();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;

import java.net.URI;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -62,7 +64,6 @@
import org.eclipse.core.runtime.Platform.OS;
import org.eclipse.core.tests.internal.filesystem.wrapper.WrapperFileSystem;
import org.eclipse.core.tests.resources.WorkspaceTestRule;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -272,11 +273,11 @@ public void testBug156082() throws CoreException {
*/
@Test
public void testBug198571() throws Exception {
Assume.assumeTrue(OS.isWindows());
assumeTrue("only relevant on Windows", OS.isWindows());

/* look for the adequate environment */
String[] devices = findAvailableDevices();
Assume.assumeFalse(devices[0] == null || devices[1] == null);
assumeFalse("only executable if at least two volumes are present", devices[0] == null || devices[1] == null);

String location = createUniqueString();
IProject testProject1 = getWorkspace().getRoot().getProject(location + "1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;

import org.eclipse.core.internal.resources.File;
Expand All @@ -48,7 +49,6 @@
import org.eclipse.core.runtime.Platform.OS;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.tests.resources.WorkspaceTestRule;
import org.junit.Assume;
import org.junit.Rule;
import org.junit.Test;

Expand All @@ -67,11 +67,11 @@ public class MoveTest {
*/
@Test
public void testMoveFileAcrossVolumes() throws CoreException {
assumeTrue(OS.isWindows());
assumeTrue("only relevant on Windows", OS.isWindows());

/* look for the adequate environment */
String[] devices = findAvailableDevices();
Assume.assumeFalse(devices[0] == null || devices[1] == null);
assumeFalse("only executable if at least two volumes are present", devices[0] == null || devices[1] == null);

// create common objects
String location = createUniqueString();
Expand Down Expand Up @@ -171,11 +171,11 @@ public void testMoveFileBetweenProjects() throws Exception {
*/
@Test
public void testMoveFolderAcrossVolumes() throws CoreException {
assumeTrue(OS.isWindows());
assumeTrue("only relevant on Windows", OS.isWindows());

/* look for the adequate environment */
String[] devices = findAvailableDevices();
Assume.assumeFalse(devices[0] == null || devices[1] == null);
assumeFalse("only executable if at least two volumes are present", devices[0] == null || devices[1] == null);

// create common objects
String location = createUniqueString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected void createBug358830Structure(IFileStore rootDir) throws CoreException
*/
@Test
public void testBug232426() throws Exception {
assumeTrue("test is only relevant for Platforms supporting symbolic links", canCreateSymLinks());
assumeTrue("only relevant for platforms supporting symbolic links", canCreateSymLinks());

IProject project = getWorkspace().getRoot().getProject("Project");
createInWorkspace(project);
Expand Down Expand Up @@ -120,7 +120,7 @@ public boolean visit(IResource resource) {

@Test
public void testBug358830() throws Exception {
assumeTrue("test is only relevant for Platforms supporting symbolic links", canCreateSymLinks());
assumeTrue("only relevant for platforms supporting symbolic links", canCreateSymLinks());

IProject project = getWorkspace().getRoot().getProject("Project");
createInWorkspace(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ public void testProjectCreationInvalidLocation() {
*/
@Test
public void testProjectCreationLocationExistsWithDifferentCase() throws CoreException {
assumeTrue("Case-sensitive file system test only relevant for Windows", OS.isWindows());
assumeTrue("only relevant on Windows", OS.isWindows());

String projectName = createUniqueString() + "a";
IProject project = getWorkspace().getRoot().getProject(projectName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class IWorkspaceRootTest {
*/
@Test
public void testFindFilesNonCanonicalPath() throws Exception {
assumeTrue("this test is for windows only", OS.isWindows());
assumeTrue("only relevant on Windows", OS.isWindows());

IProject project = getWorkspace().getRoot().getProject("testFindFilesNonCanonicalPath");
createInWorkspace(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ public void testDeleteFolderWithLinks() throws CoreException {
*/
@Test
public void testFindFilesForLocationCaseVariant() throws CoreException {
assumeTrue("this test only applies to file systems with a device in the path", OS.isWindows());
assumeTrue("only relevant on Windows", OS.isWindows());

IFolder link = nonExistingFolderInExistingProject;
IPath localLocation = resolve(localFolder);
Expand Down Expand Up @@ -1279,7 +1279,7 @@ public void testValidateEmptyLinkLocation() {
*/
@Test
public void testLocationWithColon() throws CoreException {
assumeFalse("Windows does not allow a location with colon in the name", OS.isWindows());
assumeFalse("not relevant on Windows, as it does not allow a location with colon in the name", OS.isWindows());

IFolder folder = nonExistingFolderInExistingProject;
// Note that on *nix, "c:/temp" is a relative path with two segments
Expand Down Expand Up @@ -1762,7 +1762,7 @@ public void testLinkedFolderWithOverlappingLocation_Bug293935_() {

@Test
public void testLinkedFolderWithSymlink_Bug338010() throws Exception {
assumeTrue("test is only applicable when symbolic links can be created", canCreateSymLinks());
assumeTrue("only relevant for platforms supporting symbolic links", canCreateSymLinks());

IPath baseLocation = getRandomLocation();
IPath resolvedBaseLocation = resolve(baseLocation);
Expand All @@ -1787,7 +1787,7 @@ public void testLinkedFolderWithSymlink_Bug338010() throws Exception {
*/
@Test
public void testDeleteLinkTarget_Bug507084() throws Exception {
assumeTrue("test is only applicable when symbolic links can be created", canCreateSymLinks());
assumeTrue("only relevant for platforms supporting symbolic links", canCreateSymLinks());

IPath baseLocation = getRandomLocation();
IPath resolvedBaseLocation = resolve(baseLocation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private void setSymlink(IResource resource, boolean value) throws CoreException

@Test
public void testAttributeArchive() throws CoreException {
assumeTrue("test only relevant for platforms supporting archive attribute",
assumeTrue("only relevant for platforms supporting archive attribute",
isAttributeSupported(EFS.ATTRIBUTE_ARCHIVE));

IProject project = getWorkspace().getRoot().getProject("Project");
Expand All @@ -104,7 +104,7 @@ public void testAttributeArchive() throws CoreException {

@Test
public void testAttributeExecutable() throws CoreException {
assumeTrue("test only relevant for platforms supporting executable attribute",
assumeTrue("only relevant for platforms supporting executable attribute",
isAttributeSupported(EFS.ATTRIBUTE_EXECUTABLE));

IProject project = getWorkspace().getRoot().getProject("Project");
Expand All @@ -129,7 +129,7 @@ public void testAttributeExecutable() throws CoreException {

@Test
public void testAttributeHidden() throws CoreException {
assumeTrue("test only relevant for platforms supporting hidden attribute",
assumeTrue("only relevant for platforms supporting hidden attribute",
isAttributeSupported(EFS.ATTRIBUTE_HIDDEN));

IProject project = getWorkspace().getRoot().getProject("Project");
Expand All @@ -153,7 +153,7 @@ public void testAttributeHidden() throws CoreException {

@Test
public void testAttributeReadOnly() throws CoreException {
assumeTrue("test only relevant for platforms supporting read-only attribute",
assumeTrue("only relevant for platforms supporting read-only attribute",
isAttributeSupported(EFS.ATTRIBUTE_READ_ONLY));

IProject project = getWorkspace().getRoot().getProject("Project");
Expand Down Expand Up @@ -219,7 +219,7 @@ public void testNonExistingResource() throws CoreException {
@Test
@Ignore("currently failing on Hudson: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=397353")
public void testRefreshExecutableOnFolder() throws CoreException {
assumeTrue("test only relevant for platforms supporting executable attribute",
assumeTrue("only relevant for platforms supporting executable attribute",
isAttributeSupported(EFS.ATTRIBUTE_EXECUTABLE));

IProject project = getWorkspace().getRoot().getProject("testRefreshExecutableOnFolder");
Expand Down Expand Up @@ -247,7 +247,7 @@ public void testRefreshExecutableOnFolder() throws CoreException {

@Test
public void testAttributeSymlink() throws Exception {
assumeTrue("test only relevant for platforms supporting symlinks", canCreateSymLinks());
assumeTrue("only relevant for platforms supporting symbolic links", canCreateSymLinks());

IProject project = getWorkspace().getRoot().getProject("Project");
IFile link = project.getFile("link");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public void testProjectDeletion() throws Throwable {

@Test
public void testWorkingLocationDeletion_bug433061() throws Throwable {
assumeTrue("test only makes sense when Platform support symbolic links", canCreateSymLinks());
assumeTrue("only relevant for platforms supporting symbolic links", canCreateSymLinks());

IProject project = getTestProject();
FussyProgressMonitor monitor = new FussyProgressMonitor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class Bug_025457 {

@Test
public void testFile() throws Exception {
assumeTrue("test only works on Windows", OS.isWindows());
assumeTrue("only relevant on Windows", OS.isWindows());

IProject source = getWorkspace().getRoot().getProject("project");
IFile sourceFile = source.getFile("file.txt");
Expand Down Expand Up @@ -79,7 +79,7 @@ public void testFile() throws Exception {
@Test
public void testFolder() throws IOException, CoreException {
//native code must also be present so move can detect the case change
assumeTrue("test only works on Windows", OS.isWindows() && isReadOnlySupported());
assumeTrue("only relevant on Windows", OS.isWindows() && isReadOnlySupported());

IProject source = getWorkspace().getRoot().getProject("SourceProject");
IFolder sourceFolder = source.getFolder("folder");
Expand Down Expand Up @@ -108,7 +108,7 @@ public void testFolder() throws IOException, CoreException {

@Test
public void testProject() throws IOException, CoreException {
assumeTrue("test only works on Windows", OS.isWindows());
assumeTrue("only relevant on Windows", OS.isWindows());

IProject source = getWorkspace().getRoot().getProject("project");
IProject destination = getWorkspace().getRoot().getProject("Project");
Expand Down
Loading

0 comments on commit 641757e

Please sign in to comment.