How to use os method of Platform Package

Best Selenium code snippet using Platform.os

platform_spec.rb

Source:platform_spec.rb Github

copy

Full Screen

...5 @guard = PlatformGuard.new :dummy6 allow(PlatformGuard).to receive(:new).and_return(@guard)7 ScratchPad.clear8 end9 it "does not yield when #os? returns false" do10 allow(PlatformGuard).to receive(:os?).and_return(false)11 platform_is(:ruby) { ScratchPad.record :yield }12 expect(ScratchPad.recorded).not_to eq(:yield)13 end14 it "yields when #os? returns true" do15 allow(PlatformGuard).to receive(:os?).and_return(true)16 platform_is(:solarce) { ScratchPad.record :yield }17 expect(ScratchPad.recorded).to eq(:yield)18 end19 it "returns what #os? returns when no block is given" do20 allow(PlatformGuard).to receive(:os?).and_return(true)21 expect(platform_is(:solarce)).to eq(true)22 allow(PlatformGuard).to receive(:os?).and_return(false)23 expect(platform_is(:solarce)).to eq(false)24 end25 it "sets the name of the guard to :platform_is" do26 platform_is(:solarce) { }27 expect(@guard.name).to eq(:platform_is)28 end29 it "calls #unregister even when an exception is raised in the guard block" do30 expect(@guard).to receive(:match?).and_return(true)31 expect(@guard).to receive(:unregister)32 expect do33 platform_is(:solarce) { raise Exception }34 end.to raise_error(Exception)35 end36end37RSpec.describe Object, "#platform_is_not" do38 before :each do39 @guard = PlatformGuard.new :dummy40 allow(PlatformGuard).to receive(:new).and_return(@guard)41 ScratchPad.clear42 end43 it "does not yield when #os? returns true" do44 allow(PlatformGuard).to receive(:os?).and_return(true)45 platform_is_not(:ruby) { ScratchPad.record :yield }46 expect(ScratchPad.recorded).not_to eq(:yield)47 end48 it "yields when #os? returns false" do49 allow(PlatformGuard).to receive(:os?).and_return(false)50 platform_is_not(:solarce) { ScratchPad.record :yield }51 expect(ScratchPad.recorded).to eq(:yield)52 end53 it "returns the opposite of what #os? returns when no block is given" do54 allow(PlatformGuard).to receive(:os?).and_return(true)55 expect(platform_is_not(:solarce)).to eq(false)56 allow(PlatformGuard).to receive(:os?).and_return(false)57 expect(platform_is_not(:solarce)).to eq(true)58 end59 it "sets the name of the guard to :platform_is_not" do60 platform_is_not(:solarce) { }61 expect(@guard.name).to eq(:platform_is_not)62 end63 it "calls #unregister even when an exception is raised in the guard block" do64 expect(@guard).to receive(:match?).and_return(false)65 expect(@guard).to receive(:unregister)66 expect do67 platform_is_not(:solarce) { raise Exception }68 end.to raise_error(Exception)69 end70end71RSpec.describe Object, "#platform_is :wordsize => SIZE_SPEC" do72 before :each do73 @guard = PlatformGuard.new :darwin, :wordsize => 3274 allow(PlatformGuard).to receive(:os?).and_return(true)75 allow(PlatformGuard).to receive(:new).and_return(@guard)76 ScratchPad.clear77 end78 it "yields when #wordsize? returns true" do79 allow(PlatformGuard).to receive(:wordsize?).and_return(true)80 platform_is(:wordsize => 32) { ScratchPad.record :yield }81 expect(ScratchPad.recorded).to eq(:yield)82 end83 it "doesn not yield when #wordsize? returns false" do84 allow(PlatformGuard).to receive(:wordsize?).and_return(false)85 platform_is(:wordsize => 32) { ScratchPad.record :yield }86 expect(ScratchPad.recorded).not_to eq(:yield)87 end88end89RSpec.describe Object, "#platform_is_not :wordsize => SIZE_SPEC" do90 before :each do91 @guard = PlatformGuard.new :darwin, :wordsize => 3292 allow(PlatformGuard).to receive(:os?).and_return(true)93 allow(PlatformGuard).to receive(:new).and_return(@guard)94 ScratchPad.clear95 end96 it "yields when #wordsize? returns false" do97 allow(PlatformGuard).to receive(:wordsize?).and_return(false)98 platform_is_not(:wordsize => 32) { ScratchPad.record :yield }99 expect(ScratchPad.recorded).to eq(:yield)100 end101 it "doesn not yield when #wordsize? returns true" do102 allow(PlatformGuard).to receive(:wordsize?).and_return(true)103 platform_is_not(:wordsize => 32) { ScratchPad.record :yield }104 expect(ScratchPad.recorded).not_to eq(:yield)105 end106end107RSpec.describe PlatformGuard, ".implementation?" do108 it "returns true if passed :ruby and RUBY_ENGINE == 'ruby'" do109 stub_const 'RUBY_ENGINE', 'ruby'110 expect(PlatformGuard.implementation?(:ruby)).to eq(true)111 end112 it "returns true if passed :rubinius and RUBY_ENGINE == 'rbx'" do113 stub_const 'RUBY_ENGINE', 'rbx'114 expect(PlatformGuard.implementation?(:rubinius)).to eq(true)115 end116 it "returns true if passed :jruby and RUBY_ENGINE == 'jruby'" do117 stub_const 'RUBY_ENGINE', 'jruby'118 expect(PlatformGuard.implementation?(:jruby)).to eq(true)119 end120 it "returns true if passed :ironruby and RUBY_ENGINE == 'ironruby'" do121 stub_const 'RUBY_ENGINE', 'ironruby'122 expect(PlatformGuard.implementation?(:ironruby)).to eq(true)123 end124 it "returns true if passed :maglev and RUBY_ENGINE == 'maglev'" do125 stub_const 'RUBY_ENGINE', 'maglev'126 expect(PlatformGuard.implementation?(:maglev)).to eq(true)127 end128 it "returns true if passed :topaz and RUBY_ENGINE == 'topaz'" do129 stub_const 'RUBY_ENGINE', 'topaz'130 expect(PlatformGuard.implementation?(:topaz)).to eq(true)131 end132 it "returns true if passed :ruby and RUBY_ENGINE matches /^ruby/" do133 stub_const 'RUBY_ENGINE', 'ruby'134 expect(PlatformGuard.implementation?(:ruby)).to eq(true)135 stub_const 'RUBY_ENGINE', 'ruby1.8'136 expect(PlatformGuard.implementation?(:ruby)).to eq(true)137 stub_const 'RUBY_ENGINE', 'ruby1.9'138 expect(PlatformGuard.implementation?(:ruby)).to eq(true)139 end140 it "works for an unrecognized name" do141 stub_const 'RUBY_ENGINE', 'myrubyimplementation'142 expect(PlatformGuard.implementation?(:myrubyimplementation)).to eq(true)143 expect(PlatformGuard.implementation?(:other)).to eq(false)144 end145end146RSpec.describe PlatformGuard, ".standard?" do147 it "returns true if implementation? returns true" do148 expect(PlatformGuard).to receive(:implementation?).with(:ruby).and_return(true)149 expect(PlatformGuard.standard?).to be_truthy150 end151 it "returns false if implementation? returns false" do152 expect(PlatformGuard).to receive(:implementation?).with(:ruby).and_return(false)153 expect(PlatformGuard.standard?).to be_falsey154 end155end156RSpec.describe PlatformGuard, ".wordsize?" do157 it "returns true when arg is 32 and 1.size is 4" do158 expect(PlatformGuard.wordsize?(32)).to eq(1.size == 4)159 end160 it "returns true when arg is 64 and 1.size is 8" do161 expect(PlatformGuard.wordsize?(64)).to eq(1.size == 8)162 end163end164RSpec.describe PlatformGuard, ".os?" do165 before :each do166 stub_const 'PlatformGuard::PLATFORM', 'solarce'167 end168 it "returns false when arg does not match the platform" do169 expect(PlatformGuard.os?(:ruby)).to eq(false)170 end171 it "returns false when no arg matches the platform" do172 expect(PlatformGuard.os?(:ruby, :jruby, :rubinius, :maglev)).to eq(false)173 end174 it "returns true when arg matches the platform" do175 expect(PlatformGuard.os?(:solarce)).to eq(true)176 end177 it "returns true when any arg matches the platform" do178 expect(PlatformGuard.os?(:ruby, :jruby, :solarce, :rubinius, :maglev)).to eq(true)179 end180 it "returns true when arg is :windows and the platform contains 'mswin'" do181 stub_const 'PlatformGuard::PLATFORM', 'mswin32'182 expect(PlatformGuard.os?(:windows)).to eq(true)183 end184 it "returns true when arg is :windows and the platform contains 'mingw'" do185 stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32'186 expect(PlatformGuard.os?(:windows)).to eq(true)187 end188 it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mswin'" do189 stub_const 'PlatformGuard::PLATFORM', 'i386-mswin32'190 expect(PlatformGuard.os?(:linux)).to eq(false)191 end192 it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mingw'" do193 stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32'194 expect(PlatformGuard.os?(:linux)).to eq(false)195 end196end197RSpec.describe PlatformGuard, ".os?" do198 it "returns true if called with the current OS or architecture" do199 os = RbConfig::CONFIG["host_os"].sub("-gnu", "")200 arch = RbConfig::CONFIG["host_arch"]201 expect(PlatformGuard.os?(os)).to eq(true)202 expect(PlatformGuard.os?(arch)).to eq(true)203 expect(PlatformGuard.os?("#{arch}-#{os}")).to eq(true)204 end205end206RSpec.describe PlatformGuard, ".os? on JRuby" do207 before :all do208 @verbose = $VERBOSE209 $VERBOSE = nil210 end211 after :all do212 $VERBOSE = @verbose213 end214 before :each do215 @ruby_platform = Object.const_get :RUBY_PLATFORM216 Object.const_set :RUBY_PLATFORM, 'java'217 end218 after :each do219 Object.const_set :RUBY_PLATFORM, @ruby_platform220 end221 it "raises an error when testing for a :java platform" do222 expect {223 PlatformGuard.os?(:java)224 }.to raise_error(":java is not a valid OS")225 end226 it "returns true when arg is :windows and RUBY_PLATFORM contains 'java' and os?(:windows) is true" do227 stub_const 'PlatformGuard::PLATFORM', 'mswin32'228 expect(PlatformGuard.os?(:windows)).to eq(true)229 end230 it "returns true when RUBY_PLATFORM contains 'java' and os?(argument) is true" do231 stub_const 'PlatformGuard::PLATFORM', 'amiga'232 expect(PlatformGuard.os?(:amiga)).to eq(true)233 end234end235RSpec.describe PlatformGuard, ".os?" do236 before :each do237 stub_const 'PlatformGuard::PLATFORM', 'unreal'238 end239 it "returns true if argument matches RbConfig::CONFIG['host_os']" do240 expect(PlatformGuard.os?(:unreal)).to eq(true)241 end242 it "returns true if any argument matches RbConfig::CONFIG['host_os']" do243 expect(PlatformGuard.os?(:bsd, :unreal, :amiga)).to eq(true)244 end245 it "returns false if no argument matches RbConfig::CONFIG['host_os']" do246 expect(PlatformGuard.os?(:bsd, :netbsd, :amiga, :msdos)).to eq(false)247 end248 it "returns false if argument does not match RbConfig::CONFIG['host_os']" do249 expect(PlatformGuard.os?(:amiga)).to eq(false)250 end251 it "returns true when arg is :windows and RbConfig::CONFIG['host_os'] contains 'mswin'" do252 stub_const 'PlatformGuard::PLATFORM', 'i386-mswin32'253 expect(PlatformGuard.os?(:windows)).to eq(true)254 end255 it "returns true when arg is :windows and RbConfig::CONFIG['host_os'] contains 'mingw'" do256 stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32'257 expect(PlatformGuard.os?(:windows)).to eq(true)258 end259 it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mswin'" do260 stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32'261 expect(PlatformGuard.os?(:linux)).to eq(false)262 end263 it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mingw'" do264 stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32'265 expect(PlatformGuard.os?(:linux)).to eq(false)266 end267end268RSpec.describe PlatformGuard, ".windows?" do269 it "returns true on windows" do270 stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32'271 expect(PlatformGuard.windows?).to eq(true)272 end273 it "returns false on non-windows" do274 stub_const 'PlatformGuard::PLATFORM', 'i586-linux'275 expect(PlatformGuard.windows?).to eq(false)276 end277end...

