Skip to content
Permalink
Browse files

Remove trailing spaces

  • Loading branch information
mojca committed Oct 2, 2018
1 parent 39d22da commit ee6fbfdfd0aec8c5918138591b736b7337218fff
Showing with 45 additions and 45 deletions.
  1. +9 −9 src/pextlib1.0/fs-traverse.c
  2. +36 −36 src/pextlib1.0/tests/fs-traverse.tcl
@@ -19,7 +19,7 @@
* 3. Neither the name of Apple Inc. nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -100,21 +100,21 @@ FsTraverseCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Ob
}
break;
}

/* Parse remaining args */
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv_orig, "?-depth? ?-ignoreErrors? ?-tails? ?--? varname target-list body");
return TCL_ERROR;
}

varname = *objv;
++objv, --objc;

listPtr = *objv;
++objv, --objc;

body = *objv;

if ((rval = Tcl_ListObjGetElements(interp, listPtr, &lobjc, &lobjv)) == TCL_OK) {
char **entries;
char **iter;
@@ -169,9 +169,9 @@ do_traverse(Tcl_Interp *interp, int flags, char * CONST *targets, Tcl_Obj *varna
int rval = TCL_OK;
FTS *root_fts;
FTSENT *ent;

root_fts = fts_open(targets, FTS_PHYSICAL /*| FTS_COMFOLLOW */| FTS_NOCHDIR | FTS_XDEV, &do_compare);

while ((ent = fts_read(root_fts)) != NULL) {
switch (ent->fts_info) {
case FTS_D: /* directory in pre-order */
@@ -244,7 +244,7 @@ do_traverse(Tcl_Interp *interp, int flags, char * CONST *targets, Tcl_Obj *varna
if (!(flags & F_IGNORE_ERRORS)) {
Tcl_SetErrno(ent->fts_errno);
Tcl_ResetResult(interp);
Tcl_AppendResult(interp, ent->fts_path, ": ", (char *)Tcl_PosixError(interp), NULL);
Tcl_AppendResult(interp, ent->fts_path, ": ", (char *)Tcl_PosixError(interp), NULL);
fts_close(root_fts);
return TCL_ERROR;
}
@@ -5,18 +5,18 @@

proc main {pextlibname} {
global trees errorInfo

load $pextlibname

set root "/tmp/macports-pextlib-fs-traverse"

file delete -force $root

setup_trees $root

# make the directory root structure
make_root

# perform tests
set result [catch {
# Basic fs-traverse test
@@ -25,52 +25,52 @@ proc main {pextlibname} {
lappend output $file
}
check_output $output $trees(1)

# Test starting with a symlink
set output [list]
fs-traverse file $root/a/c/a {
lappend output $file
}
check_output $output $trees(sub1)

# Test starting with a slash-ended symlink
set output [list]
fs-traverse file $root/a/c/a/ {
lappend output [string map {// /} $file]
}
check_output $output $trees(sub2)

# Test -depth
set output [list]
fs-traverse -depth file $root {
lappend output $file
}
check_output $output $trees(2)

# Test multiple sources
set output [list]
fs-traverse file [list $root/a $root/b] {
lappend output $file
}
check_output $output $trees(3)

# Test multiple sources with -depth
set output [list]
fs-traverse -depth file [list $root/a $root/b] {
lappend output $file
}
check_output $output $trees(4)

# Error raised for traversing directory that does not exist
if {![catch {fs-traverse file $root/does_not_exist {}}]} {
error "fs-traverse did not raise an error for a missing directory"
}

# Test -ignoreErrors
if {[catch {fs-traverse -ignoreErrors file $root/does_not_exist {}}]} {
error "fs-traverse raised an error despite -ignoreErrors"
}

# Test -ignoreErrors with multiple sources, make sure it still gets the sources after the error
if {[catch {
set output [list]
@@ -81,7 +81,7 @@ proc main {pextlibname} {
}]} {
error "fs-traverse raised an error despite -ignoreErrors"
}

# Test skipping parts of the tree
set output [list]
fs-traverse file $root {
@@ -91,29 +91,29 @@ proc main {pextlibname} {
lappend output $file
}
check_output $output $trees(5)

# Test -tails option
set output [list]
fs-traverse -tails file $root {
lappend output $file
}
check_output $output $trees(6) $root

# Test -tails option with trailing slash
set output [list]
fs-traverse -tails file $root/ {
lappend output $file
}
check_output $output $trees(6) $root

# Test -tails option with multiple paths
# It should error out
if {![catch {
fs-traverse -tails file {$root/a $root/b} {}
}]} {
error "fs-traverse did not error when using multiple paths with -tails"
}

# Test cutting the traversal short
set output [list]
fs-traverse file $root {
@@ -122,7 +122,7 @@ proc main {pextlibname} {
break
}
}

# Test using an array variable as varname
# It should error out
if {![catch {
@@ -131,32 +131,32 @@ proc main {pextlibname} {
}]} {
error "fs-traverse did not error when setting the variable"
}

# Same test with -ignoreErrors
if {[catch {
array set aryvar {}
fs-traverse -ignoreErrors aryvar $root {}
}]} {
error "fs-traverse errored out when setting the variable despite -ignoreErrors"
}

# Test using a malformed target list
if {![catch {fs-traverse file "$root/a \{$root/b" {}}]} {
error "fs-traverse did not error with malformed target list"
}

# Test again with -ignoreErrors - this is the one case where it should still error
if {![catch {fs-traverse -ignoreErrors file "$root/a \{$root/b" {}}]} {
error "fs-traverse did not error with malformed target list using -ignoreErrors"
}

# Test wacky variable name called -depth
set output [list]
fs-traverse -- -depth $root {
lappend output ${-depth}
}
check_output $output $trees(1)

# NOTE: This should be the last test performed, as it modifies the file tree
# Test to make sure deleting files during traversal works as expected
set output [list]
@@ -171,10 +171,10 @@ proc main {pextlibname} {
check_output $output $trees(5)
} errMsg]
set savedInfo $errorInfo

# Clean up
file delete -force $root

# Re-raise error if one occurred in the test block
if {$result} {
error $errMsg $savedInfo
@@ -222,9 +222,9 @@ proc make_root {} {

proc setup_trees {root} {
global trees

array set trees {}

set trees(1) "
$root directory
$root/a directory
@@ -252,19 +252,19 @@ proc setup_trees {root} {
$root/b/c/b file
$root/b/c/c file
"

set trees(sub1) "
$root/a/c/a {link ../d}
"

set trees(sub2) "
$root/a/c/a/ {link ../d}
$root/a/c/a/a file
$root/a/c/a/b {link ../../b/a}
$root/a/c/a/c directory
$root/a/c/a/d file
"

set trees(2) "
$root/a/a file
$root/a/b file
@@ -292,7 +292,7 @@ proc setup_trees {root} {
$root/b directory
$root directory
"

set trees(3) "
$root/a directory
$root/a/a file
@@ -319,7 +319,7 @@ proc setup_trees {root} {
$root/b/c/b file
$root/b/c/c file
"

set trees(4) "
$root/a/a file
$root/a/b file
@@ -346,7 +346,7 @@ proc setup_trees {root} {
$root/b/c directory
$root/b directory
"

set trees(5) "
$root directory
$root/b directory
@@ -355,7 +355,7 @@ proc setup_trees {root} {
$root/b/c/b file
$root/b/c/c file
"

set trees(6) "
. directory
a directory

0 comments on commit ee6fbfd

Please sign in to comment.
You can’t perform that action at this time.