testability-driver 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +1 -0
- data/bin/start_app_perf +199 -0
- data/bin/tdriver-devtools +3 -0
- data/config/sut_parameters.rb +39 -0
- data/ext/extconf.rb +67 -0
- data/ext/native_extensions.c +70 -0
- data/lib/matti.rb +30 -0
- data/lib/tdriver-devtools/behaviour/old/xml/example/flick-example.rb +223 -0
- data/lib/tdriver-devtools/behaviour/old/xml/example/impl.rb_invalid +194 -0
- data/lib/tdriver-devtools/behaviour/old/xml/generate_behaviour_xml.rb +95 -0
- data/lib/tdriver-devtools/behaviour/old/xml/lib/tdriver_generator.rb +722 -0
- data/lib/tdriver-devtools/behaviour/old/xml/qdoc_generator.rb +321 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.method.template +43 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.module.template +54 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument.template +7 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument_type.template +7 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.exception.template +5 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.line.template +2 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.template +5 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.method.template +23 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.template +14 -0
- data/lib/tdriver-devtools/behaviour/old/xml/update +3 -0
- data/lib/tdriver-devtools/behaviour/xml/generate.rb +88 -0
- data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +1924 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.default.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument_type.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.exception.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.arguments.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.deprecated.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.exceptions.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.info.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.returns.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.tables.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.template +12 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.returns.template +5 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.item.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.row.template +2 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.template +8 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.template +14 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/example/flick-example.rb +245 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/example/sut.rb +964 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/generate.rb +68 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/lib/custom_rdoc_generator.rb +1865 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.default.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument_type.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.exception.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.arguments.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.deprecated.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.exceptions.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.info.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.returns.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.tables.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.template +12 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.returns.template +5 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.item.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.row.template +2 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.template +7 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.template +14 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/update +3 -0
- data/lib/tdriver-devtools/doc/behaviour_xml/QtExampleGestureBehaviour.xml +138 -0
- data/lib/tdriver-devtools/doc/behaviour_xml/created.rid +1 -0
- data/lib/tdriver-devtools/doc/behaviour_xml/tdriver.hash +1 -0
- data/lib/tdriver-devtools/doc/feature_xml/qt_widget_hold.feature.xml +9 -0
- data/lib/tdriver-devtools/doc/feature_xml/qt_widget_tap.feature.xml +9 -0
- data/lib/tdriver-devtools/doc/generate.rb +892 -0
- data/lib/tdriver-devtools/doc/update +1 -0
- data/lib/tdriver-devtools/doc/xslt/html.rb +7 -0
- data/lib/tdriver-devtools/doc/xslt/template.xsl +1861 -0
- data/lib/tdriver-devtools/doc/xslt/update +3 -0
- data/lib/tdriver-devtools/plugin/placeholder.txt +1 -0
- data/lib/tdriver-devtools/tdriver-devtools.rb +404 -0
- data/lib/tdriver-devtools/tests/feature_tests/example/flick-example.rb +233 -0
- data/lib/tdriver-devtools/tests/feature_tests/example/impl.rb +194 -0
- data/lib/tdriver-devtools/tests/feature_tests/generate.rb +82 -0
- data/lib/tdriver-devtools/tests/feature_tests/lib/custom_rdoc_generator.rb +468 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/feature_attribute.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/feature_method.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_attribute.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_method.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/update +3 -0
- data/lib/tdriver.rb +26 -0
- data/lib/tdriver/base/behaviour/behaviour.rb +32 -0
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +94 -0
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +262 -0
- data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +111 -0
- data/lib/tdriver/base/behaviour/factory.rb +380 -0
- data/lib/tdriver/base/behaviour/loader.rb +28 -0
- data/lib/tdriver/base/command_data/command_data.rb +51 -0
- data/lib/tdriver/base/command_data/loader.rb +25 -0
- data/lib/tdriver/base/errors.rb +131 -0
- data/lib/tdriver/base/loader.rb +38 -0
- data/lib/tdriver/base/state_object.rb +270 -0
- data/lib/tdriver/base/sut/adapter.rb +28 -0
- data/lib/tdriver/base/sut/controller.rb +119 -0
- data/lib/tdriver/base/sut/factory.rb +287 -0
- data/lib/tdriver/base/sut/generic/behaviours/application.rb +243 -0
- data/lib/tdriver/base/sut/generic/behaviours/controller.rb +67 -0
- data/lib/tdriver/base/sut/generic/behaviours/find.rb +96 -0
- data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +346 -0
- data/lib/tdriver/base/sut/generic/behaviours/sut.rb +1268 -0
- data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +182 -0
- data/lib/tdriver/base/sut/generic/behaviours/verification.rb +119 -0
- data/lib/tdriver/base/sut/generic/commands/application.rb +219 -0
- data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +82 -0
- data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +58 -0
- data/lib/tdriver/base/sut/generic/plugin.rb +96 -0
- data/lib/tdriver/base/sut/loader.rb +35 -0
- data/lib/tdriver/base/sut/sut.rb +67 -0
- data/lib/tdriver/base/test_object/abstract.rb +179 -0
- data/lib/tdriver/base/test_object/behaviours/syncronization.rb +94 -0
- data/lib/tdriver/base/test_object/behaviours/test_object.rb +787 -0
- data/lib/tdriver/base/test_object/factory.rb +618 -0
- data/lib/tdriver/base/test_object/identificator.rb +511 -0
- data/lib/tdriver/base/test_object/loader.rb +37 -0
- data/lib/tdriver/env.rb +21 -0
- data/lib/tdriver/loader.rb +36 -0
- data/lib/tdriver/matti.rb +35 -0
- data/lib/tdriver/report/error_recovery/tdriver_custom_error_recovery.rb +83 -0
- data/lib/tdriver/report/error_recovery/tdriver_error_recovery.rb +158 -0
- data/lib/tdriver/report/error_recovery/tdriver_error_recovery_settings.rb +98 -0
- data/lib/tdriver/report/report.rb +47 -0
- data/lib/tdriver/report/report_api.rb +207 -0
- data/lib/tdriver/report/report_combine.rb +86 -0
- data/lib/tdriver/report/report_crash_file_capture.rb +167 -0
- data/lib/tdriver/report/report_creator.rb +571 -0
- data/lib/tdriver/report/report_cucumber.rb +158 -0
- data/lib/tdriver/report/report_cucumber_listener.rb +337 -0
- data/lib/tdriver/report/report_cucumber_reporter.rb +335 -0
- data/lib/tdriver/report/report_data_presentation.rb +152 -0
- data/lib/tdriver/report/report_data_table.rb +64 -0
- data/lib/tdriver/report/report_execution_statistics.rb +284 -0
- data/lib/tdriver/report/report_file_capture.rb +159 -0
- data/lib/tdriver/report/report_grouping.rb +539 -0
- data/lib/tdriver/report/report_junit_xml.rb +147 -0
- data/lib/tdriver/report/report_rspec.rb +108 -0
- data/lib/tdriver/report/report_test_case_run.rb +621 -0
- data/lib/tdriver/report/report_test_run.rb +1286 -0
- data/lib/tdriver/report/report_test_unit.rb +175 -0
- data/lib/tdriver/report/report_writer.rb +1405 -0
- data/lib/tdriver/tdriver.rb +158 -0
- data/lib/tdriver/util/common.rb +24 -0
- data/lib/tdriver/util/common/array.rb +39 -0
- data/lib/tdriver/util/common/crc16.rb +100 -0
- data/lib/tdriver/util/common/environment.rb +153 -0
- data/lib/tdriver/util/common/error.rb +39 -0
- data/lib/tdriver/util/common/file.rb +315 -0
- data/lib/tdriver/util/common/gem.rb +108 -0
- data/lib/tdriver/util/common/kernel.rb +189 -0
- data/lib/tdriver/util/common/loader.rb +39 -0
- data/lib/tdriver/util/common/retryable.rb +98 -0
- data/lib/tdriver/util/common/string.rb +77 -0
- data/lib/tdriver/util/dbaccess/dbaccess.rb +188 -0
- data/lib/tdriver/util/dbaccess/dbconnection.rb +41 -0
- data/lib/tdriver/util/dbaccess/error.rb +35 -0
- data/lib/tdriver/util/dbaccess/loader.rb +29 -0
- data/lib/tdriver/util/dynamic_attribute_filter.rb +182 -0
- data/lib/tdriver/util/hooking.rb +434 -0
- data/lib/tdriver/util/loader.rb +65 -0
- data/lib/tdriver/util/localisation.rb +24 -0
- data/lib/tdriver/util/localisation/error.rb +32 -0
- data/lib/tdriver/util/localisation/loader.rb +28 -0
- data/lib/tdriver/util/localisation/localisation.rb +479 -0
- data/lib/tdriver/util/logger.rb +377 -0
- data/lib/tdriver/util/operator_data/error.rb +29 -0
- data/lib/tdriver/util/operator_data/loader.rb +26 -0
- data/lib/tdriver/util/operator_data/operator_data.rb +93 -0
- data/lib/tdriver/util/other/config.rb +221 -0
- data/lib/tdriver/util/parameter.rb +24 -0
- data/lib/tdriver/util/parameter/error.rb +45 -0
- data/lib/tdriver/util/parameter/loader.rb +37 -0
- data/lib/tdriver/util/parameter/parameter.rb +285 -0
- data/lib/tdriver/util/parameter/parameter_hash.rb +101 -0
- data/lib/tdriver/util/parameter/parameter_template.rb +120 -0
- data/lib/tdriver/util/parameter/parameter_user_api.rb +84 -0
- data/lib/tdriver/util/parameter/parameter_xml.rb +247 -0
- data/lib/tdriver/util/plugin/abstract.rb +60 -0
- data/lib/tdriver/util/plugin/error.rb +25 -0
- data/lib/tdriver/util/plugin/loader.rb +28 -0
- data/lib/tdriver/util/plugin/service.rb +200 -0
- data/lib/tdriver/util/recorder.rb +292 -0
- data/lib/tdriver/util/stats.rb +90 -0
- data/lib/tdriver/util/user_data/error.rb +29 -0
- data/lib/tdriver/util/user_data/loader.rb +26 -0
- data/lib/tdriver/util/user_data/user_data.rb +103 -0
- data/lib/tdriver/util/video_rec.rb +264 -0
- data/lib/tdriver/util/xml/abstraction.rb +47 -0
- data/lib/tdriver/util/xml/builder.rb +54 -0
- data/lib/tdriver/util/xml/document.rb +32 -0
- data/lib/tdriver/util/xml/element.rb +32 -0
- data/lib/tdriver/util/xml/error.rb +46 -0
- data/lib/tdriver/util/xml/loader.rb +46 -0
- data/lib/tdriver/util/xml/nil_element.rb +89 -0
- data/lib/tdriver/util/xml/nodeset.rb +32 -0
- data/lib/tdriver/util/xml/parsers/libxml/libxml.rb +140 -0
- data/lib/tdriver/util/xml/parsers/loader.rb +22 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +111 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +54 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/builder.rb +58 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +58 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +147 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +42 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +187 -0
- data/lib/tdriver/util/xml/xml.rb +170 -0
- data/lib/tdriver/verify/verify.rb +687 -0
- data/lib/tdriver/verify/verify.rb_org +630 -0
- data/lib/tdriver/version.rb +21 -0
- data/xml/behaviours/generic.xml +495 -0
- data/xml/defaults/generic.xml +97 -0
- data/xml/defaults/sut_generic.xml +36 -0
- data/xml/parameters/tdriver_parameters.xml +23 -0
- data/xml/templates/generic.xml +227 -0
- metadata +327 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
############################################################################
|
|
2
|
+
##
|
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
4
|
+
## All rights reserved.
|
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
|
6
|
+
##
|
|
7
|
+
## This file is part of Testability Driver.
|
|
8
|
+
##
|
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
|
11
|
+
##
|
|
12
|
+
## This library is free software; you can redistribute it and/or
|
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
|
16
|
+
## of this file.
|
|
17
|
+
##
|
|
18
|
+
############################################################################
|
|
19
|
+
|
|
20
|
+
module MobyUtil
|
|
21
|
+
|
|
22
|
+
# template for custom error classes
|
|
23
|
+
class CustomError < StandardError
|
|
24
|
+
|
|
25
|
+
def initialize ( msg = nil )
|
|
26
|
+
|
|
27
|
+
super( msg )
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class EmptyFilenameError < MobyUtil::CustomError; end
|
|
34
|
+
|
|
35
|
+
class FileNotFoundError < MobyUtil::CustomError; end
|
|
36
|
+
|
|
37
|
+
class UnexpectedVariableTypeError < MobyUtil::CustomError; end
|
|
38
|
+
|
|
39
|
+
end # MobyUtil
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
############################################################################
|
|
2
|
+
##
|
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
4
|
+
## All rights reserved.
|
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
|
6
|
+
##
|
|
7
|
+
## This file is part of Testability Driver.
|
|
8
|
+
##
|
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
|
11
|
+
##
|
|
12
|
+
## This library is free software; you can redistribute it and/or
|
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
|
16
|
+
## of this file.
|
|
17
|
+
##
|
|
18
|
+
############################################################################
|
|
19
|
+
|
|
20
|
+
require 'ftools'
|
|
21
|
+
|
|
22
|
+
module MobyUtil
|
|
23
|
+
|
|
24
|
+
class FileHelper
|
|
25
|
+
|
|
26
|
+
# Function to verify that given folder exists
|
|
27
|
+
# == params
|
|
28
|
+
# path:: String containing path
|
|
29
|
+
# == returns
|
|
30
|
+
def self.folder_exist?( path )
|
|
31
|
+
|
|
32
|
+
begin
|
|
33
|
+
|
|
34
|
+
Dir.entries( path ).kind_of?( Array )
|
|
35
|
+
|
|
36
|
+
rescue
|
|
37
|
+
|
|
38
|
+
false
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Function to load dynamically ruby module(s) from given path
|
|
45
|
+
# == params
|
|
46
|
+
# path:: String containing path
|
|
47
|
+
# == returns
|
|
48
|
+
def self.load_modules( *path )
|
|
49
|
+
|
|
50
|
+
# deterimine caller methods working folder
|
|
51
|
+
source_path = File.dirname( MobyUtil::KernelHelper.parse_caller( caller(3).first ).first )
|
|
52
|
+
|
|
53
|
+
path.each{ | path |
|
|
54
|
+
|
|
55
|
+
# expand path if given path is relative path
|
|
56
|
+
path = File.join( source_path, path ) if is_relative_path? path
|
|
57
|
+
|
|
58
|
+
# automatically load ruby implementation files if given path is folder
|
|
59
|
+
path = File.join( path, '*.rb' ) if File.directory?( path )
|
|
60
|
+
|
|
61
|
+
require_files = Dir.glob( MobyUtil::FileHelper.fix_path( path ) )
|
|
62
|
+
|
|
63
|
+
Kernel::raise ArgumentError.new( "File not found %s" % [ path ] ) if !File.directory?( path ) && !File.file?( path ) && require_files.empty?
|
|
64
|
+
|
|
65
|
+
# load each module found from given folder
|
|
66
|
+
require_files.each { | module_name |
|
|
67
|
+
|
|
68
|
+
# load implementation file
|
|
69
|
+
require module_name
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Function to fix folder/file path, e.g. remove duplicate back-/slashes
|
|
78
|
+
# == params
|
|
79
|
+
# logger_instance:: Instance of TDriver logger
|
|
80
|
+
# == returns
|
|
81
|
+
# String:: String presentation of fixed path
|
|
82
|
+
def self.fix_path( path )
|
|
83
|
+
|
|
84
|
+
Kernel::raise ArgumentError.new( "Invalid argument format %s (Expected: %s)" % [ path.class, "String" ] ) unless path.kind_of?( String )
|
|
85
|
+
|
|
86
|
+
# replace back-/slashes to File::SEPARATOR
|
|
87
|
+
path.gsub( /[\\\/]/, File::SEPARATOR ).to_s
|
|
88
|
+
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Private helper function to set tdriver_home directory depending on os.
|
|
92
|
+
# Known possible issue: javaruby or similar, will not return correctly
|
|
93
|
+
# == params
|
|
94
|
+
# == returns
|
|
95
|
+
# String:: String presentation of TDriver home directory
|
|
96
|
+
def self.tdriver_home()
|
|
97
|
+
|
|
98
|
+
File.expand_path(
|
|
99
|
+
MobyUtil::FileHelper.fix_path(
|
|
100
|
+
ENV['TDRIVER_HOME'] || ( MobyUtil::EnvironmentHelper.windows? ? "c:/tdriver" : "/etc/tdriver" )
|
|
101
|
+
)
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Function for expand tdriver specific relative file paths
|
|
107
|
+
# === params
|
|
108
|
+
# file_path:: String containing (file-) path
|
|
109
|
+
# === returns
|
|
110
|
+
# String:: String containing expanded file path
|
|
111
|
+
# === raises
|
|
112
|
+
# ArgumentError:: Unexpected argument type '%s' for path (Expected: %s)
|
|
113
|
+
# ArgumentError:: Given path is empty
|
|
114
|
+
def self.is_relative_path?( path )
|
|
115
|
+
|
|
116
|
+
Kernel::raise ArgumentError.new("Unexpected argument type '%s' for path (Expected: %s)" % [ path.class, 'String' ] ) unless path.kind_of?( String )
|
|
117
|
+
Kernel::raise ArgumentError.new("Given path is empty") if path.empty?
|
|
118
|
+
|
|
119
|
+
dirname = File.dirname( path )
|
|
120
|
+
|
|
121
|
+
if MobyUtil::EnvironmentHelper.windows?
|
|
122
|
+
|
|
123
|
+
# windows
|
|
124
|
+
( dirname =~ /^[a-z]+:(\\|\/)/i ).nil? && ( dirname[ 0 ].chr =~ /(\\|\/)/ ).nil?
|
|
125
|
+
|
|
126
|
+
else
|
|
127
|
+
|
|
128
|
+
# linux
|
|
129
|
+
( path[ 0 ].chr != '~' ) && ( dirname[ 0 ].chr != File::SEPARATOR )
|
|
130
|
+
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Function for expand tdriver specific relative file paths
|
|
136
|
+
# === params
|
|
137
|
+
# file_path:: String containing (file-) path
|
|
138
|
+
# === returns
|
|
139
|
+
# String:: String containing expanded file path
|
|
140
|
+
# === raises
|
|
141
|
+
def self.expand_path( file_path )
|
|
142
|
+
|
|
143
|
+
_file_path = file_path # we don't want to modify original variable
|
|
144
|
+
|
|
145
|
+
return _file_path if _file_path.nil? || _file_path.empty?
|
|
146
|
+
|
|
147
|
+
_file_path = MobyUtil::FileHelper.fix_path( _file_path )
|
|
148
|
+
|
|
149
|
+
MobyUtil::FileHelper.is_relative_path?( _file_path ) ? File.join( MobyUtil::FileHelper.tdriver_home, _file_path ) : _file_path
|
|
150
|
+
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Function for retrieve tdriver configuration file content from absolute or tdrive home path
|
|
154
|
+
# If relative path given, assume that file is located in TDriver home folder
|
|
155
|
+
# === params
|
|
156
|
+
# file_path:: String containing the name and path of file
|
|
157
|
+
# === returns
|
|
158
|
+
# String:: File content
|
|
159
|
+
# === raises
|
|
160
|
+
# ParameterFileNotFoundError - if empty parameter or file doesn't exist
|
|
161
|
+
# ParameterFileParseError:: If parsing failes
|
|
162
|
+
def self.get_file( file_path )
|
|
163
|
+
|
|
164
|
+
# raise exception if file name is empty or nil
|
|
165
|
+
Kernel::raise EmptyFilenameError.new( "File name is empty or not defined" ) if file_path.nil? || file_path.to_s.empty?
|
|
166
|
+
|
|
167
|
+
# raise exception if file name is file_path variable format other than string
|
|
168
|
+
Kernel::raise UnexpectedVariableTypeError.new( "Invalid filename format %s (Expected: %s)" % [ file_path.class, "String"] ) if !file_path.kind_of?( String )
|
|
169
|
+
|
|
170
|
+
file_path = MobyUtil::FileHelper.expand_path( file_path )
|
|
171
|
+
|
|
172
|
+
# raise exception if file not found
|
|
173
|
+
Kernel::raise FileNotFoundError.new( "File not found: #{ file_path }" ) unless File.exist?( file_path )
|
|
174
|
+
|
|
175
|
+
begin
|
|
176
|
+
# read all content of file
|
|
177
|
+
file_content = IO.read( file_path )
|
|
178
|
+
rescue => ex
|
|
179
|
+
# raise exception if error occured during reading the file
|
|
180
|
+
Kernel::raise IOError.new("Error occured while reading file #{ file_path }\nDescription: #{ ex.message }")
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# return file content
|
|
184
|
+
file_content
|
|
185
|
+
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# Function for create (nested) folder path
|
|
189
|
+
# === params
|
|
190
|
+
# path:: String containing path to be created
|
|
191
|
+
# === returns
|
|
192
|
+
# NilClass
|
|
193
|
+
# === raises
|
|
194
|
+
# IOError:: Error occured while creating folder
|
|
195
|
+
def self.mkdir_path( path )
|
|
196
|
+
|
|
197
|
+
begin
|
|
198
|
+
|
|
199
|
+
current_path = ""
|
|
200
|
+
|
|
201
|
+
path.split( File::SEPARATOR ).each{ | folder |
|
|
202
|
+
|
|
203
|
+
if !folder.empty?
|
|
204
|
+
|
|
205
|
+
current_path << folder << File::SEPARATOR
|
|
206
|
+
|
|
207
|
+
Dir.mkdir( current_path ) unless File.exist?( current_path )
|
|
208
|
+
|
|
209
|
+
else
|
|
210
|
+
|
|
211
|
+
current_path << File::SEPARATOR
|
|
212
|
+
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
} unless File.directory?( path ) && File.exist?( path )
|
|
216
|
+
|
|
217
|
+
rescue => exception
|
|
218
|
+
|
|
219
|
+
Kernel::raise IOError.new("Error occured while creating folder #{ current_path } (#{ exception.message })")
|
|
220
|
+
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
nil
|
|
224
|
+
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
# Function for copy file(s) to destination folder, folder will be created if it doesn't exist.
|
|
228
|
+
# === params
|
|
229
|
+
# source:: Array or String containing source filename(s)
|
|
230
|
+
# destination:: String containing of destination folder
|
|
231
|
+
# args:: String containing arguments used for copying
|
|
232
|
+
# file:: String target filename, used to rename source filename on destination
|
|
233
|
+
# === returns
|
|
234
|
+
# NilClass
|
|
235
|
+
# === raises
|
|
236
|
+
# IOError:: Error occured while creating folder
|
|
237
|
+
def self.copy_file( source, destination, verbose = false, overwrite = true, create_folders = true, &block )
|
|
238
|
+
|
|
239
|
+
Kernel::raise ArgumentError.new( "Source and destination argument must be type of String" ) unless source.kind_of?( String ) && destination.kind_of?( String )
|
|
240
|
+
|
|
241
|
+
sources = []
|
|
242
|
+
|
|
243
|
+
if File.directory?( source )
|
|
244
|
+
|
|
245
|
+
source_folders = source if ( source_folders = MobyUtil::FileHelper.folder_tree( source ) ).empty?
|
|
246
|
+
|
|
247
|
+
source_folders.each{ | folder |
|
|
248
|
+
|
|
249
|
+
Dir.glob( File.join( folder, "*.*" ) ).each{ | file |
|
|
250
|
+
|
|
251
|
+
sources << [ file, File.join( destination, folder.gsub( source, "" ), "/", File.basename( file ) ) ]
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
else
|
|
256
|
+
|
|
257
|
+
if File.basename( source ) =~ /\*/
|
|
258
|
+
# retrieve all files when wildcards used
|
|
259
|
+
Dir.glob( File.join( File.dirname( source ), File.basename( source ) ) ).each{ | file | sources << [ file, File.join( destination, File.basename( file ) ) ] }
|
|
260
|
+
else
|
|
261
|
+
# no wildcards
|
|
262
|
+
sources << [ source, destination ]
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
sources.each{ | task |
|
|
268
|
+
|
|
269
|
+
source, destination = task
|
|
270
|
+
|
|
271
|
+
destination_folder = ( destination = MobyUtil::FileHelper.fix_path( destination ) )[ -1 ].chr =~ /[\\\/]/ ? destination : File.dirname( destination )
|
|
272
|
+
|
|
273
|
+
# create destination folder if it doesn't exist and create_folders flag is enabled
|
|
274
|
+
MobyUtil::FileHelper.mkdir_path( destination_folder ) if create_folders
|
|
275
|
+
|
|
276
|
+
Kernel::raise RuntimeError.new( "Source file does not exist (#{ source })" ) unless File.exist?( source )
|
|
277
|
+
|
|
278
|
+
File.copy(
|
|
279
|
+
|
|
280
|
+
MobyUtil::FileHelper.fix_path( source ),
|
|
281
|
+
destination,
|
|
282
|
+
verbose
|
|
283
|
+
|
|
284
|
+
) unless ( !overwrite && File.exist?( destination ) )
|
|
285
|
+
|
|
286
|
+
# yield given block, can be used eg. changing the target file's access levels etc.
|
|
287
|
+
yield( destination, source, destination_folder ) if block_given?
|
|
288
|
+
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
# Function for build list of sub-/folder(s) from given source folder
|
|
294
|
+
# === params
|
|
295
|
+
# source:: String containing source folder
|
|
296
|
+
# folders:: Array internal variable, used in recursion, can be used as result value if given variable is empty array.
|
|
297
|
+
# === returns
|
|
298
|
+
# Array list of folder names
|
|
299
|
+
# === raises
|
|
300
|
+
def self.folder_tree( source, folders = [] )
|
|
301
|
+
|
|
302
|
+
Dir.glob( source + "/*" ).each{ | folder |
|
|
303
|
+
if File.directory?( folder ); folders << folder; MobyUtil::FileHelper.folder_tree( folder, folders ); end
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
folders.uniq.compact
|
|
307
|
+
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
# enable hooking for performance measurement & debug logging
|
|
311
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
|
312
|
+
|
|
313
|
+
end # FileHelper
|
|
314
|
+
|
|
315
|
+
end # MobyUtil
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
############################################################################
|
|
2
|
+
##
|
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
4
|
+
## All rights reserved.
|
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
|
6
|
+
##
|
|
7
|
+
## This file is part of Testability Driver.
|
|
8
|
+
##
|
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
|
11
|
+
##
|
|
12
|
+
## This library is free software; you can redistribute it and/or
|
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
|
16
|
+
## of this file.
|
|
17
|
+
##
|
|
18
|
+
############################################################################
|
|
19
|
+
|
|
20
|
+
module MobyUtil
|
|
21
|
+
|
|
22
|
+
class GemHelper
|
|
23
|
+
|
|
24
|
+
def self.create_build_files
|
|
25
|
+
|
|
26
|
+
# Create build files. These are required, as RubyGems expects that external dependencies
|
|
27
|
+
# are built during the gem installation process and will not complete the installation
|
|
28
|
+
# if these files are missing.
|
|
29
|
+
|
|
30
|
+
begin
|
|
31
|
+
|
|
32
|
+
# remove following line when native extensions are supported by tdriver
|
|
33
|
+
#raise LoadError
|
|
34
|
+
|
|
35
|
+
# skip native extension build if running in java environment
|
|
36
|
+
raise LoadError if MobyUtil::EnvironmentHelper.java?
|
|
37
|
+
|
|
38
|
+
# skip also if windows env. until proper solution found how to compile in windows env.
|
|
39
|
+
raise LoadError if MobyUtil::EnvironmentHelper.windows?
|
|
40
|
+
|
|
41
|
+
# makefile creation module
|
|
42
|
+
require 'mkmf'
|
|
43
|
+
|
|
44
|
+
# name of ruby native extension
|
|
45
|
+
extension_name = 'tdriver/native_extensions'
|
|
46
|
+
|
|
47
|
+
# destination
|
|
48
|
+
dir_config( extension_name )
|
|
49
|
+
|
|
50
|
+
# create makefile for implementation
|
|
51
|
+
create_makefile( extension_name )
|
|
52
|
+
|
|
53
|
+
rescue Exception
|
|
54
|
+
|
|
55
|
+
# create dummy makefile if building native extension fails or is not supported
|
|
56
|
+
File.open( 'Makefile', 'w' ) { | f | f.write "all:\n\ninstall:\n\n" }
|
|
57
|
+
|
|
58
|
+
if MobyUtil::EnvironmentHelper.windows?
|
|
59
|
+
|
|
60
|
+
File.open( 'nmake.bat', 'w') { |f| f.write "SET ERRORLEVEL=0" }
|
|
61
|
+
File.open( 'extconf.dll', 'w' ) {}
|
|
62
|
+
|
|
63
|
+
else
|
|
64
|
+
|
|
65
|
+
File.open( 'make', 'w' ){ | f | f.write '#!/bin/sh'; f.chmod f.stat.mode | 0111; }
|
|
66
|
+
File.open( 'extconf.so', 'w' ) {}
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def self.grant_file_access_rights( folder, user_name = nil, user_group = nil )
|
|
75
|
+
|
|
76
|
+
if MobyUtil::EnvironmentHelper.posix?
|
|
77
|
+
|
|
78
|
+
# change folder ownership to user and add writing access to each file
|
|
79
|
+
user_name = MobyUtil::EnvironmentHelper.user_name if user_name.nil?
|
|
80
|
+
user_group = MobyUtil::EnvironmentHelper.user_group( user_name ) if user_group.nil?
|
|
81
|
+
|
|
82
|
+
MobyUtil::EnvironmentHelper.change_file_ownership!( folder, user_name, user_group, true )
|
|
83
|
+
|
|
84
|
+
`chmod -R u+w #{ folder }`
|
|
85
|
+
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# TODO: document
|
|
91
|
+
def self.install( *parameters, &block )
|
|
92
|
+
|
|
93
|
+
Kernel::raise ArgumentError.new( "Target folder required as first argument" ) unless parameters.count > 0
|
|
94
|
+
|
|
95
|
+
yield( *parameters )
|
|
96
|
+
|
|
97
|
+
MobyUtil::GemHelper.create_build_files
|
|
98
|
+
|
|
99
|
+
MobyUtil::GemHelper.grant_file_access_rights( parameters.first )
|
|
100
|
+
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# enable hooking for performance measurement & debug logging
|
|
104
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
|
105
|
+
|
|
106
|
+
end # GemHelper
|
|
107
|
+
|
|
108
|
+
end # MobyUtil
|