Class: Scan::ErrorHandler

Inherits:
Object
  • Object
show all
Defined in:
scan/lib/scan/error_handler.rb

Overview

This classes methods are called when something goes wrong in the building process

Class Method Summary collapse

Class Method Details

.handle_build_error(output, log_path) ⇒ Object

This method should raise an exception in any case, as the return code indicated a failed build

Parameters:

  • The (String)

    output of the errored build



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
# File 'scan/lib/scan/error_handler.rb', line 9

def handle_build_error(output, log_path)
  # The order of the handling below is important

  instruction = 'See the log'
  location = Scan.config[:suppress_xcode_output] ? "here: '#{log_path}'" : "above"
  details = "#{instruction} #{location}."

  case output
  when /US\-ASCII/
    print("Your shell environment is not correctly configured")
    print("Instead of UTF-8 your shell uses US-ASCII")
    print("Please add the following to your '~/.bashrc':")
    print("")
    print("       export LANG=en_US.UTF-8")
    print("       export LANGUAGE=en_US.UTF-8")
    print("       export LC_ALL=en_US.UTF-8")
    print("")
    print("You'll have to restart your shell session after updating the file.")
    print("If you are using zshell or another shell, make sure to edit the correct bash file.")
    print("For more information visit this stackoverflow answer:")
    print("https://stackoverflow.com/a/17031697/445598")
  when /Testing failed on/
    # This is important because xcbeautify and raw output will print:
    # Testing failed on 'iPhone 13 Pro Max'
    # when multiple devices are use.
    # xcpretty hides this output so its not an issue with xcpretty.
    # We need to catch "Testing failed on" before "Test failed"
    # so that an error isn't raised.
    # Raising an error prevents trainer from processing the xcresult
    return
  when /Testing failed/
    UI.build_failure!("Error building the application. #{details}")
  when /Executed/, /Failing tests:/
    # this is *really* important:
    # we don't want to raise an exception here
    # as we handle this in runner.rb at a later point
    # after parsing the actual test results
    # ------------------------------------------------
    # For the "Failing tests:" case, this covers Xcode
    # 10 parallel testing failure, which doesn't
    # print out the "Executed" line that would show
    # test summary (number of tests passed, etc.).
    # Instead, it just prints "Failing tests:"
    # followed by a list of tests that failed.
    return
  end
  UI.build_failure!("Error building/testing the application. #{details}")
end