forked from ThrowTheSwitch/Ceedling
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_cfg.rb
More file actions
134 lines (99 loc) · 3.77 KB
/
app_cfg.rb
File metadata and controls
134 lines (99 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# =========================================================================
# Ceedling - Test-Centered Build System for C
# ThrowTheSwitch.org
# Copyright (c) 2010-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
# SPDX-License-Identifier: MIT
# =========================================================================
require "io/console"
# Create our global application configuration option set
# This approach bridges clean Ruby and Rake
class CeedlingAppConfig
def initialize()
# Default installation location determined from the location of this file
ceedling_root_path = File.join( File.dirname( __FILE__ ), '..' )
# Create internal hash of needed values
@app_cfg = {
# Base path of any Ceedling installation
:ceedling_root_path => '',
# Ceedling installation base path + /lib
:ceedling_lib_base_path => '',
# Ceedling installation base path + /lib/ceedling
:ceedling_lib_path => '',
# Ceedling installation base path + /plugins
:ceedling_plugins_path => '',
# Ceedling installation base path + /vendor
:ceedling_vendor_path => '',
# Ceedling installation base path + /examples
:ceedling_examples_path => '',
# Ceedling lib path + lib/ceedling/rakefile.rb
:ceedling_rakefile_filepath => '',
# Blank initial value for completeness
:project_config => {},
# Default path (in build directory) to hold logs
:logging_path => '',
# If logging enabled, the filepath for Ceedling's log (may be explicitly set to be outside :logging_path)
:log_filepath => '',
# Only specified in project config (no command line or environment variable)
:default_tasks => ['test:all'],
# Default, blank test case filters
:include_test_case => '',
:exclude_test_case => '',
# Default to task categry other than build/plugin tasks
:build_tasks? => false,
# Default to `exit(1)` upon failing test cases
:tests_graceful_fail? => false,
# Set terminal width (in columns) to a default
:terminal_width => 120,
}
set_paths( ceedling_root_path )
# Try to query terminal width (not always available on all platforms)
begin
@app_cfg[:terminal_width] = (IO.console.winsize)[1]
rescue
# Do nothing; allow value already set to stand as default
end
end
def set_project_config(config)
@app_cfg[:project_config] = config
end
def set_logging_path(path)
@app_cfg[:logging_path] = path
end
def set_log_filepath(filepath)
@app_cfg[:log_filepath] = filepath
end
def set_include_test_case(matcher)
@app_cfg[:include_test_case] = matcher
end
def set_exclude_test_case(matcher)
@app_cfg[:exclude_test_case] = matcher
end
def set_build_tasks(enable)
@app_cfg[:build_tasks?] = enable
end
def set_tests_graceful_fail(enable)
@app_cfg[:tests_graceful_fail?] = enable
end
def set_paths(root_path)
_root_path = File.expand_path( root_path )
lib_base_path = File.join( _root_path, 'lib' )
lib_path = File.join( lib_base_path, 'ceedling' )
@app_cfg[:ceedling_root_path] = _root_path
@app_cfg[:ceedling_lib_base_path] = lib_base_path
@app_cfg[:ceedling_lib_path] = lib_path
@app_cfg[:ceedling_vendor_path] = File.join( _root_path, 'vendor' )
@app_cfg[:ceedling_plugins_path] = File.join( _root_path, 'plugins' )
@app_cfg[:ceedling_examples_path] = File.join( _root_path, 'examples' )
@app_cfg[:ceedling_rakefile_filepath] = File.join( lib_path, 'rakefile.rb' )
end
def build_tasks?()
return @app_cfg[:build_tasks?]
end
def tests_graceful_fail?()
return @app_cfg[:tests_graceful_fail?]
end
# External accessor to preserve hash-like read accesses
def [](key)
return @app_cfg[key]
end
end