Skip to content
This repository

Avoid hardcoded newline tests #72

Closed
wants to merge 1 commit into from

3 participants

Luis Lavena Tay Ray Chuan Jim Weirich
Luis Lavena

Add new_line helper to avoid usage of hardcoded newline evaluation in
tests.

Correct tests that presented this issue.

All tests pass:

ruby 1.9.3dev (2011-09-02 revision 33165) [i386-mingw32]
437 tests, 1250 assertions, 0 failures, 0 errors, 0 skips
Luis Lavena luislavena Avoid hardcoded newline tests
Add `new_line` helper to avoid usage of hardcoded newline evaluation in
tests.

Correct tests that presented this issue.
b9234a1
Tay Ray Chuan

@nobu Actually, I think we should just strip away the newline character(s) with String.chomp. The tests are not concerned with EOLs.

@luislavena you missed another \n instance just in the next test, test_egrep_with_error.

Tay Ray Chuan

@luislavena here's my take: #90

Tay Ray Chuan

This should be closed in light of #92.

Jim Weirich
Owner

egrep no longer opens files in binary mode, so this pull request was closed.

Thanks for the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Sep 02, 2011
Luis Lavena luislavena Avoid hardcoded newline tests
Add `new_line` helper to avoid usage of hardcoded newline evaluation in
tests.

Correct tests that presented this issue.
b9234a1
This page is out of date. Refresh to see the latest.

Showing 2 changed files with 6 additions and 2 deletions. Show diff stats Hide diff stats

  1. +4 0 test/helper.rb
  2. +2 2 test/test_rake_file_list.rb
4 test/helper.rb
@@ -81,6 +81,10 @@ def ignore_deprecations
81 81 Rake.application.options.ignore_deprecate = false
82 82 end
83 83
  84 + def new_line
  85 + Rake.application.windows? ? "\r\n" : "\n"
  86 + end
  87 +
84 88 def rake_system_dir
85 89 @system_dir = 'system'
86 90
4 test/test_rake_file_list.rb
@@ -342,7 +342,7 @@ def test_egrep_with_output
342 342 files.egrep(/XYZZY/)
343 343 end
344 344
345   - assert_equal "xyzzy.txt:2:XYZZY\n", out
  345 + assert_equal "xyzzy.txt:2:XYZZY#{new_line}", out
346 346 end
347 347
348 348 def test_egrep_with_block
@@ -353,7 +353,7 @@ def test_egrep_with_block
353 353 found = [fn, ln, line]
354 354 end
355 355
356   - assert_equal ["xyzzy.txt", 2, "XYZZY\n"], found
  356 + assert_equal ["xyzzy.txt", 2, "XYZZY#{new_line}"], found
357 357 end
358 358
359 359 def test_egrep_with_error

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.