From dabfc0279bfbe4a5acc2d993a654fc3fd337d468 Mon Sep 17 00:00:00 2001 From: Thomas Thomassen Date: Fri, 10 Feb 2023 06:31:01 -0700 Subject: [PATCH] Allow log paths to be configured for CI runs. (#208) --- README.md | 8 +++++++ src/testup/app.rb | 7 ++++++- src/testup/app_files.rb | 46 +++++++++++++++++++++++++++++++++++++++-- 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c683a4e..3b136f1 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,14 @@ Seed: 123 # The seed number for the random order of execution of the tests # file. Output: C:\Users\Thomas\SourceTree\TestUp2\tests\results.json +# Optional: +# Overriding where the .log files from a test run will be saved. +LogPath: C:\Users\Thomas\SourceTree\TestUp2\logs + +# Optional: +# Overriding where the .run files from a test run will be saved. +SavedRunsPath: C:\Users\Thomas\SourceTree\TestUp2\logs + # Optional: # Set to true to prevent SketchUp from closing. Useful for debugging purposes. # Note that if `Output` is used the results won't be written until SketchUp is diff --git a/src/testup/app.rb b/src/testup/app.rb index 8195f8b..78f13b8 100644 --- a/src/testup/app.rb +++ b/src/testup/app.rb @@ -8,12 +8,15 @@ require 'yaml' require 'testup/api' +require 'testup/app_files' require 'testup/arguments_parser' require 'testup/defer' module TestUp module App + extend AppFiles + def self.process_arguments options = ArgumentsParser.parse.arguments return if options.empty? @@ -33,6 +36,8 @@ def self.ci_run(test_suite, config = {}) # @param [String] ci_config_path Path to the configuration file to run. def self.ci_run_with_config(ci_config_path) config = self.read_config_file(ci_config_path) + self.log_path = config['LogPath'] if config.key?('LogPath') + self.saved_runs_path = config['SavedRunsPath'] if config.key?('SavedRunsPath') self.ci_run(config['Path'], config) end @@ -41,7 +46,7 @@ def self.read_config_file(ci_config_path) config = YAML.load_file(ci_config_path) config_dir = File.dirname(ci_config_path) # Expand config variables. - ['Path', 'Output'].each { |key| + ['Path', 'Output', 'LogPath', 'SavedRunsPath'].each { |key| value = config[key] value.gsub!('%CONFIG_DIR%', config_dir) } diff --git a/src/testup/app_files.rb b/src/testup/app_files.rb index 12b9d1b..5f4dcbb 100644 --- a/src/testup/app_files.rb +++ b/src/testup/app_files.rb @@ -11,15 +11,57 @@ module TestUp module AppFiles + module Impl + + extend SystemFiles + + def self.log_path + @log_path ||= default_log_path + ensure_exist(@log_path) + end + + def self.log_path=(path) + @log_path = path + end + + + def self.saved_runs_path + @saved_runs_path ||= default_saved_runs_path + ensure_exist(saved_runs_path) + end + + def self.saved_runs_path=(path) + @saved_runs_path = path + end + + + def self.default_log_path + app_data(PLUGIN_NAME, 'Logs') + end + + def self.default_saved_runs_path + app_data(PLUGIN_NAME, 'Saved Runs') + end + + end include SystemFiles def log_path - ensure_exist(app_data(PLUGIN_NAME, 'Logs')) + Impl.log_path + end + + def log_path=(path) + Impl.log_path = path end + def saved_runs_path - ensure_exist(app_data(PLUGIN_NAME, 'Saved Runs')) + Impl.saved_runs_path + end + + def saved_runs_path=(path) + Impl.saved_runs_path = path end end # module