diff options
| author | Andrew Janke | 2016-07-05 08:45:17 -0400 |
|---|---|---|
| committer | GitHub | 2016-07-05 08:45:17 -0400 |
| commit | f518f57bd8c9ff864dc23911fac59f10995302b9 (patch) | |
| tree | 7e2e4eb6ab977329bf47679f48de56113831a4b4 /Library/Homebrew/test/test_utils.rb | |
| parent | 1b1bf56733e1ede7d414c8a5ef1e04dabc645455 (diff) | |
| download | brew-f518f57bd8c9ff864dc23911fac59f10995302b9.tar.bz2 | |
gist-logs: truncate log files to be gist-friendly (#279)
Truncates each log file to about 1 MB. This avoids upload and
download errors with the gists, and respects GitHub's suggested
size limits.
Diffstat (limited to 'Library/Homebrew/test/test_utils.rb')
| -rw-r--r-- | Library/Homebrew/test/test_utils.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_utils.rb b/Library/Homebrew/test/test_utils.rb index b0caa6a2d..816032804 100644 --- a/Library/Homebrew/test/test_utils.rb +++ b/Library/Homebrew/test/test_utils.rb @@ -210,4 +210,17 @@ class UtilTests < Homebrew::TestCase assert_equal "1,000", number_readable(1_000) assert_equal "1,000,000", number_readable(1_000_000) end + + def test_truncate_text_to_approximate_size + glue = "\n[...snip...]\n" # hard-coded copy from truncate_text_to_approximate_size + n = 20 + long_s = "x" * 40 + s = truncate_text_to_approximate_size(long_s, n) + assert_equal n, s.length + assert_match(/^x+#{Regexp.escape(glue)}x+$/, s) + s = truncate_text_to_approximate_size(long_s, n, :front_weight => 0.0) + assert_equal glue + ("x" * (n - glue.length)), s + s = truncate_text_to_approximate_size(long_s, n, :front_weight => 1.0) + assert_equal(("x" * (n - glue.length)) + glue, s) + end end |
