Skip to content

Commit

Permalink
ref: create rake namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
askonev committed Nov 23, 2023
1 parent 76a321d commit d515c5b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 26 deletions.
26 changes: 0 additions & 26 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

require 'csv'
require_relative 'lib/doc_builder_testing'
require_relative 'lib/coverage/test_coverage_result'

task default: %w[run_tests_on_desktop]

Expand All @@ -23,32 +22,7 @@ task :rspec_critical do
sh("parallel_rspec spec -o '--tag critical'")
end

desc 'Generate report with resource usage'
task :resource_usage_report do
results = []
files = Dir["#{Dir.pwd}/js/**/*.js"]
files.each do |file|
data = DocBuilderWrapper.new.build_file_with_usage_stats(file)
results << { file: file, memory: data.memory, time: data.user_time }
end
memory_sum = results.sum { |h| h[:memory] }
time_sum = results.sum { |h| h[:time] }
CSV.open('report.csv', 'w') do |csv|
csv << %w[File Memory Time]
results.each do |data_line|
csv << [data_line[:file], data_line[:memory], data_line[:time]]
end
csv << ['Total:', memory_sum, time_sum]
end
end

desc 'run rspec via windows'
task :run_test_on_win do
system('rspec --tag win')
end

desc 'run coverage'
task :coverage do
File.binwrite("#{Dir.pwd}/reports/coverage_result.json",
TestCoverageResult.new.run)
end
12 changes: 12 additions & 0 deletions rakelib/coverage.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

require 'rspec/core/rake_task'
require_relative '../lib/coverage/test_coverage_result'

namespace(:coverage) do
desc 'ApiBuilder coverage'
task :builder do
File.binwrite("#{Dir.pwd}/reports/coverage_result.json",
TestCoverageResult.new.run)
end
end
24 changes: 24 additions & 0 deletions rakelib/load.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

require 'rspec/core/rake_task'

namespace(:load) do
desc 'Generate report with resource usage'
task :resource_usage do
results = []
files = Dir["#{Dir.pwd}/js/**/*.js"]
files.each do |file|
data = DocBuilderWrapper.new.build_file_with_usage_stats(file)
results << { file: file, memory: data.memory, time: data.user_time }
end
memory_sum = results.sum { |h| h[:memory] }
time_sum = results.sum { |h| h[:time] }
CSV.open("#{Dir.pwd}/reports/load.csv", 'w') do |csv|
csv << %w[File Memory Time]
results.each do |data_line|
csv << [data_line[:file], data_line[:memory], data_line[:time]]
end
csv << ['Total:', memory_sum, time_sum]
end
end
end

0 comments on commit d515c5b

Please sign in to comment.