<commit_before>/*
 * Copyright 2010 the original author or authors.
 *
 * 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.gradle.integtests

import org.gradle.integtests.fixtures.ExecutionFailure
import org.gradle.util.OperatingSystem
import org.gradle.util.TestFile
import org.junit.Assert
import org.junit.Test

class CopyErrorIntegrationTest extends AbstractIntegrationTest {
    @Test
    public void reportsSymLinkWhichPointsToNothing() {
        if (OperatingSystem.current().isWindows()) {
            return
        }

        TestFile link = testFile('src/file')
        link.linkTo(testFile('missing'))

        Assert.assertFalse(link.isDirectory())
        Assert.assertFalse(link.isFile())
        Assert.assertFalse(link.exists())

        testFile('build.gradle') << '''
            task copy(type: Copy) {
                from 'src'
                into 'dest'
            }
'''

        ExecutionFailure failure = inTestDirectory().withTasks('copy').runWithFailure()
        failure.assertHasDescription("Could not list contents of '${link}'.")
    }

    @Test
    public void reportsUnreadableSourceDir() {
        if (OperatingSystem.current().isWindows()) {
            return
        }

        TestFile dir = testFile('src').createDir()
        dir.permissions = '-w-r--r--'

        Assert.assertTrue(dir.isDirectory())
        Assert.assertTrue(dir.exists())
        Assert.assertFalse(dir.canRead())
        Assert.assertTrue(dir.canWrite())

        testFile('build.gradle') << '''
            task copy(type: Copy) {
                from 'src'
                into 'dest'
            }
'''

        ExecutionFailure failure = inTestDirectory().withTasks('copy').runWithFailure()
        failure.assertHasDescription("Could not list contents of directory '${dir}' as it is not readable.")
    }
}<commit_msg>Fixed broken int test on unix<commit_after>/*
 * Copyright 2010 the original author or authors.
 *
 * 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.gradle.integtests

import org.gradle.integtests.fixtures.ExecutionFailure
import org.gradle.util.OperatingSystem
import org.gradle.util.TestFile
import org.junit.Assert
import org.junit.Test

class CopyErrorIntegrationTest extends AbstractIntegrationTest {
    @Test
    public void reportsSymLinkWhichPointsToNothing() {
        if (OperatingSystem.current().isWindows()) {
            return
        }

        TestFile link = testFile('src/file')
        link.linkTo(testFile('missing'))

        Assert.assertFalse(link.isDirectory())
        Assert.assertFalse(link.isFile())
        Assert.assertFalse(link.exists())

        testFile('build.gradle') << '''
            task copy(type: Copy) {
                from 'src'
                into 'dest'
            }
'''

        ExecutionFailure failure = inTestDirectory().withTasks('copy').runWithFailure()
        failure.assertHasDescription("Could not list contents of '${link}'.")
    }

    @Test
    public void reportsUnreadableSourceDir() {
        if (OperatingSystem.current().isWindows()) {
            return
        }

        TestFile dir = testFile('src').createDir()
        dir.permissions = '-w-r--r--'

        Assert.assertTrue(dir.isDirectory())
        Assert.assertTrue(dir.exists())
        Assert.assertFalse(dir.canRead())
        Assert.assertTrue(dir.canWrite())

        testFile('build.gradle') << '''
            task copy(type: Copy) {
                from 'src'
                into 'dest'
            }
'''

        ExecutionFailure failure = inTestDirectory().withTasks('copy').runWithFailure()
        failure.assertHasDescription("Could not list contents of directory '${dir}' as it is not readable.")

        dir.permissions = 'rwxr--r--'
    }
}
{'fraction_non_alphanumeric': 0.10824417872876023, 'fraction_numerical': 0.003356408642752255, 'mean_word_length': 2.676175790285274, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4675172', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1216, 'n_words': 351}