Class: XamarinTestCloud::Dsym

Inherits:
Object
  • Object
show all
Defined in:
lib/xamarin-test-cloud/dsym.rb

Overview

TODO validate dsym against the current application. github.com/xamarinhq/test-cloud-command-line/issues/91

TODO dsym-file can be relative to workspace github.com/xamarinhq/test-cloud-command-line/issues/92

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Dsym

Caller should rescue RuntimeError and re-raise.

Raises:

  • RuntimeError If the dSYM at path is invalid.



14
15
16
17
# File 'lib/xamarin-test-cloud/dsym.rb', line 14

def initialize(path)
  @path = path
  validate!
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'lib/xamarin-test-cloud/dsym.rb', line 10

def path
  @path
end

Instance Method Details

#dwarf_symbol_filesObject



94
95
96
97
98
99
100
101
# File 'lib/xamarin-test-cloud/dsym.rb', line 94

def dwarf_symbol_files
  @dwarf_symbol_files ||= begin
    base = File.join(path, "Contents", "Resources", "DWARF")
    Dir.entries(base).select do |entry|
      !(entry.end_with?('..') || entry.end_with?('.'))
    end.map { |entry| File.join(base, entry) }
  end
end

#inspectObject



23
24
25
# File 'lib/xamarin-test-cloud/dsym.rb', line 23

def inspect
  to_s
end

#remote_path(path_to_app) ⇒ Object



84
85
86
# File 'lib/xamarin-test-cloud/dsym.rb', line 84

def remote_path(path_to_app)
  "#{File.basename(path_to_app)}_dSym"
end

#symbol_fileObject



88
89
90
# File 'lib/xamarin-test-cloud/dsym.rb', line 88

def symbol_file
  File.expand_path(dwarf_symbol_files[0])
end

#to_sObject



19
20
21
# File 'lib/xamarin-test-cloud/dsym.rb', line 19

def to_s
  "#<DSYM #{@path}>"
end

#validate!Object



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
# File 'lib/xamarin-test-cloud/dsym.rb', line 27

def validate!
  extension = File.extname(path)

  if extension != ".dSYM"
    raise RuntimeError, %Q[Invalid dSYM directory.

The --dsym-file must have a dSYM extension.  Found:

#{path}
]
  end

  if !File.exist?(path)
    raise RuntimeError, %Q[Invalid dSYM directory.

The --dsym-file does not exist:

#{path}
]
  end

  if !File.directory?(path)
    raise RuntimeError, %Q[Invalid dSYM directory.

The --dsym-file is not a directory:

#{path}
]
  end

  if dwarf_symbol_files.count > 1
    raise RuntimeError, %Q[Invalid dSYM directory.

The --dsym-file contains more than one symbol file.

Check the contents of #{File.join("Contents", "Resources", "DWARF")} in:

#{path}
]
  end

  if dwarf_symbol_files.count < 1
    raise RuntimeError, %Q[Invalid dSYM directory.

The --dsym-file contains no symbol file.

Check the contents of #{File.join("Contents", "Resources", "DWARF")} in:

#{path}

    #{Dir.glob(File.join(path, "Contents", "Resources", "DWARF", "*" ))}
]
  end

  true
end