Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Launchable: test-spec: Remove launchable option and related formatter… #13708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions spec/mspec/lib/mspec/commands/mspec-run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ def options(argv = ARGV)
options.doc "\n When to perform it"
options.action_filters

options.doc "\n Launchable"
options.launchable

options.doc "\n Help!"
options.debug
options.version MSpec::VERSION
Expand Down
88 changes: 0 additions & 88 deletions spec/mspec/lib/mspec/runner/formatters/launchable.rb
Original file line number Diff line number Diff line change
@@ -1,88 +0,0 @@
module LaunchableFormatter
def self.extend_object(obj)
super
obj.init
end

def self.setDir(dir)
@@path = File.join(dir, "#{rand.to_s}.json")
self
end

def init
@timer = nil
@tests = []
end

def before(state = nil)
super
@timer = TimerAction.new
@timer.start
end

def after(state = nil)
super
@timer.finish
file = MSpec.file
return if file.nil? || state&.example.nil? || exception?

@tests << {:test => state, :file => file, :exception => false, duration: @timer.elapsed}
end

def exception(exception)
super
@timer.finish
file = MSpec.file
return if file.nil?

@tests << {:test => exception, :file => file, :exception => true, duration: @timer.elapsed}
end

def finish
super

require_relative '../../../../../../tool/lib/launchable'

@writer = writer = Launchable::JsonStreamWriter.new(@@path)
@writer.write_array('testCases')
at_exit {
@writer.close
}

repo_path = File.expand_path("#{__dir__}/../../../../../../")

@tests.each do |t|
testcase = t[:test].description
relative_path = t[:file].delete_prefix("#{repo_path}/")
# The test path is a URL-encoded representation.
# https://github.com/launchableinc/cli/blob/v1.81.0/launchable/testpath.py#L18
test_path = {file: relative_path, testcase: testcase}.map{|key, val|
"#{encode_test_path_component(key)}=#{encode_test_path_component(val)}"
}.join('#')

status = 'TEST_PASSED'
if t[:exception]
message = t[:test].message
backtrace = t[:test].backtrace
e = "#{message}\n#{backtrace}"
status = 'TEST_FAILED'
end

@writer.write_object(
{
testPath: test_path,
status: status,
duration: t[:duration],
createdAt: Time.now.to_s,
stderr: e,
stdout: nil
}
)
end
end

private
def encode_test_path_component component
component.to_s.gsub('%', '%25').gsub('=', '%3D').gsub('#', '%23').gsub('&', '%26').tr("\x00-\x08", "")
end
end
9 changes: 0 additions & 9 deletions spec/mspec/lib/mspec/utils/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -489,14 +489,6 @@ def debug
end
end

def launchable
on("--launchable-test-reports", "DIR",
"DIR The directory for reporting test results in Launchable JSON format") do |o|
require 'mspec/runner/formatters/launchable'
config[:launchable] = LaunchableFormatter.setDir(o)
end
end

def all
configure {}
env
Expand All @@ -516,6 +508,5 @@ def all
action_filters
actions
debug
launchable
end
end
4 changes: 0 additions & 4 deletions spec/mspec/lib/mspec/utils/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@ def config_formatter
config[:formatter] = config[:formatter].new(config[:output])
end

if config[:launchable]
config[:formatter].extend config[:launchable]
end

config[:formatter]
end

Expand Down
Loading