Full Screen

Full Screen

platform.rb

Source:platform.rb Github

copy

Full Screen

...6# See `gem help platform` for information on platform matching.7class Gem::Platform8 @local = nil9 attr_accessor :cpu10 attr_accessor :os11 attr_accessor :version12 def self.local13 arch = RbConfig::CONFIG['arch']14 arch = "#{arch}_60" if arch =~ /mswin(?:32|64)$/15 @local ||= new(arch)16 end17 def self.match(platform)18 Gem.platforms.any? do |local_platform|19 platform.nil? or20 local_platform == platform or21 (local_platform != Gem::Platform::RUBY and local_platform =~ platform)22 end23 end24 def self.installable?(spec)25 if spec.respond_to? :installable_platform?26 spec.installable_platform?27 else28 match spec.platform29 end30 end31 def self.new(arch) # :nodoc:32 case arch33 when Gem::Platform::CURRENT then34 Gem::Platform.local35 when Gem::Platform::RUBY, nil, '' then36 Gem::Platform::RUBY37 else38 super39 end40 end41 def initialize(arch)42 case arch43 when Array then44 @cpu, @os, @version = arch45 when String then46 arch = arch.split '-'47 if arch.length > 2 and arch.last !~ /\d/ then # reassemble x86-linux-gnu48 extra = arch.pop49 arch.last << "-#{extra}"50 end51 cpu = arch.shift52 @cpu = case cpu53 when /i\d86/ then 'x86'54 else cpu55 end56 if arch.length == 2 and arch.last =~ /^\d+(\.\d+)?$/ then # for command-line57 @os, @version = arch58 return59 end60 os, = arch61 @cpu, os = nil, cpu if os.nil? # legacy jruby62 @os, @version = case os63 when /aix(\d+)?/ then [ 'aix', $1 ]64 when /cygwin/ then [ 'cygwin', nil ]65 when /darwin(\d+)?/ then [ 'darwin', $1 ]66 when /^macruby$/ then [ 'macruby', nil ]67 when /freebsd(\d+)?/ then [ 'freebsd', $1 ]68 when /hpux(\d+)?/ then [ 'hpux', $1 ]69 when /^java$/, /^jruby$/ then [ 'java', nil ]70 when /^java([\d.]*)/ then [ 'java', $1 ]71 when /^dalvik(\d+)?$/ then [ 'dalvik', $1 ]72 when /^dotnet$/ then [ 'dotnet', nil ]73 when /^dotnet([\d.]*)/ then [ 'dotnet', $1 ]74 when /linux/ then [ 'linux', $1 ]75 when /mingw32/ then [ 'mingw32', nil ]76 when /(mswin\d+)(\_(\d+))?/ then77 os, version = $1, $378 @cpu = 'x86' if @cpu.nil? and os =~ /32$/79 [os, version]80 when /netbsdelf/ then [ 'netbsdelf', nil ]81 when /openbsd(\d+\.\d+)?/ then [ 'openbsd', $1 ]82 when /bitrig(\d+\.\d+)?/ then [ 'bitrig', $1 ]83 when /solaris(\d+\.\d+)?/ then [ 'solaris', $1 ]84 # test85 when /^(\w+_platform)(\d+)?/ then [ $1, $2 ]86 else [ 'unknown', nil ]87 end88 when Gem::Platform then89 @cpu = arch.cpu90 @os = arch.os91 @version = arch.version92 else93 raise ArgumentError, "invalid argument #{arch.inspect}"94 end95 end96 def inspect97 "%s @cpu=%p, @os=%p, @version=%p>" % [super[0..-2], *to_a]98 end99 def to_a100 [@cpu, @os, @version]101 end102 def to_s103 to_a.compact.join '-'104 end105 ##106 # Is +other+ equal to this platform? Two platforms are equal if they have107 # the same CPU, OS and version.108 def ==(other)109 self.class === other and to_a == other.to_a110 end111 alias :eql? :==112 def hash # :nodoc:113 to_a.hash114 end115 ##116 # Does +other+ match this platform? Two platforms match if they have the117 # same CPU, or either has a CPU of 'universal', they have the same OS, and118 # they have the same version, or either has no version.119 #120 # Additionally, the platform will match if the local CPU is 'arm' and the121 # other CPU starts with "arm" (for generic ARM family support).122 def ===(other)123 return nil unless Gem::Platform === other124 # cpu125 ([nil,'universal'].include?(@cpu) or [nil, 'universal'].include?(other.cpu) or @cpu == other.cpu or126 (@cpu == 'arm' and other.cpu =~ /\Aarm/)) and127 # os128 @os == other.os and129 # version130 (@version.nil? or other.version.nil? or @version == other.version)131 end132 ##133 # Does +other+ match this platform? If +other+ is a String it will be134 # converted to a Gem::Platform first. See #=== for matching rules.135 def =~(other)136 case other137 when Gem::Platform then # nop138 when String then139 # This data is from http://gems.rubyforge.org/gems/yaml on 19 Aug 2007140 other = case other141 when /^i686-darwin(\d)/ then ['x86', 'darwin', $1 ]142 when /^i\d86-linux/ then ['x86', 'linux', nil ]...

