<commit_before># encoding: utf-8

require 'rake'
require 'fileutils'
require 'test/unit'
require 'rake/delphi'
require 'rake/delphi/project'
require 'rake/delphi/tool'
require 'rake/helpers/unittest'
require 'rake/helpers/raketask'
require 'helpers/consts'
require 'helpers/verinfo'

module DelphiTests

class TestDelphi < TestVerInfo
private
    def _test_compile_and_output(prepare_args, output)
        args = [:altercfg, :usecfg, :defines, :debuginfo, :debug, :includepaths]
        # reinitialize arguments (even absent ones)
        args.each do |arg|
            prepare_args[arg] = prepare_args[arg]
        end

        bin_dir = File.dirname(exe)
        dcu_dir_rel = '../../../../tmp/win32/dcu'
        dcu_dir = bin_dir + '/../' + dcu_dir_rel
        FileUtils.mkdir_p(bin_dir)
        FileUtils.mkdir_p(dcu_dir)
        # reenable task for subsequent calls
        prepare_task = ::Rake::Task['test:prepare']
        prepare_task.reenable
        # prepare arguments
        useresources = prepare_args[:useresources]
        prepare_args.delete(:useresources)
        prepare_args[:bin] = bin_dir
        prepare_args[:dcu] = dcu_dir_rel.gsub('/', '\\')

        prepare_task.invoke(useresources, prepare_args)

        # reenable tasks (!!! after invoking 'test:prepare')
        task = ::Rake::Task['test:compile']
        task.reenable_chain
        task.invoke

        assert(File.exists?(exe), 'File %s does not exist' % exe)
        out = `#{exe}`.chomp
        assert_equal output, out, 'exe output'<commit_msg>fixed: test/test-delphi.rb failure<commit_after># encoding: utf-8

require 'rake'
require 'fileutils'
require 'test/unit'
require 'rake/delphi'
require 'rake/delphi/project'
require 'rake/delphi/tool'
require 'rake/helpers/unittest'
require 'rake/helpers/raketask'
require 'helpers/consts'
require 'helpers/verinfo'

module DelphiTests

class TestDelphi < TestVerInfo
private
    def _test_compile_and_output(prepare_args, output)
        args = [:altercfg, :usecfg, :defines, :debuginfo, :debug, :includepaths]
        # reinitialize arguments (even absent ones)
        args.each do |arg|
            prepare_args[arg] = prepare_args[arg]
        end

        bin_dir = File.dirname(exe)
        dcu_dir_rel = '../../tmp/win32/dcu'
        dcu_dir = bin_dir + '/../../' + dcu_dir_rel
        FileUtils.mkdir_p(bin_dir)
        FileUtils.mkdir_p(dcu_dir)
        # reenable task for subsequent calls
        prepare_task = ::Rake::Task['test:prepare']
        prepare_task.reenable
        # prepare arguments
        useresources = prepare_args[:useresources]
        prepare_args.delete(:useresources)
        prepare_args[:bin] = bin_dir
        prepare_args[:dcu] = dcu_dir_rel.gsub('/', '\\')

        prepare_task.invoke(useresources, prepare_args)

        # reenable tasks (!!! after invoking 'test:prepare')
        task = ::Rake::Task['test:compile']
        task.reenable_chain
        task.invoke

        assert(File.exists?(exe), 'File %s does not exist' % exe)
        out = `#{exe}`.chomp
        assert_equal output, out, 'exe output'
{'fraction_non_alphanumeric': 0.12346079066753078, 'fraction_numerical': 0.0019442644199611147, 'mean_word_length': 2.932484076433121, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '310201', 'n_tokens_mistral': 1002, 'n_tokens_neox': 987, 'n_words': 203}