Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make compress test stable #2899

Merged
merged 2 commits into from
Mar 19, 2020
Merged

Make compress test stable #2899

merged 2 commits into from
Mar 19, 2020

Commits on Mar 18, 2020

  1. Remove useless wait

    Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
    ganmacs committed Mar 18, 2020
    Configuration menu
    Copy the full SHA
    5923fca View commit details
    Browse the repository at this point in the history
  2. it cannot compare gziped string

    Making gzip's header uses time so it doesn't return the same value.
    https://github.com/ruby/ruby/blob/afd23ed0491b9df0b6a1753a2f66cd3f80428930/ext/zlib/zlib.c#L2520
    
    ```rb
    require 'zlib'
    require 'stringio'
    
    def compress(data, **kwargs)
      output_io = kwargs[:output_io]
      io = output_io || StringIO.new
      Zlib::GzipWriter.wrap(io, Zlib::DEFAULT_COMPRESSION, Zlib::FILTERED) do |gz|
        gz.write data
      end
      output_io || io.string
    end
    
    @src = 'text data for compressing' * 5
    v = compress(@src)
    
    sleep 2                         # needed
    
    io = StringIO.new
    a = compress(@src, output_io: io)
    v1 = a.string
    if v != v1
      p v
      p v1
    end
    
    ```
    
    Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
    ganmacs committed Mar 18, 2020
    Configuration menu
    Copy the full SHA
    5a24a7a View commit details
    Browse the repository at this point in the history