-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
86 changed files
with
313 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,189 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rubocop/rake_task' | ||
require 'rspec/core/rake_task' | ||
|
||
RuboCop::RakeTask.new | ||
|
||
namespace :smithy do | ||
RSpec::Core::RakeTask.new('spec:unit') do |t| | ||
t.pattern = 'gems/smithy/spec/**/*_spec.rb' | ||
t.ruby_opts = '-I gems/smithy/spec' | ||
t.rspec_opts = '--format documentation' | ||
t.rspec_opts += ' --tag rbs_test' if ENV['SMITHY_RUBY_RBS_TEST'] | ||
end | ||
|
||
task 'spec:generated', [:suite, :rbs_test] do |_t, args| | ||
require_relative 'gems/smithy/spec/spec_helper' | ||
|
||
spec_paths = [] | ||
include_paths = ['gems/smithy/spec/support/matchers'] | ||
plans = [] | ||
rbs_targets = %w[Smithy Smithy::* Smithy::Client] | ||
sig_paths = %w[gems/smithy-client/sig gems/smithy-schema/sig] | ||
Dir.glob("gems/smithy/spec/fixtures/#{args[:suite]}/*/model.json") do |model_path| | ||
test_name = model_path.split('/')[-2] | ||
test_module = test_name.gsub('-', '').camelize | ||
plan = SpecHelper.generate_gem(test_module, :client, fixture: "#{args[:suite]}/#{test_name}") | ||
plans << plan | ||
tmpdir = plan.destination_root | ||
spec_paths << "#{tmpdir}/spec" | ||
include_paths << "#{tmpdir}/lib" | ||
include_paths << "#{tmpdir}/spec" | ||
sig_paths << "#{tmpdir}/sig" | ||
rbs_targets += [test_module, "#{test_module}::*"] | ||
end | ||
specs = spec_paths.join(' ') | ||
includes = include_paths.map { |p| "-I #{p}" }.join(' ') | ||
|
||
env = | ||
if args[:rbs_test] | ||
{ | ||
'RUBYOPT' => '-r bundler/setup -r rbs/test/setup', | ||
'RBS_TEST_RAISE' => 'true', | ||
'RBS_TEST_LOGLEVEL' => 'error', | ||
'RBS_TEST_OPT' => sig_paths.map { |p| "-I #{p}" }.join(' '), | ||
'RBS_TEST_TARGET' => "\"#{rbs_targets.join(',')}\"", | ||
'RBS_TEST_DOUBLE_SUITE' => 'rspec' | ||
} | ||
else | ||
{} | ||
end | ||
|
||
sh(env, "bundle exec rspec #{specs} #{includes}") | ||
ensure | ||
plans.each { |plan| SpecHelper.cleanup_gem(plan) } | ||
end | ||
|
||
task 'spec:endpoints', [:rbs_test] do |_t, args| | ||
task('smithy:spec:generated').invoke('endpoints', args[:rbs_test]) | ||
end | ||
|
||
task 'spec:protocols', [:rbs_test] do |_t, args| | ||
task('smithy:spec:generated').invoke('protocol_tests', args[:rbs_test]) | ||
end | ||
|
||
task 'spec' => %w[spec:unit spec:endpoints spec:protocols] | ||
|
||
desc 'Convert all fixture smithy models to JSON AST representation.' | ||
task 'sync-fixtures' do | ||
smithy_build_files = Dir.glob('gems/smithy/spec/fixtures/**/smithy-build.json') | ||
Dir.glob('gems/smithy/spec/fixtures/**/model.smithy') do |model_path| | ||
out_path = model_path.sub('.smithy', '.json') | ||
config_files = smithy_build_files.map do |file| | ||
if model_path.include?(File.dirname(file)) | ||
FileUtils.touch(file) # https://github.com/smithy-lang/smithy/issues/2537 | ||
" --config #{file}" | ||
end | ||
end | ||
sh("smithy ast#{config_files.join} #{model_path} > #{out_path}") | ||
end | ||
end | ||
|
||
desc 'Validate that all fixtures JSON models are up to date.' | ||
task 'validate-fixtures' do | ||
require 'json' | ||
failures = [] | ||
smithy_build_files = Dir.glob('gems/smithy/spec/fixtures/**/smithy-build.json') | ||
Dir.glob('gems/smithy/spec/fixtures/**/model.smithy') do |model_path| | ||
old = JSON.load_file(model_path.sub('.smithy', '.json')) | ||
config_files = smithy_build_files.map do |file| | ||
if model_path.include?(File.dirname(file)) | ||
FileUtils.touch(file) # https://github.com/smithy-lang/smithy/issues/2537 | ||
" --config #{file}" | ||
end | ||
end | ||
new = JSON.parse(`smithy ast#{config_files.join} #{model_path}`) | ||
failures << model_path if old != new | ||
end | ||
if failures.any? | ||
puts 'Fixture models out of sync:' | ||
failures.each { |m| puts "\t#{m}" } | ||
|
||
raise 'Fixture models are out of sync. Run bundle exec rake smithy:sync-fixtures to correct' | ||
end | ||
end | ||
|
||
desc 'Run RBS spy tests for all Unit tests that use fixtures.' | ||
task 'rbs:unit' do | ||
env = { | ||
'SMITHY_RUBY_RBS_TEST' => 'true' | ||
} | ||
sh(env, 'bundle exec rake smithy:spec:unit') | ||
end | ||
|
||
desc 'Run RBS spy tests for all generated endpoint provider specs.' | ||
task 'rbs:endpoints' do | ||
task('smithy:spec:endpoints').invoke('rbs_test') | ||
end | ||
|
||
desc 'Run RBS spy tests for all generated protocol test specs.' | ||
task 'rbs:protocol_tests' do | ||
task('smithy:spec:protocols').invoke('rbs_test') | ||
end | ||
|
||
desc 'Run RBS spy tests for unit tests and generated endpoint provider specs.' | ||
task 'rbs' => %w[rbs:unit rbs:endpoints rbs:protocol_tests] | ||
end | ||
|
||
namespace 'smithy-client' do | ||
RSpec::Core::RakeTask.new do |t| | ||
t.pattern = 'gems/smithy-client/spec/**/*_spec.rb' | ||
t.ruby_opts = '-I gems/smithy-client/spec' | ||
t.rspec_opts = '--format documentation' | ||
end | ||
|
||
desc 'Run RBS validation.' | ||
task 'rbs:validate' do | ||
sh('bundle exec rbs -I gems/smithy-client/sig -I gems/smithy-schema/sig validate') | ||
end | ||
|
||
desc 'Run RBS spy tests on all unit tests.' | ||
task 'rbs:test' do | ||
env = { | ||
'RUBYOPT' => '-r bundler/setup -r rbs/test/setup', | ||
'RBS_TEST_RAISE' => 'true', | ||
'RBS_TEST_LOGLEVEL' => 'error', | ||
'RBS_TEST_OPT' => '-I gems/smithy-client/sig -I gems/smithy-schema/sig', | ||
'RBS_TEST_TARGET' => '"Smithy::Client,Smithy::Client::*"', | ||
'RBS_TEST_DOUBLE_SUITE' => 'rspec' | ||
} | ||
sh(env, | ||
'bundle exec rspec gems/smithy-client/spec -I gems/smithy-client/lib -I gems/smithy-client/spec ' \ | ||
"--require spec_helper --tag '~rbs_test:skip'") | ||
end | ||
|
||
desc 'Run RBS validation and spy tests.' | ||
task 'rbs' => %w[rbs:validate rbs:test] | ||
end | ||
|
||
namespace 'smithy-schema' do | ||
RSpec::Core::RakeTask.new do |t| | ||
t.pattern = 'gems/smithy-schema/spec/**/*_spec.rb' | ||
t.ruby_opts = '-I gems/smithy-schema/spec' | ||
t.rspec_opts = '--format documentation' | ||
end | ||
|
||
desc 'Run RBS validation.' | ||
task 'rbs:validate' do | ||
sh('bundle exec rbs -I gems/smithy-schema/sig validate') | ||
end | ||
|
||
desc 'Run RBS spy tests on all unit tests.' | ||
task 'rbs:test' do | ||
env = { | ||
'RUBYOPT' => '-r bundler/setup -r rbs/test/setup', | ||
'RBS_TEST_RAISE' => 'true', | ||
'RBS_TEST_LOGLEVEL' => 'error', | ||
'RBS_TEST_OPT' => '-I gems/smithy-client/sig', | ||
'RBS_TEST_TARGET' => '"Smithy::Schema,Smithy::Schema::*"', | ||
'RBS_TEST_DOUBLE_SUITE' => 'rspec' | ||
} | ||
sh(env, | ||
'bundle exec rspec gems/smithy-schema/spec -I gems/smithy-schema/lib -I gems/smithy-schema/spec ' \ | ||
"--require spec_helper --tag '~rbs_test:skip'") | ||
end | ||
|
||
desc 'Run RBS validation and spy tests.' | ||
task 'rbs' => %w[rbs:validate rbs:test] | ||
Dir.glob('tasks/**/*.rake').each do |task_file| | ||
load(task_file) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../spec_helper' | ||
|
||
module Smithy | ||
module Client | ||
describe Base do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../spec_helper' | ||
|
||
module Smithy | ||
module Client | ||
module CBOR | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../spec_helper' | ||
|
||
module Smithy | ||
module Client | ||
module CBOR | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../spec_helper' | ||
|
||
module Smithy | ||
module Client | ||
describe CBOR do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../spec_helper' | ||
|
||
module Smithy | ||
module Client | ||
module Codecs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../spec_helper' | ||
|
||
module Smithy | ||
module Client | ||
module Errors | ||
|
2 changes: 2 additions & 0 deletions
2
gems/smithy-client/spec/smithy-client/handler_builder_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
gems/smithy-client/spec/smithy-client/handler_context_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../spec_helper' | ||
|
||
module Smithy | ||
module Client | ||
describe Handler do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../spec_helper' | ||
|
||
module Smithy | ||
module Client | ||
module HTTP | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../spec_helper' | ||
|
||
module Smithy | ||
module Client | ||
module HTTP | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../spec_helper' | ||
|
||
module Smithy | ||
module Client | ||
module HTTP | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../spec_helper' | ||
|
||
require 'tempfile' | ||
|
||
module Smithy | ||
|
2 changes: 2 additions & 0 deletions
2
gems/smithy-client/spec/smithy-client/net_http/connection_pool_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../spec_helper' | ||
|
||
module Smithy | ||
module Client | ||
module NetHTTP | ||
|
2 changes: 2 additions & 0 deletions
2
gems/smithy-client/spec/smithy-client/net_http/handler_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
gems/smithy-client/spec/smithy-client/net_http/patches_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../spec_helper' | ||
|
||
module Smithy | ||
module Client | ||
module NetHTTP | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../spec_helper' | ||
|
||
module Smithy | ||
module Client | ||
describe Output do | ||
|
2 changes: 2 additions & 0 deletions
2
gems/smithy-client/spec/smithy-client/param_converter_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../spec_helper' | ||
|
||
require 'bigdecimal' | ||
require 'stringio' | ||
|
||
|
2 changes: 2 additions & 0 deletions
2
gems/smithy-client/spec/smithy-client/param_validator_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.