Use assertTrue instead of assert

GitOrigin-RevId: 83fdb15a53686fad4175a525032dfea14cb116e9
This commit is contained in:
Tagir Valeev
2024-07-10 09:50:37 +02:00
committed by intellij-monorepo-bot
parent 75e4d4852a
commit 9a2d6e2607
4 changed files with 25 additions and 22 deletions

View File

@@ -36,8 +36,7 @@ import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.*;
import static org.junit.Assert.fail;
/** /**
* Provides 3 streams of output named system, stdout and stderr, * Provides 3 streams of output named system, stdout and stderr,
@@ -156,7 +155,7 @@ public class OutputChecker {
String actual = preprocessBuffer(buildOutputString(), sortClassPath); String actual = preprocessBuffer(buildOutputString(), sortClassPath);
File outsDir = new File(myAppPath.produce(), "outs"); File outsDir = new File(myAppPath.produce(), "outs");
assert outsDir.exists() || outsDir.mkdirs() : outsDir; assertTrue(outsDir.toString(), outsDir.exists() || outsDir.mkdirs());
File outFile = getOutFile(outsDir, jdk, null, ""); File outFile = getOutFile(outsDir, jdk, null, "");
if (!outFile.exists()) { if (!outFile.exists()) {

View File

@@ -58,6 +58,7 @@ import java.util.concurrent.TimeUnit;
import static com.intellij.configurationStore.StoreUtilKt.getPersistentStateComponentStorageLocation; import static com.intellij.configurationStore.StoreUtilKt.getPersistentStateComponentStorageLocation;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
public final class CompilerTester { public final class CompilerTester {
private static final Logger LOG = Logger.getInstance(CompilerTester.class); private static final Logger LOG = Logger.getInstance(CompilerTester.class);
@@ -142,7 +143,7 @@ public final class CompilerTester {
@Nullable @Nullable
public File findClassFile(String className, Module module) { public File findClassFile(String className, Module module) {
VirtualFile out = ModuleRootManager.getInstance(module).getModuleExtension(CompilerModuleExtension.class).getCompilerOutputPath(); VirtualFile out = ModuleRootManager.getInstance(module).getModuleExtension(CompilerModuleExtension.class).getCompilerOutputPath();
assert out != null; assertNotNull(out);
File cls = new File(out.getPath(), className.replace('.', '/') + ".class"); File cls = new File(out.getPath(), className.replace('.', '/') + ".class");
return cls.exists() ? cls : null; return cls.exists() ? cls : null;
} }
@@ -151,7 +152,7 @@ public final class CompilerTester {
WriteAction.runAndWait(() -> { WriteAction.runAndWait(() -> {
file.setBinaryContent(file.contentsToByteArray(), -1, file.getTimeStamp() + 1); file.setBinaryContent(file.contentsToByteArray(), -1, file.getTimeStamp() + 1);
File ioFile = VfsUtilCore.virtualToIoFile(file); File ioFile = VfsUtilCore.virtualToIoFile(file);
assert ioFile.setLastModified(ioFile.lastModified() - 100000); assertTrue(ioFile.setLastModified(ioFile.lastModified() - 100000));
file.refresh(false, false); file.refresh(false, false);
}); });
} }
@@ -197,11 +198,11 @@ public final class CompilerTester {
CompilerTestUtil.saveApplicationSettings(); CompilerTestUtil.saveApplicationSettings();
CompilerTests.saveWorkspaceModelCaches(getProject()); CompilerTests.saveWorkspaceModelCaches(getProject());
EdtTestUtil.runInEdtAndWait(() -> { EdtTestUtil.runInEdtAndWait(() -> {
// for now directory based project is used for external storage // for now, a directory-based project is used for external storage
if (!ProjectKt.isDirectoryBased(myProject)) { if (!ProjectKt.isDirectoryBased(myProject)) {
for (Module module : myModules) { for (Module module : myModules) {
Path ioFile = module.getModuleNioFile(); Path ioFile = module.getModuleNioFile();
assert Files.exists(ioFile) : "File does not exist: " + ioFile; assertTrue("File does not exist: " + ioFile, Files.exists(ioFile));
} }
} }

View File

@@ -39,6 +39,9 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
public abstract class JavaModuleFixtureBuilderImpl<T extends ModuleFixture> extends ModuleFixtureBuilderImpl<T> implements JavaModuleFixtureBuilder<T> { public abstract class JavaModuleFixtureBuilderImpl<T extends ModuleFixture> extends ModuleFixtureBuilderImpl<T> implements JavaModuleFixtureBuilder<T> {
private final List<Lib> myLibraries = new ArrayList<>(); private final List<Lib> myLibraries = new ArrayList<>();
private final List<MavenLib> myMavenLibraries = new ArrayList<>(); private final List<MavenLib> myMavenLibraries = new ArrayList<>();
@@ -210,18 +213,18 @@ public abstract class JavaModuleFixtureBuilderImpl<T extends ModuleFixture> exte
if (myOutputPath != null) { if (myOutputPath != null) {
final File pathFile = new File(myOutputPath); final File pathFile = new File(myOutputPath);
if (!pathFile.mkdirs()) { if (!pathFile.mkdirs()) {
assert pathFile.exists() : "unable to create: " + myOutputPath; assertTrue("unable to create: " + myOutputPath, pathFile.exists());
} }
final VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(myOutputPath); final VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(myOutputPath);
assert virtualFile != null : "cannot find output path: " + myOutputPath; assertNotNull("cannot find output path: " + myOutputPath, virtualFile);
rootModel.getModuleExtension(CompilerModuleExtension.class).setCompilerOutputPath(virtualFile); rootModel.getModuleExtension(CompilerModuleExtension.class).setCompilerOutputPath(virtualFile);
rootModel.getModuleExtension(CompilerModuleExtension.class).inheritCompilerOutputPath(false); rootModel.getModuleExtension(CompilerModuleExtension.class).inheritCompilerOutputPath(false);
rootModel.getModuleExtension(CompilerModuleExtension.class).setExcludeOutput(false); rootModel.getModuleExtension(CompilerModuleExtension.class).setExcludeOutput(false);
} }
if (myTestOutputPath != null) { if (myTestOutputPath != null) {
assert new File(myTestOutputPath).mkdirs() : myTestOutputPath; assertTrue(myTestOutputPath, new File(myTestOutputPath).mkdirs());
final VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(myTestOutputPath); final VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(myTestOutputPath);
assert virtualFile != null : "cannot find test output path: " + myTestOutputPath; assertNotNull("cannot find test output path: " + myTestOutputPath, virtualFile);
rootModel.getModuleExtension(CompilerModuleExtension.class).setCompilerOutputPathForTests(virtualFile); rootModel.getModuleExtension(CompilerModuleExtension.class).setCompilerOutputPathForTests(virtualFile);
rootModel.getModuleExtension(CompilerModuleExtension.class).inheritCompilerOutputPath(false); rootModel.getModuleExtension(CompilerModuleExtension.class).inheritCompilerOutputPath(false);
rootModel.getModuleExtension(CompilerModuleExtension.class).setExcludeOutput(false); rootModel.getModuleExtension(CompilerModuleExtension.class).setExcludeOutput(false);

View File

@@ -51,8 +51,8 @@ public class ShFileCompletionTest extends BasePlatformTestCase {
public void testSimple() throws Exception { public void testSimple() throws Exception {
if (SystemInfo.isWindows) return; // "Tests shouldn't run on Windows OS", if (SystemInfo.isWindows) return; // "Tests shouldn't run on Windows OS",
assert new File(myTempDirectory, FIRST_FILE_NAME).createNewFile(); assertTrue(new File(myTempDirectory, FIRST_FILE_NAME).createNewFile());
assert new File(myTempDirectory, SECOND_FILE_NAME).createNewFile(); assertTrue(new File(myTempDirectory, SECOND_FILE_NAME).createNewFile());
String path = myTempDirectory.getCanonicalPath(); String path = myTempDirectory.getCanonicalPath();
myFixture.configureByText("a.sh", path + "/<caret>"); myFixture.configureByText("a.sh", path + "/<caret>");
@@ -62,9 +62,9 @@ public class ShFileCompletionTest extends BasePlatformTestCase {
public void testFolderCompletion() throws Exception { public void testFolderCompletion() throws Exception {
if (SystemInfo.isWindows) return; // "Tests shouldn't run on Windows OS", if (SystemInfo.isWindows) return; // "Tests shouldn't run on Windows OS",
File folder = new File(myTempDirectory, FOLDER_NAME); File folder = new File(myTempDirectory, FOLDER_NAME);
assert folder.mkdir(); assertTrue(folder.mkdir());
assert new File(folder, FIRST_FILE_NAME).createNewFile(); assertTrue(new File(folder, FIRST_FILE_NAME).createNewFile());
assert new File(folder, SECOND_FILE_NAME).createNewFile(); assertTrue(new File(folder, SECOND_FILE_NAME).createNewFile());
String path = myTempDirectory.getCanonicalPath(); String path = myTempDirectory.getCanonicalPath();
myFixture.configureByText("a.sh", path + "/<caret>"); myFixture.configureByText("a.sh", path + "/<caret>");
@@ -77,7 +77,7 @@ public class ShFileCompletionTest extends BasePlatformTestCase {
public void testFileNameEncoding() throws Exception { public void testFileNameEncoding() throws Exception {
if (SystemInfo.isWindows) return; // "Tests shouldn't run on Windows OS", if (SystemInfo.isWindows) return; // "Tests shouldn't run on Windows OS",
String folderName = " '\"#$=,[]!<>|;{}()*?^&`"; String folderName = " '\"#$=,[]!<>|;{}()*?^&`";
assert new File(myTempDirectory, folderName).mkdir(); assertTrue(new File(myTempDirectory, folderName).mkdir());
String path = myTempDirectory.getCanonicalPath(); String path = myTempDirectory.getCanonicalPath();
myFixture.configureByText("a.sh", path + "/<caret>"); myFixture.configureByText("a.sh", path + "/<caret>");
@@ -123,8 +123,8 @@ public class ShFileCompletionTest extends BasePlatformTestCase {
public void testCompletionWithPrefixMatch() throws IOException { public void testCompletionWithPrefixMatch() throws IOException {
if (SystemInfo.isWindows) return; // "Tests shouldn't run on Windows OS", if (SystemInfo.isWindows) return; // "Tests shouldn't run on Windows OS",
assert new File(myTempDirectory, FIRST_FILE_NAME).createNewFile(); assertTrue(new File(myTempDirectory, FIRST_FILE_NAME).createNewFile());
assert new File(myTempDirectory, SECOND_FILE_NAME).createNewFile(); assertTrue(new File(myTempDirectory, SECOND_FILE_NAME).createNewFile());
String path = myTempDirectory.getCanonicalPath(); String path = myTempDirectory.getCanonicalPath();
myFixture.configureByText("a.sh", path + "/<caret>"); myFixture.configureByText("a.sh", path + "/<caret>");
@@ -142,9 +142,9 @@ public class ShFileCompletionTest extends BasePlatformTestCase {
public void testReplacement() throws Exception { public void testReplacement() throws Exception {
if (SystemInfo.isWindows) return; // "Tests shouldn't run on Windows OS", if (SystemInfo.isWindows) return; // "Tests shouldn't run on Windows OS",
assert new File(myTempDirectory, FOLDER_NAME).mkdir(); assertTrue(new File(myTempDirectory, FOLDER_NAME).mkdir());
assert new File(myTempDirectory, FIRST_FILE_NAME).createNewFile(); assertTrue(new File(myTempDirectory, FIRST_FILE_NAME).createNewFile());
assert new File(myTempDirectory, SECOND_FILE_NAME).createNewFile(); assertTrue(new File(myTempDirectory, SECOND_FILE_NAME).createNewFile());
String path = myTempDirectory.getCanonicalPath(); String path = myTempDirectory.getCanonicalPath();
myFixture.configureByText("a.sh", path + "/<caret>"); myFixture.configureByText("a.sh", path + "/<caret>");