diff --git a/lib/org/hamcrest/annotations.xml b/lib/org/hamcrest/annotations.xml new file mode 100644 index 000000000000..36d1cf4640d1 --- /dev/null +++ b/lib/org/hamcrest/annotations.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/platform/testFramework/testSrc/TemporaryDirectory.kt b/platform/testFramework/testSrc/TemporaryDirectory.kt new file mode 100644 index 000000000000..d49ca2587174 --- /dev/null +++ b/platform/testFramework/testSrc/TemporaryDirectory.kt @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.testFramework + +import com.intellij.openapi.util.io.FileUtil +import com.intellij.openapi.util.io.FileUtilRt +import com.intellij.util.SmartList +import org.junit.rules.ExternalResource +import java.io.File + +public class TemporaryDirectory : ExternalResource() { + private val files = SmartList() + + override fun after() { + for (file in files) { + FileUtil.delete(file) + } + files.clear() + } + + public fun newDirectory(): File { + val file = FileUtilRt.generateRandomTemporaryPath() + files.add(file) + return file; + } +} diff --git a/platform/testFramework/testSrc/matchers.kt b/platform/testFramework/testSrc/matchers.kt new file mode 100644 index 000000000000..7f2fb364bba4 --- /dev/null +++ b/platform/testFramework/testSrc/matchers.kt @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.testFramework + +import org.hamcrest.Description +import org.hamcrest.Factory +import org.hamcrest.Matcher +import org.hamcrest.TypeSafeDiagnosingMatcher +import java.io.File + +public class FileExistenceMatcher(private val exists: Boolean) : TypeSafeDiagnosingMatcher(javaClass()) { + override fun matchesSafely(file: File, mismatchDescription: Description): Boolean { + if (exists == file.exists()) { + return true + } + + mismatchDescription.appendText("is not a file") + return false + } + + override fun describeTo(description: Description) { + description.appendText("an existing file") + } +} + +public Factory fun exists(): Matcher = FileExistenceMatcher(true) \ No newline at end of file