Full Screen

Full Screen

Rakefile

Source:Rakefile Github

copy

Full Screen

...3end4def project_name5 'ChartsDemo-iOS/ChartsDemo-iOS.xcodeproj'6end7def macos_project_name8 'ChartsDemo-macOS/ChartsDemo-macOS.xcodeproj'9end10def configuration11 'Debug'12end13def test_platforms14 %i[15 iOS16 tvOS17 ]18end19def build_platforms20 [21 :macOS22 ]23end24def build_schemes25 %w[26 Charts27 ]28end29def build_demo_schemes30 %i[31 ChartsDemo-iOS32 ChartsDemo-iOS-Swift33 ]34end35def build_macos_demo_schemes36 [37 'ChartsDemo-macOS'38 ]39end40def test_schemes41 [42 'ChartsTests'43 ]44end45def devices46 {47 iOS: {48 sdk: 'iphonesimulator',49 device: "name='iPhone 7'",50 name: 'iPhone 7'51 },52 macOS: {53 sdk: 'macosx',54 device: "arch='x86_64'",55 uuid: nil56 },57 tvOS: {58 sdk: 'appletvsimulator',59 device: "name='Apple TV'",60 name: 'Apple TV'61 }62 }63end64def open_simulator_and_sleep(uuid)65 return if uuid.nil? # Don't need a sleep on macOS because it runs first.66 sh "xcrun instruments -w '#{uuid}' || sleep 15"67end68def xcodebuild(type, name, scheme, configuration, sdk, destination, tasks, xcprety_args)69 # set either workspace or project flag for xcodebuild70 case type71 when :project72 project_type = '-project'73 when :workspace74 project_type = '-workspace'75 else76 abort 'Invalid project type, use `:project` for xcodeproj and `:workspace` for xcworkspace.'77 end78 sh "set -o pipefail && xcodebuild #{project_type} '#{name}' -scheme '#{scheme}' -configuration '#{configuration}' -sdk #{sdk} -destination #{destination} #{tasks} | bundle exec xcpretty -c #{xcprety_args}"79end80def run_xcodebuild(tasks, destination, is_build_demo, xcprety_args)81 sdk = destination[:sdk]82 device = destination[:device]83 uuid = destination[:uuid]84 is_test = tasks.include?('test')85 is_macos = sdk == 'macosx'86 project = is_macos ? macos_project_name : project_name87 schemes_to_execute = []88 if is_test89 schemes_to_execute = test_schemes90 elsif is_build_demo91 schemes_to_execute = is_macos ? build_macos_demo_schemes : build_demo_schemes92 else93 schemes_to_execute = build_schemes94 end95 open_simulator_and_sleep uuid if is_test96 schemes_to_execute.each do |scheme|97 xcodebuild type, project, scheme, configuration, sdk, device, tasks, xcprety_args98 end99end100def execute(tasks, platform, is_build_demo = false, xcprety_args: '')101 # platform specific settings102 destination = devices[platform]103 # check if xcodebuild needs to be run on multiple devices104 if destination.is_a?(Array)105 destination.each do |destination|106 run_xcodebuild tasks, destination, is_build_demo, xcprety_args107 end108 else109 run_xcodebuild tasks, destination, is_build_demo, xcprety_args110 end111end112def arg_to_key(string_key)113 case string_key.downcase114 when 'ios'115 :iOS116 when 'tvos'117 :tvOS118 when 'macos'119 :macOS120 when 'watchos'121 :watchOS122 else123 abort 'Invalid platform, use `iOS`, `tvOS`, `macOS` or `watchOS`'124 end125end126desc 'Run CI tasks. Build and test or build depending on the platform.'127task :ci, [:platform] do |_task, args|128 platform = arg_to_key(args[:platform]) if args.key?(:platform)129 is_build_demo = test_platforms.include?(platform) || build_platforms.include?(platform)130 if test_platforms.include?(platform) # iOS and tvOS131 if platform == :iOS132 execute 'clean', platform, is_build_demo133 execute 'build', platform, is_build_demo134 execute 'test', platform # not use demo specifically...

