Skip to content

Commit

Permalink
Allow log paths to be configured for CI runs. (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomthom authored Feb 10, 2023
1 parent c5f7c2b commit dabfc02
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/testup/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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

Expand All @@ -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)
}
Expand Down
46 changes: 44 additions & 2 deletions src/testup/app_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dabfc02

Please sign in to comment.