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 the reinplace warning an error #232

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/port1.0/portutil.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ proc reinplace {args} {
close $tmpfd

if {!$quiet && ![catch {exec -ignorestderr cmp -s $file $tmpfile}]} {
ui_warn "[format [msgcat::mc "reinplace %1\$s didn't change anything in %2\$s"] $pattern $file]"
return -code error "[format [msgcat::mc "reinplace %1\$s didn't change anything in %2\$s"] $pattern $file]"
}

set attributes [file attributes $file]
Expand Down
24 changes: 24 additions & 0 deletions src/port1.0/tests/portutil.test
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,30 @@ test reinplace {
}
close $f

# If no changes are made, nothing is printed out. This should
# generate an error.
if {![catch {reinplace s/notfound/test/1 $file}]} {
return "FAIL: reinplace with no changes should generate an error."
}
catch {set f [open $file r]}
set cont [read -nonewline $f]
if { $cont != "" } {
return "FAIL: reinplace with no changes should not alter file."
}
close $f

# If no changes are made, nothing is printed out. This should
# not generate an error due to -q.
if {[catch {reinplace -q s/notfound/test/1 $file}]} {
return "FAIL: reinplace (-q) with no changes should not generate an error."
}
catch {set f [open $file r]}
set cont [read -nonewline $f]
if { $cont != "" } {
return "FAIL: reinplace (-q) with no changes should not alter file."
}
close $f

return "Reinplace successful."

} -cleanup {
Expand Down