Full Screen

Full Screen

gem_helpers.rb

Source:gem_helpers.rb Github

copy

Full Screen

...14 def generic(p)15 return p if p == Gem::Platform::RUBY16 GENERIC_CACHE[p] ||= begin17 _, found = GENERICS.find do |match, _generic|18 p.os == match.os && (!match.cpu || p.cpu == match.cpu)19 end20 found || Gem::Platform::RUBY21 end22 end23 module_function :generic24 def generic_local_platform25 generic(Bundler.local_platform)26 end27 module_function :generic_local_platform28 def platform_specificity_match(spec_platform, user_platform)29 spec_platform = Gem::Platform.new(spec_platform)30 return PlatformMatch::EXACT_MATCH if spec_platform == user_platform31 return PlatformMatch::WORST_MATCH if spec_platform.nil? || spec_platform == Gem::Platform::RUBY || user_platform == Gem::Platform::RUBY32 PlatformMatch.new(33 PlatformMatch.os_match(spec_platform, user_platform),34 PlatformMatch.cpu_match(spec_platform, user_platform),35 PlatformMatch.platform_version_match(spec_platform, user_platform)36 )37 end38 module_function :platform_specificity_match39 def select_best_platform_match(specs, platform)40 specs.select {|spec| spec.match_platform(platform) }.41 min_by {|spec| platform_specificity_match(spec.platform, platform) }42 end43 module_function :select_best_platform_match44 PlatformMatch = Struct.new(:os_match, :cpu_match, :platform_version_match)45 class PlatformMatch46 def <=>(other)47 return nil unless other.is_a?(PlatformMatch)48 m = os_match <=> other.os_match49 return m unless m.zero?50 m = cpu_match <=> other.cpu_match51 return m unless m.zero?52 m = platform_version_match <=> other.platform_version_match53 m54 end55 EXACT_MATCH = new(-1, -1, -1).freeze56 WORST_MATCH = new(1_000_000, 1_000_000, 1_000_000).freeze57 def self.os_match(spec_platform, user_platform)58 if spec_platform.os == user_platform.os59 060 else61 162 end63 end64 def self.cpu_match(spec_platform, user_platform)65 if spec_platform.cpu == user_platform.cpu66 067 elsif spec_platform.cpu == "arm" && user_platform.cpu.to_s.start_with?("arm")68 069 elsif spec_platform.cpu.nil? || spec_platform.cpu == "universal"70 171 else72 2...

