Fix line separators for windows in tests

This commit is contained in:
Natalia Ukhorskaya
2014-03-07 17:14:38 +04:00
parent 1fdd3bd615
commit d9d045cbb2
35 changed files with 45 additions and 45 deletions
@@ -206,7 +206,7 @@ public class AntTaskTest extends KotlinIntegrationTestBase {
}
private static void checkFilePrefixPostfix(@NotNull File file, @Nullable File prefix, @Nullable File postfix) throws IOException {
String fileContent = FileUtil.loadFile(file);
String fileContent = FileUtil.loadFile(file, true);
String prefixContent = FileUtilsPackage.readTextOrEmpty(prefix);
assertTrue(fileContent.startsWith(prefixContent));
@@ -513,7 +513,7 @@ public class JetTestUtils {
String content;
try {
content = StringUtil.convertLineSeparators(FileUtil.loadFile(new File(filePath)));
content = FileUtil.loadFile(new File(filePath), true);
}
catch (IOException e) {
throw new RuntimeException(e);
@@ -743,7 +743,7 @@ public class JetTestUtils {
}
public static JetFile loadJetFile(@NotNull Project project, @NotNull File ioFile) throws IOException {
String text = FileUtil.loadFile(ioFile);
String text = FileUtil.loadFile(ioFile, true);
return JetPsiFactory.createPhysicalFile(project, ioFile.getName(), text);
}
@@ -65,7 +65,7 @@ public abstract class AbstractCheckLocalVariablesTableTest extends TestCaseWithT
protected void doTest(@NotNull String ktFileName) throws Exception {
ktFile = new File(ktFileName);
String text = FileUtil.loadFile(ktFile);
String text = FileUtil.loadFile(ktFile, true);
JetFile psiFile = JetTestUtils.createFile(ktFile.getName(), text, jetCoreEnvironment.getProject());
assert psiFile != null;
@@ -77,7 +77,7 @@ public class LineNumberTest extends TestCaseWithTmpdir {
String text;
try {
text = FileUtil.loadFile(file);
text = FileUtil.loadFile(file, true);
}
catch (IOException e) {
throw UtilsPackage.rethrow(e);
@@ -38,7 +38,7 @@ public abstract class AbstractDefaultArgumentsReflectionTest extends CodegenTest
protected void doTest(String path) throws IOException {
loadFileByFullPath(path);
String fileText = FileUtil.loadFile(new File(path));
String fileText = FileUtil.loadFile(new File(path), true);
String className = loadInstructionValue(fileText, "CLASS");
boolean hasDefaultConstructor = loadInstructionValue(fileText, "HAS_DEFAULT_CONSTRUCTOR").equals("true");
@@ -58,7 +58,7 @@ public abstract class AbstractDescriptorSerializationTest extends KotlinTestWith
protected void doTest(@NotNull String path) throws IOException {
File ktFile = new File(path);
ModuleDescriptor moduleDescriptor = LazyResolveTestUtil.resolveEagerly(Collections.singletonList(
JetTestUtils.createFile(ktFile.getName(), FileUtil.loadFile(ktFile), getProject())
JetTestUtils.createFile(ktFile.getName(), FileUtil.loadFile(ktFile, true), getProject())
), getEnvironment());
PackageViewDescriptor testPackage = moduleDescriptor.getPackage(FqName.topLevel(TEST_PACKAGE_NAME));
@@ -61,7 +61,7 @@ abstract class AbstractEvaluateExpressionTest: AbstractAnnotationDescriptorResol
private fun doTest(path: String, getValueToTest: (JetProperty, BindingContext) -> String) {
val myFile = File(path)
val fileText = FileUtil.loadFile(myFile)
val fileText = FileUtil.loadFile(myFile, true)
val packageView = getPackage(fileText)
val propertiesForTest = getObjectsToTest(fileText)
@@ -138,7 +138,7 @@ public abstract class AbstractCompileKotlinAgainstKotlinTest extends TestCaseWit
@NotNull Disposable disposable
) throws IOException {
String text = FileUtil.loadFile(file);
String text = FileUtil.loadFile(file, true);
JetFile psiFile = JetTestUtils.createFile(file.getName(), text, jetCoreEnvironment.getProject());
@@ -186,7 +186,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
assertTrue(compiledDir.mkdir());
List<File> srcFiles = JetTestUtils.createTestFiles(
new File(javaFileName).getName(), FileUtil.loadFile(new File(javaFileName)),
new File(javaFileName).getName(), FileUtil.loadFile(new File(javaFileName), true),
new JetTestUtils.TestFileFactory<File>() {
@Override
public File create(String fileName, String text, Map<String, String> directives) {
@@ -66,7 +66,7 @@ public abstract class AbstractWriteSignatureTest extends TestCaseWithTmpdir {
protected void doTest(String ktFileName) throws Exception {
File ktFile = new File(ktFileName);
String text = FileUtil.loadFile(ktFile);
String text = FileUtil.loadFile(ktFile, true);
JetFile psiFile = JetTestUtils.createFile(ktFile.getName(), text, jetCoreEnvironment.getProject());
@@ -69,7 +69,7 @@ public class JetPsiUtilTest extends JetLiteFixture {
}
public void testIsLocalClass() throws IOException {
String text = FileUtil.loadFile(new File(getTestDataPath() + "/psiUtil/isLocalClass.kt"));
String text = FileUtil.loadFile(new File(getTestDataPath() + "/psiUtil/isLocalClass.kt"), true);
JetClass aClass = JetPsiFactory.createClass(getProject(), text);
@SuppressWarnings("unchecked")
@@ -49,7 +49,7 @@ public class JetCodeConformanceTest extends TestCase {
public void testParserCode() throws Exception {
for (File sourceFile : FileUtil.findFilesByMask(JAVA_FILE_PATTERN, new File("compiler/frontend/src/org/jetbrains/jet/lang/parsing"))) {
String source = FileUtil.loadFile(sourceFile);
String source = FileUtil.loadFile(sourceFile, true);
Pattern atPattern = Pattern.compile("assert.*?[^_]at.*?$", Pattern.MULTILINE);
Matcher matcher = atPattern.matcher(source);
@@ -68,7 +68,7 @@ public class JetCodeConformanceTest extends TestCase {
continue;
}
String source = FileUtil.loadFile(sourceFile);
String source = FileUtil.loadFile(sourceFile, true);
if (source.contains("@author") && JAVADOC_PATTERN.matcher(source).find()) { // .contains() is invoked for optimization
filesWithAuthorJavadoc.add(sourceFile);
@@ -23,7 +23,7 @@ import org.jetbrains.jet.JetTestUtils
public abstract class AbstractAnnotationParameterTest : AbstractAnnotationDescriptorResolveTest() {
fun doTest(path: String) {
val fileText = FileUtil.loadFile(File(path))
val fileText = FileUtil.loadFile(File(path), true)
val packageView = getPackage(fileText)
val classDescriptor = AbstractAnnotationDescriptorResolveTest.getClassDescriptor(packageView, "MyClass")
@@ -41,7 +41,7 @@ public class RecursiveDescriptorProcessorTest extends KotlinTestWithEnvironment
public void testRecursive() throws Exception {
File ktFile = new File("compiler/testData/recursiveProcessor/declarations.kt");
File txtFile = new File("compiler/testData/recursiveProcessor/declarations.txt");
String text = FileUtil.loadFile(ktFile);
String text = FileUtil.loadFile(ktFile, true);
JetFile jetFile = JetTestUtils.createFile("declarations.kt", text, getEnvironment().getProject());
AnalyzeExhaust exhaust = JetTestUtils.analyzeFile(jetFile);
PackageViewDescriptor testPackage = exhaust.getModuleDescriptor().getPackage(FqName.topLevel(Name.identifier("test")));
@@ -80,7 +80,7 @@ public class TypeSubstitutorTest extends KotlinTestWithEnvironment {
private JetScope getContextScope() throws IOException {
// todo comments
String text = FileUtil.loadFile(new File("compiler/testData/type-substitutor.kt"));
String text = FileUtil.loadFile(new File("compiler/testData/type-substitutor.kt"), true);
JetFile jetFile = JetPsiFactory.createFile(getProject(), text);
ModuleDescriptor module = LazyResolveTestUtil.resolveLazily(Collections.singletonList(jetFile), getEnvironment());
JetScope topLevelDeclarations = module.getPackage(FqName.ROOT).getMemberScope();
@@ -52,7 +52,7 @@ public abstract class AbstractJetQuickDocProviderTest extends LightCodeInsightFi
String info = CtrlMouseHandler.getInfo(targetElement, element);
File testDataFile = new File(path);
String textData = FileUtil.loadFile(testDataFile);
String textData = FileUtil.loadFile(testDataFile, true);
List<String> directives = InTextDirectivesUtils.findLinesWithPrefixesRemoved(textData, "INFO:");
if (directives.isEmpty()) {
@@ -265,7 +265,7 @@ public abstract class AbstractJetFindUsagesTest extends LightCodeInsightFixtureT
protected <T extends PsiElement> void doTest(@NotNull String path) throws Exception {
File mainFile = new File(path);
final String mainFileName = mainFile.getName();
String mainFileText = FileUtil.loadFile(mainFile);
String mainFileText = FileUtil.loadFile(mainFile, true);
final String prefix = mainFileName.substring(0, mainFileName.indexOf('.') + 1);
List<String> caretElementClassNames = InTextDirectivesUtils.findLinesWithPrefixesRemoved(mainFileText, "// PSI_ELEMENT: ");
@@ -105,7 +105,7 @@ public class JetTypingIndentationTest extends LightCodeInsightTestCase {
}
public void doFileSettingNewLineTest() throws Exception {
String originalFileText = FileUtil.loadFile(new File(getTestDataPath(), getBeforeFileName()));
String originalFileText = FileUtil.loadFile(new File(getTestDataPath(), getBeforeFileName()), true);
SettingsConfigurator configurator = JetFormatSettingsUtil.createConfigurator(originalFileText);
@@ -48,7 +48,7 @@ public abstract class JetLightCodeInsightFixtureTestCase extends LightCodeInsigh
protected LightProjectDescriptor getProjectDescriptorFromFileDirective() {
if (!isAllFilesPresentInTest()) {
try {
String fileText = FileUtil.loadFile(new File(getTestDataPath(), fileName()));
String fileText = FileUtil.loadFile(new File(getTestDataPath(), fileName()), true);
List<String> withLibraryDirective = InTextDirectivesUtils.findLinesWithPrefixesRemoved(fileText, "WITH_LIBRARY:");
if (!withLibraryDirective.isEmpty()) {
@@ -81,7 +81,7 @@ public abstract class AbstractInsertImportOnPasteTest extends JetLightCodeInsigh
myFixture.checkResultByFile(testFileName.replace(".kt", ".expected.kt"));
if (!InTextDirectivesUtils.isDirectiveDefined(FileUtil.loadFile(testFile), ALLOW_UNRESOLVED_DIRECTIVE)) {
if (!InTextDirectivesUtils.isDirectiveDefined(FileUtil.loadFile(testFile, true), ALLOW_UNRESOLVED_DIRECTIVE)) {
checkNoUnresolvedReferences(toFile);
}
}
@@ -134,7 +134,7 @@ public abstract class AbstractInsertImportOnPasteTest extends JetLightCodeInsigh
if (file.exists()) {
if (dependencyFileName.endsWith(".java")) {
//allow test framework to put it under right directory
myFixture.addClass(FileUtil.loadFile(file));
myFixture.addClass(FileUtil.loadFile(file, true));
}
else {
myFixture.configureByFile(dependencyFileName);
@@ -44,7 +44,7 @@ public abstract class AbstractCodeMoverTest extends LightCodeInsightTestCase {
private void doTest(@NotNull String path, @NotNull Class<? extends StatementUpDownMover> defaultMoverClass) throws Exception {
configureByFile(path);
String fileText = FileUtil.loadFile(new File(path));
String fileText = FileUtil.loadFile(new File(path), true);
String direction = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// MOVE: ");
boolean down = true;
@@ -81,7 +81,7 @@ public abstract class AbstractSurroundWithTest extends LightCodeInsightTestCase
private void doTest(String path, Surrounder surrounder) throws Exception {
configureByFile(path);
String fileText = FileUtil.loadFile(new File(path));
String fileText = FileUtil.loadFile(new File(path), true);
String isApplicableString = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// IS_APPLICABLE: ");
if (isApplicableString != null) {
@@ -162,7 +162,7 @@ public abstract class AbstractCodeTransformationTest extends LightCodeInsightTes
private void doTestIntention(@NotNull String path, @NotNull IntentionAction intentionAction) throws Exception {
configureByFile(path);
String fileText = FileUtil.loadFile(new File(path));
String fileText = FileUtil.loadFile(new File(path), true);
String isApplicableString = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// IS_APPLICABLE: ");
boolean isApplicableExpected = isApplicableString == null || isApplicableString.equals("true");
@@ -71,7 +71,7 @@ public abstract class AbstractQuickFixMultiFileTest extends DaemonAnalyzerTestCa
public void run() {
try {
Pair<String, Boolean> pair = LightQuickFixTestCase.parseActionHint(
getFile(),FileUtil.loadFile(new File(getTestDataPath() + beforeFileName)));
getFile(),FileUtil.loadFile(new File(getTestDataPath() + beforeFileName), true));
String text = pair.getFirst();
boolean actionShouldBeAvailable = pair.getSecond();
@@ -70,7 +70,7 @@ public abstract class AbstractJetMoveTest : MultiFileTestCase() {
)!!
}
val config = JsonParser().parse(FileUtil.loadFile(File(path))) as JsonObject
val config = JsonParser().parse(FileUtil.loadFile(File(path), true)) as JsonObject
val action = MoveAction.valueOf(config.getString("type"))
@@ -63,7 +63,7 @@ public abstract class AbstractRenameTest : MultiFileTestCase() {
val module: Module = getModule()!!)
public open fun doTest(path : String) {
val fileText = FileUtil.loadFile(File(path))
val fileText = FileUtil.loadFile(File(path), true)
val jsonParser = JsonParser()
val renameObject = jsonParser.parse(fileText) as JsonObject
@@ -31,8 +31,8 @@ import java.io.File;
public abstract class AbstractJetPsiMatcherTest extends JetLiteFixture {
public void doTestExpressions(@NotNull String path) throws Exception {
String fileText = FileUtil.loadFile(new File(path));
String fileText2 = FileUtil.loadFile(new File(path + ".2"));
String fileText = FileUtil.loadFile(new File(path), true);
String fileText2 = FileUtil.loadFile(new File(path + ".2"), true);
boolean equalityExpected = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// NOT_EQUAL") == null;
@@ -46,8 +46,8 @@ public abstract class AbstractJetPsiMatcherTest extends JetLiteFixture {
}
public void doTestTypes(@NotNull String path) throws Exception {
String fileText = FileUtil.loadFile(new File(path));
String fileText2 = FileUtil.loadFile(new File(path + ".2"));
String fileText = FileUtil.loadFile(new File(path), true);
String fileText2 = FileUtil.loadFile(new File(path + ".2"), true);
boolean equalityExpected = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// NOT_EQUAL") == null;
@@ -50,7 +50,7 @@ public abstract class AbstractSearcherTest extends LightCodeInsightFixtureTestCa
}
protected void checkResult(Query<?> actual) throws IOException {
List<String> expected = InTextDirectivesUtils.findListWithPrefixes(FileUtil.loadFile(new File(getPathToFile())), "// SEARCH: ");
List<String> expected = InTextDirectivesUtils.findListWithPrefixes(FileUtil.loadFile(new File(getPathToFile()), true), "// SEARCH: ");
List<String> actualModified = new ArrayList<String>();
for (Object member : actual) {
actualModified.add(member.toString());
@@ -42,7 +42,7 @@ public class AnnotatedMembersSearchTest extends AbstractSearcherTest {
private void doTest() throws IOException {
myFixture.configureByFile(getFileName());
List<String> directives = InTextDirectivesUtils.findListWithPrefixes(FileUtil.loadFile(new File(getPathToFile())),
List<String> directives = InTextDirectivesUtils.findListWithPrefixes(FileUtil.loadFile(new File(getPathToFile()), true),
"// ANNOTATION: ");
assertFalse("Specify ANNOTATION directive in test file", directives.isEmpty());
String annotationClassName = directives.get(0);
@@ -38,7 +38,7 @@ public class ClassInheritorsSearchTest extends AbstractSearcherTest {
private void doTest() throws IOException {
myFixture.configureByFile(getFileName());
List<String> directives = InTextDirectivesUtils.findListWithPrefixes(FileUtil.loadFile(new File(getPathToFile())), "// CLASS: ");
List<String> directives = InTextDirectivesUtils.findListWithPrefixes(FileUtil.loadFile(new File(getPathToFile()), true), "// CLASS: ");
assertFalse("Specify CLASS directive in test file", directives.isEmpty());
String superClassName = directives.get(0);
PsiClass psiClass = getPsiClass(superClassName);
@@ -49,7 +49,7 @@ public class JUnitMembersSearcherTest extends AbstractSearcherTest {
private void doJUnit3test() throws IOException {
myFixture.configureByFile(getFileName());
List<String> directives = InTextDirectivesUtils.findListWithPrefixes(FileUtil.loadFile(new File(getPathToFile())), "// CLASS: ");
List<String> directives = InTextDirectivesUtils.findListWithPrefixes(FileUtil.loadFile(new File(getPathToFile()), true), "// CLASS: ");
assertFalse("Specify CLASS directive in test file", directives.isEmpty());
String superClassName = directives.get(0);
PsiClass psiClass = getPsiClass(superClassName);
@@ -58,7 +58,7 @@ public class JUnitMembersSearcherTest extends AbstractSearcherTest {
private void doJUnit4test() throws IOException {
myFixture.configureByFile(getFileName());
List<String> directives = InTextDirectivesUtils.findListWithPrefixes(FileUtil.loadFile(new File(getPathToFile())),
List<String> directives = InTextDirectivesUtils.findListWithPrefixes(FileUtil.loadFile(new File(getPathToFile()), true),
"// ANNOTATION: ");
assertFalse("Specify ANNOTATION directive in test file", directives.isEmpty());
String annotationClassName = directives.get(0);
@@ -84,12 +84,12 @@ public final class OutputPrefixPostfixTest extends SingleFileTranslationTest {
super.runFunctionOutputTest(ecmaVersions, kotlinFilename, packageName, functionName, expectedResult);
for (EcmaVersion ecmaVersion : ecmaVersions) {
String output = FileUtil.loadFile(new File(getOutputFilePath(filename, ecmaVersion)));
String output = FileUtil.loadFile(new File(getOutputFilePath(filename, ecmaVersion)), true);
if (outputPrefixFile != null) {
assertTrue(output.startsWith(FileUtil.loadFile(outputPrefixFile)));
assertTrue(output.startsWith(FileUtil.loadFile(outputPrefixFile, true)));
}
if (outputPostfixFile != null) {
assertTrue(output.endsWith(FileUtil.loadFile(outputPostfixFile)));
assertTrue(output.endsWith(FileUtil.loadFile(outputPostfixFile, true)));
}
}
}
@@ -96,7 +96,7 @@ public final class RhinoUtils {
@NotNull Scriptable scope) throws Exception {
String result;
try {
result = FileUtil.loadFile(new File(inputFile));
result = FileUtil.loadFile(new File(inputFile), true);
}
catch (IOException e) {
throw new RuntimeException(e);
@@ -224,7 +224,7 @@ public final class RhinoUtils {
return null;
}
Object[] args = {FileUtil.loadFile(new File(fileName)), JSHINT_OPTIONS};
Object[] args = {FileUtil.loadFile(new File(fileName), true), JSHINT_OPTIONS};
Function function = (Function) ScriptableObject.getProperty(scope.getParentScope(), "JSHINT");
Object status = function.call(context, scope.getParentScope(), scope.getParentScope(), args);
if (!(Boolean) Context.jsToJava(status, Boolean.class)) {
@@ -71,7 +71,7 @@ public abstract class InlineTest extends SingleFileTranslationTest {
private void checkFooBoxIsTrueAndFunctionNameIsNotReferenced(@NotNull String filename, String funName) throws Exception {
fooBoxTest();
String generatedJSFilePath = getOutputFilePath(filename, EcmaVersion.defaultVersion());
String outputFileText = FileUtil.loadFile(new File(generatedJSFilePath));
String outputFileText = FileUtil.loadFile(new File(generatedJSFilePath), true);
assertTrue(countOccurrences(outputFileText, funName) == 1);
}
@@ -146,7 +146,7 @@ public final class TranslationUtils {
for (String libFileName : list) {
try {
String path = root == null ? libFileName : (root + libFileName);
String text = FileUtil.loadFile(new File(path));
String text = FileUtil.loadFile(new File(path), true);
JetFile jetFile = JetFileUtils.createJetFile(path, text, project);
libFiles.add(jetFile);
}