Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
mbj committed Feb 18, 2024
1 parent 35f3694 commit a6a8276
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 35 deletions.
32 changes: 1 addition & 31 deletions lib/mutant/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,7 @@ def cover_index(mutation_index)
end

def run_test_index(test_index)
test_result = nil

output = with_capture do
test_result = integration.call([integration.all_tests.fetch(test_index)])
end

Result::Test.new(
output: output,
passed: test_result.passed,
runtime: test_result.runtime
)
integration.call([integration.all_tests.fetch(test_index)])
end

def emit_mutation_worker_process_start(index:)
Expand Down Expand Up @@ -193,26 +183,6 @@ def run_mutation_tests(mutation, tests)
def timer
world.timer
end

# TODO: Move this to an isolation based capture.
# mutant:disable
def with_capture
stderr, stdout = world.stderr, world.stdout
original_stdout = stderr.dup
original_stderr = stderr.dup
world.tempfile.create('capture') do |io|
stdout.reopen(io)
stdout.sync = true
stderr.reopen(stdout)
yield
io.rewind
io.read
end
ensure
stdout.reopen(original_stdout)
stderr.reopen(original_stderr)
end

end # Env
# rubocop:enable Metrics/ClassLength
end # Mutant
1 change: 1 addition & 0 deletions lib/mutant/integration/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def call(tests)
@runner.configuration.start_time = world.time.now - @setup_elapsed
start = timer.now
passed = @runner.run_specs(@rspec_world.ordered_example_groups).equal?(EXIT_SUCCESS)
@runner.configuration.reset_reporter
Result::Test.new(
output: '',
passed: passed,
Expand Down
13 changes: 10 additions & 3 deletions lib/mutant/parallel/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Config
)
end

include Adamantium, Anima.new(:connection, :config, :pid)
include Adamantium, Anima.new(:connection, :output, :config, :pid)

def self.start(**attributes)
start_config(Config.new(**attributes))
Expand All @@ -32,18 +32,25 @@ def self.start_config(config)

request = Pipe.from_io(io)
response = Pipe.from_io(io)
output = Pipe.from_io(io)

pid = world.process.fork do
writer = output.to_writer

world.stdout.reopen(writer)
world.stderr.reopen(writer)

run_child(
config: config,
connection: Pipe::Connection.from_pipes(marshal: marshal, reader: request, writer: response)
)
end

new(
pid: pid,
config: config,
connection: Pipe::Connection.from_pipes(marshal: marshal, reader: response, writer: request)
connection: Pipe::Connection.from_pipes(marshal: marshal, reader: response, writer: request),
output: output.to_reader,
pid: pid
)
end
private_class_method :start_config
Expand Down
2 changes: 1 addition & 1 deletion scripts/devloop.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
while inotifywait lib/**/*.rb meta/**/*.rb spec/**/*.rb Gemfile Gemfile.shared mutant.gemspec; do
bundle exec mutant environment test run --fail-fast spec/unit \
bundle exec mutant environment test run -j 1 --fail-fast spec/unit \
&& bundle exec mutant run --since main --zombie -- 'Mutant*' \
&& bundle exec rubocop
done

0 comments on commit a6a8276

Please sign in to comment.