lib/startup_time/registry.rb in startup-time-1.1.1 vs lib/startup_time/registry.rb in startup-time-1.2.0
- old
+ new
@@ -2,11 +2,10 @@
require 'active_support'
require 'active_support/core_ext/hash/indifferent_access'
require 'active_support/core_ext/hash/slice' # XXX in core since 2.5
require 'set'
-require 'shellwords'
require 'yaml'
module StartupTime
# StartupTime::Registry - an interface to the tests configured in
# resources/tests.yaml
@@ -33,13 +32,19 @@
abort "invalid test spec (#{id}): group ID (#{group}) conflicts with test ID" if TESTS[group]
GROUPS[group] << id
end
end
- # returns a hash which maps test-ID keys (e.g. "scala") to their
- # corresponding group names (e.g. "compiled, jvm, slow")
- def self.ids_to_groups
- TESTS.entries.map { |id, test| [id, test[:groups].sort.join(', ')] }
+ # a hash which maps test IDs (e.g. "scala") to their corresponding group
+ # names (e.g. ["compiled", "jvm", "slow"])
+ def self.ids_to_groups(format: :ascii)
+ if format == :json
+ TESTS.entries.each_with_object({}) do |(id, test), target|
+ target[id] = test[:groups].sort
+ end
+ else # ASCII
+ TESTS.entries.map { |id, test| [id, test[:groups].sort.join(', ')] }
+ end
end
def initialize
@omit = Set.new
@only = Set.new