Full Screen

Full Screen

mariadb_helper.rb

Source:mariadb_helper.rb Github

copy

Full Screen

...5 require 'socket'6 require 'timeout'7 def do_port_connect(ip, port)8 s = TCPSocket.new(ip, port)9 s.close10 true11 rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH12 false13 end14 def port_open?(ip, port)15 begin16 Timeout.timeout(5) do17 return do_port_connect(ip, port)18 end19 rescue Timeout::Error20 false21 end22 false23 end24 # Trying to determine if we need to restart the mysql service25 def mariadb_service_restart_required?(ip, port, _socket)26 restart = false27 restart = true unless port_open?(ip, port)28 restart29 end30 # Helper to determine if running operating system shipped a package for31 # mariadb server & client. No galera shipped in any os yet.32 # @param [String] os_platform Indicate operating system type, e.g. centos33 # @param [String] os_version Indicate operating system version, e.g. 7.034 def os_package_provided?(os_platform, os_version)35 package_provided = false36 case os_platform37 when 'centos', 'redhat'38 package_provided = true if os_version.to_i == 739 when 'fedora'40 package_provided = true if os_version.to_i >= 1941 end42 package_provided43 end44 # Helper to determine mariadb server service name shipped by native package45 # If no native package available on this platform, return nil46 # @param [String] os_platform Indicate operating system type, e.g. centos47 # @param [String] os_version Indicate operating system version, e.g. 7.048 def os_service_name(os_platform, os_version)49 return nil unless os_package_provided?(os_platform, os_version)50 service_name = 'mariadb'51 if os_platform == 'fedora' && os_version.to_i >= 1952 service_name = 'mysqld'53 end54 service_name55 end56 # Helper to determine whether to use os native package57 # @param [Boolean] prefer_os Indicate whether to prefer os native package58 # @param [String] os_platform Indicate operating system type, e.g. centos59 # @param [String] os_version Indicate operating system version, e.g. 7.060 def use_os_native_package?(prefer_os, os_platform, os_version)61 return false unless prefer_os62 if os_package_provided?(os_platform, os_version)63 true64 else65 Chef::Log.warn 'prefer_os_package detected, but no native mariadb'\66 " package available on #{os_platform}-#{os_version}."\67 ' Fall back to use community package.'68 false69 end70 end71 end72end...

