Pārlūkot izejas kodu

pod_lib_lint.rb improvements (#3418)

* Make sure `pod_lib_lint.rb` fails when lint fails.

* `pod_lib_lint.rb` comment  social_media_url in the podspec.

* Typo

* pod_lib_lint.rb: exit with pod lint status.

* Code style.

* Travis: fix FirebaseInstallations lint parameters.

* Avoid dirtying the workspace when linting. (#3421)

* Proper type for `pod_lint_status`
Maksym Malyhin 6 gadi atpakaļ
vecāks
revīzija
77b7c6e1b6
2 mainītis faili ar 35 papildinājumiem un 7 dzēšanām
  1. 5 5
      .travis.yml
  2. 30 2
      scripts/pod_lib_lint.rb

+ 5 - 5
.travis.yml

@@ -403,13 +403,13 @@ jobs:
       before_install:
         - ./scripts/if_changed.sh ./scripts/install_prereqs.sh
       script:
-        - travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseInstallations.podspec --platforms=ios,tvos --ignore-local-specs=FirebaseInstanceID.podspec
+        - travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseInstallations.podspec --platforms=ios,tvos --ignore-local-podspecs=FirebaseInstanceID.podspec
         # TODO: Fix FBLPromises warnings for macOS.
-        - travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseInstallations.podspec --platforms=macos --allow-warnings --ignore-local-specs=FirebaseInstanceID.podspec
-        - travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseInstallations.podspec --use-libraries --ignore-local-specs=FirebaseInstanceID.podspec
-        - travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseInstallations.podspec --use-modular-headers --platforms=ios,tvos --ignore-local-specs=FirebaseInstanceID.podspec
+        - travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseInstallations.podspec --platforms=macos --allow-warnings --ignore-local-podspecs=FirebaseInstanceID.podspec
+        - travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseInstallations.podspec --use-libraries --ignore-local-podspecs=FirebaseInstanceID.podspec
+        - travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseInstallations.podspec --use-modular-headers --platforms=ios,tvos --ignore-local-podspecs=FirebaseInstanceID.podspec
         # TODO: Fix FBLPromises warnings for macOS.
-        - travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseInstallations.podspec --use-modular-headers --platforms=macos --allow-warnings --ignore-local-specs=FirebaseInstanceID.podspec
+        - travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseInstallations.podspec --use-modular-headers --platforms=macos --allow-warnings --ignore-local-podspecs=FirebaseInstanceID.podspec
 
   allow_failures:
     # Run fuzz tests only on cron jobs.

+ 30 - 2
scripts/pod_lib_lint.rb

@@ -60,8 +60,8 @@ def main(args)
     end
   end
 
-  # Figure out which dependencies are local
   podspec_file = pod_args[0]
+  # Figure out which dependencies are local
   deps = find_local_deps(podspec_file, ignore_local_podspecs.to_set)
   arg = make_include_podspecs(deps)
   command.push(arg) if arg
@@ -70,8 +70,12 @@ def main(args)
   puts command.join(' ')
 
   # Run the lib lint command in a thread.
+  pod_lint_status = 1
   t = Thread.new do
-    system(*command)
+    with_removed_social_media_url(podspec_file) do
+      system(*command)
+      pod_lint_status = $?.exitstatus
+    end
   end
 
   # Print every minute since linting can run for >10m without output.
@@ -83,6 +87,8 @@ def main(args)
       puts "Still working, running for #{number_of_times_checked / 60}min."
     end
   end
+
+  exit(pod_lint_status)
 end
 
 # Loads all the specs (inclusing subspecs) from the given podspec file.
@@ -162,4 +168,26 @@ def trace(*args)
   STDERR.puts(args.join(' '))
 end
 
+# Edits the given podspec file to remove the social_media_url, yields, then
+# restores the file to its original condition.  Validating of the social URL
+# can be very flaky (see #3416). Remove it from spec to let the actual tests
+# pass.
+def with_removed_social_media_url(spec)
+  podspec_content = File.read(spec)
+  updated_podspec_content =
+      podspec_content.gsub("s.social_media_url = ", "# s.social_media_url = ")
+  write_file(spec, updated_podspec_content)
+  yield
+
+ensure
+  write_file(spec, podspec_content)
+end
+
+# Writes the text in +contents+ to the file named by +filename+.
+def write_file(filename, contents)
+  File.open(filename, "w") do |file|
+    file.write(contents)
+  end
+end
+
 main(ARGV)