Module: UE4TestRunner

Defined in:
lib/runner.rb

Constant Summary collapse

UE4_ROOT =
"D:\\UE_4.26"
EXECUTABLE_LOCATION =
"\\Engine\\Binaries\\Win64\\UE4Editor-Cmd.exe"
FLAGS =
'-unattended -silent -nopause -NullRHI -testexit="Automation Test Queue Empty" -log -log=RunTests.log'
MISSING_FILE_ERROR_MESSAGE =
"File does not exists D:"
MISSING_PROJECT_FILE_ERROR_MESSAGE =
"uproject file does not exists D: make sure you're in the ue4 project root directory"
TEST_RESULT_DIR =
'TestResult'

Instance Method Summary collapse

Instance Method Details

#build_commandObject



29
30
31
# File 'lib/runner.rb', line 29

def build_command
  "#{UE4_ROOT}#{EXECUTABLE_LOCATION} #{project_file_path} #{FLAGS} #{tests_command} #{report_outputh_path}"
end

#current_directoryObject



51
52
53
# File 'lib/runner.rb', line 51

def current_directory
  File.expand_path(File.dirname(__FILE__))
end

#project_file_pathObject



33
34
35
36
37
# File 'lib/runner.rb', line 33

def project_file_path
  file = Dir.entries(".").select {|file_name| file_name.include?('.uproject')}.first
  raise MISSING_PROJECT_FILE_ERROR_MESSAGE if file.nil?
  File.expand_path(file, File.dirname(file))
end

#report_outputh_pathObject



47
48
49
# File 'lib/runner.rb', line 47

def report_outputh_path
  "-ReportOutputPath=\"#{current_directory}\\#{TEST_RESULT_DIR}\""
end

#runObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/runner.rb', line 12

def run
  begin
      puts "Running tests..."
      system(build_command, :out => File::NULL)
      file_name = "#{current_directory}\\#{TEST_RESULT_DIR}\\index.json"

      puts "#{file_name}: #{MISSING_FILE_ERROR_MESSAGE}" and return unless File.file?(file_name)

      tests = Parser::parse(file_name)
      tests.each {|test| puts test.pretty}

      FileUtils.rm_rf("#{current_directory}#{TEST_RESULT_DIR}")
  rescue RuntimeError => error
      puts error
  end
end

#tests_commandObject



39
40
41
# File 'lib/runner.rb', line 39

def tests_command
  "-ExecCmds=\"Automation RunTests #{tests_to_run}\""
end

#tests_to_runObject



43
44
45
# File 'lib/runner.rb', line 43

def tests_to_run
  ARGV[0]
end