Full Screen

Full Screen

helper_spec.rb

Source:helper_spec.rb Github

copy

Full Screen

...11 it { expect(helper.binary_path).to match(/chromedriver\.exe$/) }12 end13 end14 describe '#platform' do15 os_cpu_matrix = [16 { 'host_os' => 'darwin','host_cpu' => 'irrelevant', 'expected_platform' => 'mac' },17 { 'host_os' => 'linux', 'host_cpu' => 'amd64', 'expected_platform' => 'linux64' },18 { 'host_os' => 'linux', 'host_cpu' => 'irrelevant', 'expected_platform' => 'linux32' },19 { 'host_os' => 'linux', 'host_cpu' => 'x86_64', 'expected_platform' => 'linux64' },20 { 'host_os' => 'mingw', 'host_cpu' => 'irrelevant', 'expected_platform' => 'win' },21 { 'host_os' => 'mswin', 'host_cpu' => 'irrelevant', 'expected_platform' => 'win' }22 ]23 os_cpu_matrix.each do |config|24 expected_platform = config['expected_platform']25 host_cpu = config['host_cpu']26 host_os = config['host_os']27 context "given host OS #{host_os} and host CPU #{host_cpu}" do28 before do29 RbConfig.send(:remove_const, :CONFIG)30 RbConfig::CONFIG = { 'host_os' => host_os, 'host_cpu' => host_cpu }31 end32 it "returns #{expected_platform}" do33 expect(helper.platform).to eq(expected_platform)34 end35 end36 end37 context 'given an unknown host OS' do38 before do39 RbConfig.send(:remove_const, :CONFIG)40 RbConfig::CONFIG = { 'host_os' => 'freebsd', 'host_cpu' => 'irrelevant' }41 end42 it 'raises an exception' do43 expect { helper.platform }.to raise_error("Unsupported host OS 'freebsd'")44 end45 end46 end47end

Full Screen

Full Screen

computer.rb

Source:computer.rb Github

copy

Full Screen

...26 def type27 fetch('computer.type')28 end29 ##30 # Produces the name of a computer os.31 #32 # @param platform [String] optionally specify the platform `linux`, `macos`, or `windows`.33 # @return [String]34 #35 # @example36 # Faker::Computer.os #=> "RHEL 6.10"37 #38 # @faker.version 2.12.039 def os(platform: self.platform)40 platform = self.platform unless fetch_all('computer.platform').include?(platform)41 fetch("computer.os.#{platform.downcase}")42 end43 ##44 # Produces a string with computer platform and os45 #46 # @return [String]47 #48 # @example49 # Faker::Computer.stack #=> "Linux, RHEL 6.10"50 #51 # @faker.version 2.12.052 def stack53 platform = self.platform54 os = fetch("computer.os.#{platform.downcase}")55 "#{platform}, #{os}"56 end57 end58 end59end...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful