Skip to content

Commit

Permalink
Create unique result folder (#7016)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximenoel8 authored May 17, 2023
1 parent 6db7b5d commit cbe11a9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
13 changes: 8 additions & 5 deletions testsuite/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ require 'rake/task'
require 'parallel'

junit_results = '-f junit -o results_junit'
build_number = ENV['BUILD_NUMBER']
result_folder = build_number.nil? ? 'results' : "results/#{build_number}"

namespace :cucumber do
# Create results folder
sh "mkdir -p results", verbose: false
sh "mkdir -p #{result_folder}", verbose: false
Dir.glob(File.join(Dir.pwd, 'run_sets', '**', '*.yml')).each do |entry|
Cucumber::Rake::Task.new(File.basename(entry, '.yml').to_sym) do |t|
filename = File.basename(entry, '.yml').to_sym
timestamp = Time.now.strftime('%Y%m%d%H%M%S')
node_name = ENV['NODE']
node_result_extension = node_name.nil? ? '' : "_#{node_name}"
json_results = "-f json -o results/output#{node_result_extension}_#{timestamp}-#{filename}.json"
html_results = "-f html -o results/output#{node_result_extension}_#{timestamp}-#{filename}.html"
json_results = "-f json -o #{result_folder}/output#{node_result_extension}_#{timestamp}-#{filename}.json"
html_results = "-f html -o #{result_folder}/output#{node_result_extension}_#{timestamp}-#{filename}.html"
profiles = ENV['PROFILE']
# Our profiles include a --tags keyword in all of them, if we have multiple profiles in the list
# it will act as an intersection of tags, not as an union of them.
Expand Down Expand Up @@ -172,9 +174,10 @@ namespace :utils do
desc 'Generate test report'
task :generate_test_report do
sh 'rm -rf ./cucumber_report && mkdir cucumber_report', verbose: false
sh 'timeout 180 bash -c -- "while find results/output*.json -type f -size 0 | grep json; do sleep 10;done" ; exit 0', verbose: false
sh "timeout 180 bash -c -- \"while find #{result_folder}/output*.json -type f -size 0 | grep json; do sleep 10;done\" ; exit 0", verbose: false
sh 'find . -size 0 -delete', verbose: false
sh 'node index.js &> cucumber_reporter.log', verbose: false
sh 'node index.js #{result_folder} &> cucumber_reporter.log', verbose: false
sh "cp cucumber_report/cucumber_report.html #{result_folder}"
end
end

Expand Down
7 changes: 6 additions & 1 deletion testsuite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
*/

var reporter = require('cucumber-html-reporter');
var path = require('path');

// Read command-line arguments
var args = process.argv.slice(2);
var jsonDir = args[0] || '.'; // Default to current directory if no argument provided

var options = {
theme: 'bootstrap',
jsonDir: '.',
jsonDir: jsonDir,
output: 'cucumber_report/cucumber_report.html',
reportSuiteAsScenarios: true,
launchReport: true,
Expand Down

0 comments on commit cbe11a9

Please sign in to comment.