<commit_before># try loading rcov
begin
  require 'rcov/rcovtask'
rescue LoadError
  # STDERR.puts "rcov not installed"
  # ^^ I don't want to get this error every time.
end

def plugins_with_allowed_fixtures
  # skip plugins that load fixtures we don't have a schema for
  Engines.plugins.by_precedence.reject do |p|
     %w(
     multiple_select
     will_paginate
     acts_as_versioned
     acts_as_list
     better_acts_as_tree
     acts_as_state_machine
     ).include? p.name
  end
end

namespace :test do
  namespace :mods do

    desc "Run the plugin tests in extensions/mods/**/test (or specify with MOD=name)"
    task :all => [:units, :functionals, :integration]

    desc "Run all plugin unit tests"
    Rake::TestTask.new(:units => :setup_plugin_fixtures) do |t|
      t.pattern = "extensions/mods/#{ENV['MOD'] || "**"}/test/unit/**/*_test.rb"
      t.verbose = true
    end

    desc "Run all plugin functional tests"
    Rake::TestTask.new(:functionals => :setup_plugin_fixtures) do |t|
      t.pattern = "extensions/mods/#{ENV['MOD'] || "**"}/test/functional/**/*_test.rb"
      t.verbose = true
    end

    desc "Integration test engines"
    Rake::TestTask.new(:integration => :setup_plugin_fixtures) do |t|
      t.pattern = "extensions/mods/#{ENV['MOD'] || "**"}/test/integration/**/*_test.rb"
      t.verbose = true
    end

    desc "Mirrors plugin fixtures into a single location to help plugin tests"
    task :setup_plugin_fixtures => :environment do
      if ENV['MOD']
        plugin = Engines.plugins.detect{|plugin|plugin.name == ENV['MOD']}
        unless plugin
          puts 'ERROR: mod plugin named "%s" not found.' % ENV['MOD']
          exit
        end
        Engines::Testing.setup_plugin_fixtures([plugin])
      else
        Engines::Testing.setup_plugin_fixtures
      end
    end

  end
end

namespace :test do
  namespace :pages do

    desc "Run the plugin tests in extensions/pages/**/test (or specify with PAGE=name)"
    task :all => [:units, :functionals, :integration]<commit_msg>added rake test:fast:* -- this skips test:db:prepare, with radically speeds up tests. you still need to run test:db:prepare if the db has changed.<commit_after># try loading rcov
begin
  require 'rcov/rcovtask'
rescue LoadError
  # STDERR.puts "rcov not installed"
  # ^^ I don't want to get this error every time.
end

# def plugins_with_allowed_fixtures
#   # skip plugins that load fixtures we don't have a schema for
#   Engines.plugins.by_precedence.reject do |p|
#      %w(
#      multiple_select
#      will_paginate
#      acts_as_versioned
#      acts_as_list
#      better_acts_as_tree
#      acts_as_state_machine
#      ).include? p.name
#   end
# end

#
# Faster tests
#
# Normally, "rake test:x" will invoke db:test:prepare. This is really slow.
# This is only needed when we have changed the database.
#
# The rake tasks listed here are copies of the ones in Rails, but with db:test:prepare removed.
#
namespace :test do
  namespace :fast do
    Rake::TestTask.new(:units) do |t|
      t.libs << "test"
      t.pattern = 'test/unit/**/*_test.rb'
      t.verbose = true
    end
    Rake::Task['test:fast:units'].comment = "Run test:units without db:test:prepare"

    Rake::TestTask.new(:functionals) do |t|
      t.libs << "test"
      t.pattern = 'test/functional/**/*_test.rb'
      t.verbose = true
    end
    Rake::Task['test:fast:functionals'].comment = "Run test:functionals without db:test:prepare"

    Rake::TestTask.new(:integration) do |t|
      t.libs << "test"
      t.pattern = 'test/integration/**/*_test.rb'
      t.verbose = true
    end
    Rake::Task['test:fast:integration'].comment = "Run test:integration without db:test:prepare"
  end
end

#
# Testing mods
#
namespace :test do
  namespace :mods do

    desc "Run the plugin tests in extensions/mods/**/test (or specify with MOD=name)"
    task :all => [:units, :functionals, :integration]

    desc "Run all plugin unit tests"
    Rake::TestTask.new(:units => :setup_plugin_fixtures) do |t|
      t.pattern = "extensions/mods/#{ENV['MOD'] || "**"}/test/unit/**/*_test.rb"
      t.verbose = true
    end

    desc "Run all plugin functional tests"
    Rake::TestTask.new(:functionals => :setup_plugin_fixtures) do |t|
      t.pattern = "extensions/mods/#{ENV['MOD'] || "**"}/test/functional/**/*_test.rb"
      t.verbose = true
    end

    desc "Integration test engines"
    Rake::TestTask.new(:integration => :setup_plugin_fixtures) do |t|
      t.pattern = "extensions/mods/#{ENV['MOD'] || "**"}/test/integration/**/*_test.rb"
      t.verbose = true
    end

    desc "Mirrors plugin fixtures into a single location to help plugin tests"
    task :setup_plugin_fixtures => :environment do
      if ENV['MOD']
        plugin = Engines.plugins.detect{|plugin|plugin.name == ENV['MOD']}
        unless plugin
          puts 'ERROR: mod plugin named "%s" not found.' % ENV['MOD']
          exit
        end
        Engines::Testing.setup_plugin_fixtures([plugin])
      else
        Engines::Testing.setup_plugin_fixtures
      end
    end

  end
end

#
# Testing pages
#
namespace :test do
  namespace :pages do

    desc "Run the plugin tests in extensions/pages/**/test (or specify with PAGE=name)"
    task :all => [:units, :functionals, :integration]
{'fraction_non_alphanumeric': 0.1264215314632297, 'fraction_numerical': 0.0, 'mean_word_length': 3.106614785992218, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, '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': '6051780', 'n_tokens_mistral': 1727, 'n_tokens_neox': 1677, 'n_words': 477}