From: Ben Elliston Date: Wed, 16 Mar 2016 06:51:26 +0000 (+1100) Subject: This reverts commit 4d344f712298364c836038b641625b3407db2fc3. The GCC X-Git-Tag: upstream/1.6.2~142 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cef9e5b99eb29a942ecd6493fa3008d0f6afb9df;p=platform%2Fupstream%2Fdejagnu.git This reverts commit 4d344f712298364c836038b641625b3407db2fc3. The GCC testsuite still uses diff. 2016-03-15 Ben Elliston * lib/utils.exp (diff): Remove proc. * doc/ref.xml: Update documentation. * doc/dejagnu.texi: Regenerate. * NEWS: Update. --- diff --git a/ChangeLog b/ChangeLog index 0bddd16..125f3d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2016-03-16 Ben Elliston + + Revert this change (the GCC testsuite uses diff): + + 2016-03-15 Ben Elliston + + * lib/utils.exp (diff): Remove proc. + * doc/ref.xml: Update documentation. + * doc/dejagnu.texi: Regenerate. + * NEWS: Update. + 2016-03-15 Ben Elliston * testsuite/runtest.all/options.exp: Properly clean up log files diff --git a/NEWS b/NEWS index 3cedf64..1d3f672 100644 --- a/NEWS +++ b/NEWS @@ -10,8 +10,8 @@ Changes since 1.5.3: 2 if an exception is raised by the Tcl interpreter. 3. runtest now exits with the standard exit codes of programs that are terminated by the SIGINT, SIGTERM and SIGQUIT signals. -4. The user-visible utility procedures `absolute', `psource', `slay' - and `diff' have been removed. If a testsuite uses any of these +4. The user-visible utility procedures `absolute', `psource' and + `slay' have been removed. If a testsuite uses any of these procedures, a copy of the procedure should be made and placed in the lib directory of the testsuite. 5. Support was added for testing the D compiler. diff --git a/doc/dejagnu.texi b/doc/dejagnu.texi index c0c80ba..99dd8f1 100644 --- a/doc/dejagnu.texi +++ b/doc/dejagnu.texi @@ -5414,6 +5414,7 @@ tool, and its version number. * Grep Procedure: grep procedure. * Prune Procedure: prune procedure. * Runtest_file_p Procedure: runtest_file_p procedure. +* Diff Procedure: diff procedure. * Setenv Procedure: setenv procedure. * unsetenv Procedure: unsetenv procedure. * Getenv Procedure: getenv procedure. @@ -5543,7 +5544,7 @@ the next release of DejaGnu. If a testsuite uses this procedure, a copy of the procedure should be made and placed in the lib directory of the testsuite. -@node runtest_file_p procedure, setenv procedure, prune procedure, Utility Procedures +@node runtest_file_p procedure, diff procedure, prune procedure, Utility Procedures @subsubsection Runtest_file_p Procedure Search @emph{runtest}s for @@ -5576,7 +5577,30 @@ The list of patterns to compare against. The test case filename. @end table -@node setenv procedure, unsetenv procedure, runtest_file_p procedure, Utility Procedures +@node diff procedure, setenv procedure, runtest_file_p procedure, Utility Procedures +@subsubsection Diff Procedure + +Compares the two files and returns a @emph{1} if +they match, or a @emph{0} if they don't. If +@code{verbose} is set, then it'll print the differences to +the screen. + +@quotation + +@t{@b{diff}(@i{file_1} +@i{file_2});} +@end quotation + +@table @asis + +@item @code{file_1} +The first file to compare. + +@item @code{file_2} +The second file to compare. +@end table + +@node setenv procedure, unsetenv procedure, diff procedure, Utility Procedures @subsubsection Setenv Procedure Sets the environment variable @emph{var} to the diff --git a/doc/ref.xml b/doc/ref.xml index 0276334..05013ae 100644 --- a/doc/ref.xml +++ b/doc/ref.xml @@ -3620,6 +3620,33 @@ + + Diff Procedure + + Compares the two files and returns a 1 if + they match, or a 0 if they don't. If + verbose is set, then it'll print the differences to + the screen. + + + + diff + file_1 + file_2 + + + + + file_1 + The first file to compare. + + + file_2 + The second file to compare. + + + + Setenv Procedure diff --git a/lib/utils.exp b/lib/utils.exp index 8db12b8..505ad18 100644 --- a/lib/utils.exp +++ b/lib/utils.exp @@ -250,6 +250,75 @@ proc runtest_file_p { runtests testcase } { } +# Compares two files line-by-line +# returns 1 it the files match, +# returns 0 if there was a file error, +# returns -1 if they didn't match. +# +proc diff { file_1 file_2 } { + set eof -1 + set differences 0 + + if {[file exists ${file_1}]} { + set file_a [open ${file_1} r] + fconfigure $file_a -encoding binary + } else { + warning "${file_1} doesn't exist" + return 0 + } + + if {[file exists ${file_2}]} { + set file_b [open ${file_2} r] + fconfigure $file_b -encoding binary + } else { + warning "${file_2} doesn't exist" + return 0 + } + + verbose "# Diff'ing: ${file_1} ${file_2}" 1 + + set list_a "" + while { [gets ${file_a} line] != ${eof} } { + if {[regexp "^#.*$" ${line}]} { + continue + } else { + lappend list_a ${line} + } + } + close ${file_a} + + set list_b "" + while { [gets ${file_b} line] != ${eof} } { + if {[regexp "^#.*$" ${line}]} { + continue + } else { + lappend list_b ${line} + } + } + close ${file_b} + for { set i 0 } { $i < [llength $list_a] } { incr i } { + set line_a [lindex ${list_a} ${i}] + set line_b [lindex ${list_b} ${i}] + + if {[string compare ${line_a} ${line_b}]} { + verbose -log "line #${i}" 2 + verbose -log "\< ${line_a}" 2 + verbose -log "\> ${line_b}" 2 + set differences -1 + } + } + + if { $differences == -1 || [llength ${list_a}] != [llength ${list_b}] } { + verbose "Files not the same" 2 + set differences -1 + } else { + verbose "Files are the same" 2 + set differences 1 + } + return ${differences} +} + +# # Set an environment variable # proc setenv { var val } {