<commit_before>description("Runs the applications tests") {
    usage "grails test-app [TEST NAME]"
    completer TestsCompleter
    synonyms 'test'
    argument name:"Test Name", description:"The name of the test to run (optional)", required:false
    flag name:'debug-jvm'
}


arguments = []

// configure environment to test is not specified
if(!commandLine.isEnvironmentSet()) {
    System.setProperty('grails.env', 'test')
}

// add test.single argument if specified
args = commandLine.remainingArgs.collect { "--tests $it".toString() }.join(' ')

// add debug flag if present
try {
    if(flag('debug-jvm')) {
        gradle."test $args --debug-jvm"(*arguments)
    }
    else {
        gradle."test $args"(*arguments)
    }
    addStatus "Tests PASSED"
    return true
} catch(e) {
    console.error "Tests FAILED", "Test execution failed"
    return false
}<commit_msg>GRAILS-11961 handle running integration tests in test-app<commit_after>description("Runs the applications tests") {
    usage "grails test-app [TEST NAME]"
    completer TestsCompleter
    synonyms 'test'
    argument name:"Test Name", description:"The name of the test to run (optional)", required:false
    flag name:'debug-jvm'
    flag name:'unit', description:"Run unit tests (test target)"
    flag name:'integration', description:"Run integration tests (integrationTest target)"
}

// configure environment to test is not specified
if(!commandLine.isEnvironmentSet()) {
    System.setProperty('grails.env', 'test')
}

// add test.single argument if specified
def testsFilter = commandLine.remainingArgs.collect { "--tests $it".toString() }.join(' ')?.trim()
boolean debugJvm = flag('debug-jvm')

def handleTestPhase = { targetName ->
    def args = []
    args << targetName
    if(testsFilter) {
        args << testsFilter
    }
    // add debug flag if present
    if(debugJvm) {
        args << "--debug-jvm"
    }
    args
}

def gradleArgs = []

boolean executeUnitTests = flag('unit') || !flag('integration')
if(executeUnitTests) {
    gradleArgs += handleTestPhase('test')
} 

boolean hasIntegrationTests = file("src/integration-test").isDirectory()
boolean executeIntegrationTests = hasIntegrationTests && (flag('integration') || !flag('unit'))
if(executeIntegrationTests) {
    gradleArgs += handleTestPhase('integrationTest')
}

try {
    gradle."${gradleArgs.join(' ')}"()
    addStatus "Tests PASSED"
    return true
} catch(e) {
    console.error "Tests FAILED", "Test execution failed"
    return false
}
{'fraction_non_alphanumeric': 0.13423891330403515, 'fraction_numerical': 0.001997602876548142, 'mean_word_length': 3.8810916179337234, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6800455', 'n_tokens_mistral': 748, 'n_tokens_neox': 724, 'n_words': 202}