ReplayTests.swift 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import Foundation
  2. enum ReplayTests {
  3. /// Flag to enable replay tests.
  4. ///
  5. /// These test are only used for debugging so normally they should be disabled. But
  6. /// if you're debugging the oref-swift functions they are extremely useful. To enable them
  7. /// add these lines to your ConfigOverride.xcconfig file:
  8. /// ```
  9. /// ENABLE_REPLAY_TESTS = YES
  10. /// ```
  11. static var enabled: Bool {
  12. let env = ProcessInfo.processInfo.environment
  13. if env["ENABLE_REPLAY_TESTS"] == "YES" {
  14. return true
  15. }
  16. let bundle = Bundle(for: BundleReference.self)
  17. return bundle.object(forInfoDictionaryKey: "EnableReplayTests") as? String == "YES"
  18. }
  19. /// The offset for pagination of replay input files
  20. ///
  21. /// Set this offset using an environment variable or the ConfigOverride.xcconfig file.
  22. /// For this change to take effect you must also set the length
  23. /// ```
  24. /// HTTP_FILES_OFFSET = 2000
  25. /// ```
  26. static var filesOffset: Int? {
  27. let env = ProcessInfo.processInfo.environment
  28. if let offset = env["HTTP_FILES_OFFSET"].flatMap({ Int($0) }) {
  29. return offset
  30. }
  31. let bundle = Bundle(for: BundleReference.self)
  32. let offsetString = bundle.object(forInfoDictionaryKey: "HttpFilesOffset") as? String
  33. return offsetString.flatMap { Int($0) }
  34. }
  35. /// Length for pagination of replay input files
  36. ///
  37. /// Set this length using an environment variable or the ConfigOverride.xcconfig file.
  38. /// ```
  39. /// HTTP_FILES_LENGTH = 3500
  40. /// ```
  41. static var filesLength: Int? {
  42. let env = ProcessInfo.processInfo.environment
  43. if let length = env["HTTP_FILES_LENGTH"].flatMap({ Int($0) }) {
  44. return length
  45. }
  46. let bundle = Bundle(for: BundleReference.self)
  47. let lengthString = bundle.object(forInfoDictionaryKey: "HttpFilesLength") as? String
  48. return lengthString.flatMap { Int($0) }
  49. }
  50. /// Timezone to use for replay tests.
  51. ///
  52. /// This is used to filter replay test files by timezone. If not set, it defaults to "America/Los_Angeles".
  53. /// To set it, add this line to your ConfigOverride.xcconfig file:
  54. /// ```
  55. /// REPLAY_TEST_TIMEZONE = Europe/Berlin
  56. /// ```
  57. static var timezone: String {
  58. let env = ProcessInfo.processInfo.environment
  59. if let timezone = env["REPLAY_TEST_TIMEZONE"], !timezone.isEmpty {
  60. return timezone
  61. }
  62. let bundle = Bundle(for: BundleReference.self)
  63. return bundle.object(forInfoDictionaryKey: "ReplayTestTimezone") as? String ?? "America/Los_Angeles"
  64. }
  65. }