Skip to content

Commit

Permalink
Add filename as arguments of driver.rb (#16)
Browse files Browse the repository at this point in the history
add filename as arguments of driver.rb
  • Loading branch information
jhlee-mitre committed Jul 7, 2022
1 parent 1a0116b commit 65333f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
11 changes: 6 additions & 5 deletions lib/TestScriptEngine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_relative './TestScriptRunnable'

class TestScriptEngine
attr_accessor :endpoint, :directory_path
attr_accessor :endpoint, :directory_path, :file_name

def scripts
@scripts ||= {}
Expand All @@ -25,9 +25,10 @@ def client
@client ||= FHIR::Client.new(endpoint || 'localhost:3000')
end

def initialize(endpoint = nil, directory_path = nil)
def initialize(endpoint = nil, directory_path = nil, file_name = nil)
self.endpoint = endpoint
self.directory_path = directory_path
self.file_name = file_name
end

# TODO: Tie-in stronger validation. Possibly, Inferno validator.
Expand All @@ -37,9 +38,9 @@ def valid_testscript? script

# @path [String] Optional, specifies the path to the folder containing the
# TestScript Resources to-be loaded into the engine.
def load_scripts path = nil, file_name = nil
on_deck = Dir.glob "#{path || root}/**/*.{json, xml}"
FHIR.logger.info "[.load_scripts] TestScript Path: [#{path || root}]"
def load_scripts
on_deck = Dir.glob "#{root}/**/*.{json, xml}"
FHIR.logger.info "[.load_scripts] TestScript Path: [#{root}]"

on_deck.each do |resource|
next if file_name && !resource.include?(file_name)
Expand Down
13 changes: 7 additions & 6 deletions lib/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@
require './TestScriptRunnable' # TODO: Remove

test_server_url = 'http:https://hapi.fhir.org/baseR4'
testscript_path = nil
testscript_path = '../TestScripts'
testscript_file = nil

parameters = ARGV
parameters.each do |parameter|
if parameter.start_with?('http')
test_server_url = parameter
elsif parameter.include?('.json')
testscript_file = parameter
else
testscript_path = parameter
end
end

puts "SERVER: #{test_server_url}"
puts "TESTSCRIPTS: #{testscript_path}"
puts "TESTSCRIPT PATH: #{testscript_path}"
puts "TESTSCRIPT FILE: #{testscript_file}"

default_engine = TestScriptEngine.new(test_server_url, testscript_path)
# Load and execute all TestScript in /TestScripts
default_engine = TestScriptEngine.new(test_server_url, testscript_path, testscript_file)
default_engine.load_scripts
# Specify a TestScript to execute
# default_engine.load_scripts(nil, 'general_test_script.json')
default_engine.make_runnables
default_engine.execute_runnables
default_engine.write_reports
Expand Down

0 comments on commit 65333f0

Please sign in to comment.