<commit_before>package emitter

import (
	"errors"
	"qa/runner"
	"qa/runner/ruby"
	"qa/runner/server"
	"qa/tapjio"
)

type Emitter interface {
	TraceProbes() []string
	EnumerateTests() ([]tapjio.TraceEvent, []runner.TestRunner, error)
}

type emitterStarter func(
	srv *server.Server,
	passthroughConfig map[string](interface{}),
	workerEnvs []map[string]string,
	dir string,
	env map[string]string,
	seed int,
	files []string) (Emitter, error)

// Enable entries below to add specific method calls (and optionally their arguments) to the trace.
var rubyTraceProbes = []string{
// "Kernel#require(path)",
// "Kernel#load",
// "ActiveRecord::ConnectionAdapters::Mysql2Adapter#execute(sql,name)",
// "ActiveRecord::ConnectionAdapters::PostgresSQLAdapter#execute_and_clear(sql,name,binds)",
// "ActiveSupport::Dependencies::Loadable#require(path)",
// "ActiveRecord::ConnectionAdapters::QueryCache#clear_query_cache",
// "ActiveRecord::ConnectionAdapters::SchemaCache#initialize",
// "ActiveRecord::ConnectionAdapters::SchemaCache#clear!",
// "ActiveRecord::ConnectionAdapters::SchemaCache#clear_table_cache!",
}

func rubyEmitterStarter(runnerAssetName string, policy ruby.SquashPolicy) emitterStarter {
	return func(
		srv *server.Server,
		passthroughConfig map[string](interface{}),
		workerEnvs []map[string]string,
		dir string,
		env map[string]string,
		seed int,
		files []string) (Emitter, error) {

		config := &ruby.ContextConfig{
			Dir:               dir,
			EnvVars:           env,
			Seed:              seed,
			Rubylib:           []string{"spec", "lib", "test"},
			RunnerAssetName:   runnerAssetName,
			TraceProbes:       rubyTraceProbes,
			SquashPolicy:      policy,
			PassthroughConfig: passthroughConfig,
		}

		ctx, err := ruby.StartContext(config, srv, workerEnvs, files)
		if err != nil {
			return nil, err
		}

		return ctx, nil
	}
}

var starters = map[string]emitterStarter{
	"rspec":               rubyEmitterStarter("ruby/rspec.rb", ruby.SquashByFile),
	"rspec-squashall":     rubyEmitterStarter("ruby/rspec.rb", ruby.SquashAll),
	"rspec-pendantic":     rubyEmitterStarter("ruby/rspec.rb", ruby.SquashNothing),
	"minitest":            rubyEmitterStarter("ruby/minitest.rb", ruby.SquashByFile),
	"minitest-squashall":  rubyEmitterStarter("ruby/minitest.rb", ruby.SquashAll),
	"minitest-pendantic":  rubyEmitterStarter("ruby/minitest.rb", ruby.SquashNothing),
	"test-unit":           rubyEmitterStarter("ruby/test-unit.rb", ruby.SquashByFile),
	"test-unit-squashall": rubyEmitterStarter("ruby/test-unit.rb", ruby.SquashAll),
	"test-unit-pendantic": rubyEmitterStarter("ruby/test-unit.rb", ruby.SquashNothing),
}

var defaultGlobs = map[string]string {
	"rspec": "spec/**/*spec.rb",
	"minitest": "test/**/test*.rb",
	"test-unit": "test/**/test*.rb",
}

func DefaultGlob(name string) string {<commit_msg>Add default globs for -squashall, -pendantic<commit_after>package emitter

import (
	"errors"
	"qa/runner"
	"qa/runner/ruby"
	"qa/runner/server"
	"qa/tapjio"
)

type Emitter interface {
	TraceProbes() []string
	EnumerateTests() ([]tapjio.TraceEvent, []runner.TestRunner, error)
}

type emitterStarter func(
	srv *server.Server,
	passthroughConfig map[string](interface{}),
	workerEnvs []map[string]string,
	dir string,
	env map[string]string,
	seed int,
	files []string) (Emitter, error)

// Enable entries below to add specific method calls (and optionally their arguments) to the trace.
var rubyTraceProbes = []string{
// "Kernel#require(path)",
// "Kernel#load",
// "ActiveRecord::ConnectionAdapters::Mysql2Adapter#execute(sql,name)",
// "ActiveRecord::ConnectionAdapters::PostgresSQLAdapter#execute_and_clear(sql,name,binds)",
// "ActiveSupport::Dependencies::Loadable#require(path)",
// "ActiveRecord::ConnectionAdapters::QueryCache#clear_query_cache",
// "ActiveRecord::ConnectionAdapters::SchemaCache#initialize",
// "ActiveRecord::ConnectionAdapters::SchemaCache#clear!",
// "ActiveRecord::ConnectionAdapters::SchemaCache#clear_table_cache!",
}

func rubyEmitterStarter(runnerAssetName string, policy ruby.SquashPolicy) emitterStarter {
	return func(
		srv *server.Server,
		passthroughConfig map[string](interface{}),
		workerEnvs []map[string]string,
		dir string,
		env map[string]string,
		seed int,
		files []string) (Emitter, error) {

		config := &ruby.ContextConfig{
			Dir:               dir,
			EnvVars:           env,
			Seed:              seed,
			Rubylib:           []string{"spec", "lib", "test"},
			RunnerAssetName:   runnerAssetName,
			TraceProbes:       rubyTraceProbes,
			SquashPolicy:      policy,
			PassthroughConfig: passthroughConfig,
		}

		ctx, err := ruby.StartContext(config, srv, workerEnvs, files)
		if err != nil {
			return nil, err
		}

		return ctx, nil
	}
}

var starters = map[string]emitterStarter{
	"rspec":               rubyEmitterStarter("ruby/rspec.rb", ruby.SquashByFile),
	"rspec-squashall":     rubyEmitterStarter("ruby/rspec.rb", ruby.SquashAll),
	"rspec-pendantic":     rubyEmitterStarter("ruby/rspec.rb", ruby.SquashNothing),
	"minitest":            rubyEmitterStarter("ruby/minitest.rb", ruby.SquashByFile),
	"minitest-squashall":  rubyEmitterStarter("ruby/minitest.rb", ruby.SquashAll),
	"minitest-pendantic":  rubyEmitterStarter("ruby/minitest.rb", ruby.SquashNothing),
	"test-unit":           rubyEmitterStarter("ruby/test-unit.rb", ruby.SquashByFile),
	"test-unit-squashall": rubyEmitterStarter("ruby/test-unit.rb", ruby.SquashAll),
	"test-unit-pendantic": rubyEmitterStarter("ruby/test-unit.rb", ruby.SquashNothing),
}

var defaultGlobs = map[string]string {
	"rspec": "spec/**/*spec.rb",
	"rspec-squashall": "spec/**/*spec.rb",
	"rspec-pendantic": "spec/**/*spec.rb",
	"minitest": "test/**/test*.rb",
	"minitest-squashall": "test/**/test*.rb",
	"minitest-pendantic": "test/**/test*.rb",
	"test-unit": "test/**/test*.rb",
	"test-unit-squashall": "test/**/test*.rb",
	"test-unit-pendantic": "test/**/test*.rb",
}

func DefaultGlob(name string) string {
{'fraction_non_alphanumeric': 0.15693860386879732, 'fraction_numerical': 0.000336417157275021, 'mean_word_length': 4.922310756972111, 'pattern_counts': {'":': 30, '<': 3, '<?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': '6580952', 'n_tokens_mistral': 2208, 'n_tokens_neox': 2039, 'n_words': 347}