@@ -36,7 +36,7 @@ gemfile_contents = Dir.mktmpdir do |dir|
3636 raise "could not unpack gem #{ gemfile } "
3737 end
3838
39- %x( tar -ztf data.tar.gz) . split ( "\n " )
39+ ` tar -ztf data.tar.gz` . split ( "\n " )
4040 end
4141end
4242
@@ -46,7 +46,7 @@ gemspec = Dir.mktmpdir do |dir|
4646 raise "could not unpack gem #{ gemfile } "
4747 end
4848
49- YAML . unsafe_load ( %x( gunzip -c metadata.gz) )
49+ YAML . unsafe_load ( ` gunzip -c metadata.gz` )
5050 end
5151end
5252
@@ -96,117 +96,121 @@ describe File.basename(gemfile) do
9696 describe "all platforms" do
9797 [ "lib" , "test" ] . each do |dir |
9898 it "contains every ruby file in #{ dir } /" do
99- expected = %x( git ls-files #{ dir } ) . split ( "\n " ) . grep ( /\. rb$/ ) . sort
99+ expected = ` git ls-files #{ dir } ` . split ( "\n " ) . grep ( /\. rb$/ ) . sort
100100 skip "looks like this isn't a git repository" if expected . empty?
101101 actual = gemfile_contents . select { |f | f . start_with? ( "#{ dir } /" ) } . grep ( /\. rb$/ ) . sort
102102 assert_equal ( expected , actual )
103103 end
104104 end
105105 end
106106
107- describe "ruby platform" do
108- it "depends on mini_portile2" do
109- assert ( gemspec . dependencies . find { |d | d . name == "mini_portile2" } )
110- end
107+ if gemspec . platform == Gem ::Platform ::RUBY
108+ describe "ruby platform" do
109+ it "depends on mini_portile2" do
110+ assert ( gemspec . dependencies . find { |d | d . name == "mini_portile2" } )
111+ end
111112
112- it "contains extension C and header files" do
113- assert_equal ( 6 , gemfile_contents . count { |f | File . fnmatch? ( "ext/**/*.c" , f ) } )
114- assert_equal ( 6 , gemfile_contents . count { |f | File . fnmatch? ( "ext/**/*.h" , f ) } )
115- end
113+ it "contains extension C and header files" do
114+ assert_equal ( 6 , gemfile_contents . count { |f | File . fnmatch? ( "ext/**/*.c" , f ) } )
115+ assert_equal ( 6 , gemfile_contents . count { |f | File . fnmatch? ( "ext/**/*.h" , f ) } )
116+ end
116117
117- it "includes C files in extra_rdoc_files" do
118- assert_equal ( 6 , gemspec . extra_rdoc_files . count { |f | File . fnmatch? ( "ext/**/*.c" , f ) } )
119- end
118+ it "includes C files in extra_rdoc_files" do
119+ assert_equal ( 6 , gemspec . extra_rdoc_files . count { |f | File . fnmatch? ( "ext/**/*.c" , f ) } )
120+ end
120121
121- it "contains the port files" do
122- dependencies = YAML . load_file ( File . join ( __dir__ , ".." , "dependencies.yml" ) , symbolize_names : true )
123- sqlite_tarball = File . basename ( dependencies [ :sqlite3 ] [ :files ] . first [ :url ] )
124- actual_ports = gemfile_contents . grep ( %r{^ports/} )
122+ it "contains the port files" do
123+ dependencies = YAML . load_file ( File . join ( __dir__ , ".." , "dependencies.yml" ) , symbolize_names : true )
124+ sqlite_tarball = File . basename ( dependencies [ :sqlite3 ] [ :files ] . first [ :url ] )
125+ actual_ports = gemfile_contents . grep ( %r{^ports/} )
125126
126- assert_equal ( [ "ports/archives/#{ sqlite_tarball } " ] , actual_ports )
127- end
127+ assert_equal ( [ "ports/archives/#{ sqlite_tarball } " ] , actual_ports )
128+ end
128129
129- it "contains the patch files" do
130- assert_equal ( Dir . glob ( "patches/*.patch" ) . length , gemfile_contents . count { |f | File . fnmatch? ( "patches/*" , f ) } )
131- end
130+ it "contains the patch files" do
131+ assert_equal ( Dir . glob ( "patches/*.patch" ) . length , gemfile_contents . count { |f | File . fnmatch? ( "patches/*" , f ) } )
132+ end
132133
133- it "sets metadata for msys2" do
134- refute_nil ( gemspec . metadata [ "msys2_mingw_dependencies" ] )
135- end
134+ it "sets metadata for msys2" do
135+ refute_nil ( gemspec . metadata [ "msys2_mingw_dependencies" ] )
136+ end
136137
137- it "sets required_ruby_version appropriately" do
138- all_supported_ruby_versions . each do |v |
139- assert (
140- gemspec . required_ruby_version . satisfied_by? ( Gem ::Version . new ( v ) ) ,
141- "required_ruby_version='#{ gemspec . required_ruby_version } ' should support ruby #{ v } " ,
142- )
138+ it "sets required_ruby_version appropriately" do
139+ all_supported_ruby_versions . each do |v |
140+ assert (
141+ gemspec . required_ruby_version . satisfied_by? ( Gem ::Version . new ( v ) ) ,
142+ "required_ruby_version='#{ gemspec . required_ruby_version } ' should support ruby #{ v } "
143+ )
144+ end
143145 end
144146 end
145- end if gemspec . platform == Gem :: Platform :: RUBY
147+ end
146148
147- describe "native platform" do
148- it "does not depend on mini_portile2" do
149- refute ( gemspec . dependencies . find { |d | d . name == "mini_portile2" } )
150- end
149+ if gemspec . platform . is_a? ( Gem ::Platform ) && gemspec . platform . cpu
150+ describe "native platform" do
151+ it "does not depend on mini_portile2" do
152+ refute ( gemspec . dependencies . find { |d | d . name == "mini_portile2" } )
153+ end
151154
152- it "contains extension C and header files" do
153- assert_equal ( 6 , gemfile_contents . count { |f | File . fnmatch? ( "ext/**/*.c" , f ) } )
154- assert_equal ( 6 , gemfile_contents . count { |f | File . fnmatch? ( "ext/**/*.h" , f ) } )
155- end
155+ it "contains extension C and header files" do
156+ assert_equal ( 6 , gemfile_contents . count { |f | File . fnmatch? ( "ext/**/*.c" , f ) } )
157+ assert_equal ( 6 , gemfile_contents . count { |f | File . fnmatch? ( "ext/**/*.h" , f ) } )
158+ end
156159
157- it "includes C files in extra_rdoc_files" do
158- assert_equal ( 6 , gemspec . extra_rdoc_files . count { |f | File . fnmatch? ( "ext/**/*.c" , f ) } )
159- end
160+ it "includes C files in extra_rdoc_files" do
161+ assert_equal ( 6 , gemspec . extra_rdoc_files . count { |f | File . fnmatch? ( "ext/**/*.c" , f ) } )
162+ end
160163
161- it "does not contain the port files" do
162- assert_empty ( gemfile_contents . grep ( %r{^ports/} ) )
163- end
164+ it "does not contain the port files" do
165+ assert_empty ( gemfile_contents . grep ( %r{^ports/} ) )
166+ end
164167
165- it "does not contain the patch files" do
166- assert_empty ( gemfile_contents . grep ( %r{^patches/} ) )
167- end
168+ it "does not contain the patch files" do
169+ assert_empty ( gemfile_contents . grep ( %r{^patches/} ) )
170+ end
171+
172+ it "contains expected shared library files " do
173+ platform_supported_ruby_versions . each do |version |
174+ actual = gemfile_contents . find do |p |
175+ File . fnmatch? ( "lib/sqlite3/#{ version } /sqlite3_native.{so,bundle}" , p , File ::FNM_EXTGLOB )
176+ end
177+ assert ( actual , "expected to find shared library file for ruby #{ version } " )
178+ end
168179
169- it "contains expected shared library files " do
170- platform_supported_ruby_versions . each do |version |
171180 actual = gemfile_contents . find do |p |
172- File . fnmatch? ( "lib/sqlite3/#{ version } / sqlite3_native.{so,bundle}" , p , File ::FNM_EXTGLOB )
181+ File . fnmatch? ( "lib/sqlite3/sqlite3_native.{so,bundle}" , p , File ::FNM_EXTGLOB )
173182 end
174- assert ( actual , "expected to find shared library file for ruby #{ version } " )
175- end
183+ refute ( actual , "did not expect to find shared library file in lib/sqlite3" )
176184
177- actual = gemfile_contents . find do |p |
178- File . fnmatch? ( "lib/sqlite3/sqlite3_native.{so,bundle}" , p , File ::FNM_EXTGLOB )
185+ actual = gemfile_contents . find_all do |p |
186+ File . fnmatch? ( "lib/sqlite3/**/*.{so,bundle}" , p , File ::FNM_EXTGLOB )
187+ end
188+ assert_equal (
189+ platform_supported_ruby_versions . length ,
190+ actual . length ,
191+ "did not expect extra shared library files"
192+ )
179193 end
180- refute ( actual , "did not expect to find shared library file in lib/sqlite3" )
181194
182- actual = gemfile_contents . find_all do |p |
183- File . fnmatch? ( "lib/sqlite3/**/*.{so,bundle}" , p , File ::FNM_EXTGLOB )
195+ it "sets required_ruby_version appropriately" do
196+ unsupported_versions = all_supported_ruby_versions - platform_supported_ruby_versions
197+ platform_supported_ruby_versions . each do |v |
198+ assert (
199+ gemspec . required_ruby_version . satisfied_by? ( Gem ::Version . new ( v ) ) ,
200+ "required_ruby_version='#{ gemspec . required_ruby_version } ' should support ruby #{ v } "
201+ )
202+ end
203+ unsupported_versions . each do |v |
204+ refute (
205+ gemspec . required_ruby_version . satisfied_by? ( Gem ::Version . new ( v ) ) ,
206+ "required_ruby_version='#{ gemspec . required_ruby_version } ' should not support ruby #{ v } "
207+ )
208+ end
184209 end
185- assert_equal (
186- platform_supported_ruby_versions . length ,
187- actual . length ,
188- "did not expect extra shared library files" ,
189- )
190- end
191210
192- it "sets required_ruby_version appropriately" do
193- unsupported_versions = all_supported_ruby_versions - platform_supported_ruby_versions
194- platform_supported_ruby_versions . each do |v |
195- assert (
196- gemspec . required_ruby_version . satisfied_by? ( Gem ::Version . new ( v ) ) ,
197- "required_ruby_version='#{ gemspec . required_ruby_version } ' should support ruby #{ v } " ,
198- )
211+ it "does not set metadata for msys2" do
212+ assert_nil ( gemspec . metadata [ "msys2_mingw_dependencies" ] )
199213 end
200- unsupported_versions . each do |v |
201- refute (
202- gemspec . required_ruby_version . satisfied_by? ( Gem ::Version . new ( v ) ) ,
203- "required_ruby_version='#{ gemspec . required_ruby_version } ' should not support ruby #{ v } " ,
204- )
205- end
206- end
207-
208- it "does not set metadata for msys2" do
209- assert_nil ( gemspec . metadata [ "msys2_mingw_dependencies" ] )
210214 end
211- end if gemspec . platform . is_a? ( Gem :: Platform ) && gemspec . platform . cpu
215+ end
212216end
0 commit comments