Class: Pinspec::Runner::Capture
- Inherits:
-
Object
- Object
- Pinspec::Runner::Capture
- Defined in:
- lib/pinspec/runner/capture.rb
Defined Under Namespace
Classes: Result
Constant Summary collapse
- OUTPUT =
"observations.json"
Instance Method Summary collapse
-
#initialize(app_root:, target:, method:, max_cases: Inputs::Corpus::DEFAULT_MAX_CASES, boots: 2, compare_sql: false, sandbox_env: {}, output_dir: nil, sample: false, sample_env: nil, redact: true) ⇒ Capture
constructor
A new instance of Capture.
- #probe_tz ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(app_root:, target:, method:, max_cases: Inputs::Corpus::DEFAULT_MAX_CASES, boots: 2, compare_sql: false, sandbox_env: {}, output_dir: nil, sample: false, sample_env: nil, redact: true) ⇒ Capture
Returns a new instance of Capture.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pinspec/runner/capture.rb', line 13 def initialize(app_root:, target:, method:, max_cases: Inputs::Corpus::DEFAULT_MAX_CASES, boots: 2, compare_sql: false, sandbox_env: {}, output_dir: nil, sample: false, sample_env: nil, redact: true) @app_root = app_root @target_file = target @method = method @max_cases = max_cases @boots = boots @compare_sql = compare_sql @sandbox_env = sandbox_env @output_dir = output_dir || File.join(app_root, Sandbox::PROBE_DIR) @sample = sample @sample_env = sample_env @redact = redact end |
Instance Method Details
#probe_tz ⇒ Object
61 62 63 |
# File 'lib/pinspec/runner/capture.rb', line 61 def probe_tz @sandbox_env["TZ"] || Sandbox::FORCED_ENV.fetch("TZ") end |
#run ⇒ Object
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 |
# File 'lib/pinspec/runner/capture.rb', line 29 def run target_profile = Analyzer::TargetParser.parse(@target_file, @method) app_profile = Analyzer::AppProfileReader.read(@app_root) plan = Setup::ContextBuilder.build(target: target_profile, profile: app_profile, tz: probe_tz) imports = @sample ? sample_imports(plan, app_profile, target_profile) : [] if imports.any? plan = Setup::ContextBuilder.build(target: target_profile, profile: app_profile, imports: imports, tz: probe_tz) end corpus = Inputs::Corpus.build( target: target_profile, plan: plan, schema: app_profile.schema, max_cases: @max_cases ) probe = ProbeGenerator.generate( plan: plan, corpus: corpus, fk_map: app_profile.schema.fk_map, target: target_profile ) runs = Sandbox.new(app_root: @app_root, probe_source: probe, env: @sandbox_env) .capture(boots: @boots) stability = Emit::StabilityFilter.new(compare_sql: @compare_sql).filter(runs) Result.new( target: target_profile, plan: plan, corpus: corpus, runs: runs, stability: stability, probe_source: probe, output_path: write_observations(plan, runs, stability) ) end |