-
Notifications
You must be signed in to change notification settings - Fork 67
/
Rakefile
executable file
·74 lines (57 loc) · 1.68 KB
/
Rakefile
1
2
3
4
5
6
7
8
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env rake
require 'bundler'
require "bundler/gem_tasks"
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do
Bundler.setup(:default, :test)
end
task :example do
FileList['examples/**/*.rb'].each do |f|
puts "==== Run example: #{f} ===="
ruby f
end
end
require 'rake/testtask'
begin
require 'rake/extensiontask'
rescue LoadError
abort <<-error
rake-compile is missing; Rugged depends on rake-compiler to build the C wrapping code.
Install it by running `gem i rake-compiler`
error
end
gemspec = Gem::Specification::load(
File.expand_path('../aliyun-sdk.gemspec', __FILE__))
Gem::PackageTask.new(gemspec) do |pkg|
end
Rake::ExtensionTask.new('crcx', gemspec) do |ext|
ext.name = 'crcx'
ext.ext_dir = 'ext/crcx'
ext.lib_dir = 'lib/aliyun'
end
Rake::TestTask.new do |t|
t.pattern = "tests/**/test_*.rb"
end
task :default => [:compile, :spec]
task :smart_test do
# run spec test
Rake::Task[:spec].invoke
if ENV.keys.include?('RUBY_SDK_OSS_KEY')
begin
env_upload_crc_enable = ENV['RUBY_SDK_OSS_UPLOAD_CRC_ENABLE']
env_download_crc_enable = ENV['RUBY_SDK_OSS_DOWNLOAD_CRC_ENABLE']
# run test with crc
ENV['RUBY_SDK_OSS_UPLOAD_CRC_ENABLE'] = 'true'
ENV['RUBY_SDK_OSS_DOWNLOAD_CRC_ENABLE'] = 'true'
Rake::Task[:test].invoke
# run test without crc
ENV['RUBY_SDK_OSS_UPLOAD_CRC_ENABLE'] = 'false'
ENV['RUBY_SDK_OSS_DOWNLOAD_CRC_ENABLE'] = 'false'
Rake::Task[:test].invoke
ensure
ENV['RUBY_SDK_OSS_UPLOAD_CRC_ENABLE'] = env_upload_crc_enable
ENV['RUBY_SDK_OSS_DOWNLOAD_CRC_ENABLE'] = env_download_crc_enable
end
end
end
Rake::Task[:smart_test].prerequisites << :compile