# This file tests the filesystem and vfs internals.
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 2002 Vincent Darley.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import -force ::tcltest::*
}

makeFile "test file" gorp.file
makeDirectory dir.file
makeFile "test file in directory" [file join dir.file inside.file]

# It would be good to be able to make these work on MacOS too.
# If we added 'file link from to' we could easily do that.
catch {exec ln -s gorp.file link.file}
catch {exec ln -s inside.file dir.file/linkinside.file}
catch {exec ln -s dir.file dir.link}

test filesystem-1.0 {link normalisation} {unixOnly} {
   string equal [file normalize gorp.file] [file normalize link.file]
} {0}

test filesystem-1.1 {link normalisation} {unixOnly} {
   string equal [file normalize dir.file] [file normalize dir.link]
} {0}

test filesystem-1.2 {link normalisation} {unixOnly} {
   string equal [file normalize gorp.file/foo] [file normalize link.file/foo]
} {1}

test filesystem-1.3 {link normalisation} {unixOnly} {
   string equal [file normalize dir.file/foo] [file normalize dir.link/foo]
} {1}

test filesystem-1.4 {link normalisation} {unixOnly} {
   string equal [file normalize dir.file/inside.file] [file normalize dir.link/inside.file]
} {1}

test filesystem-1.5 {link normalisation} {unixOnly} {
   string equal [file normalize dir.file/linkinside.file] [file normalize dir.file/linkinside.file]
} {1}

test filesystem-1.6 {link normalisation} {unixOnly} {
   string equal [file normalize dir.file/linkinside.file] [file normalize dir.link/inside.file]
} {0}

test filesystem-1.7 {link normalisation} {unixOnly} {
   string equal [file normalize dir.link/linkinside.file/foo] [file normalize dir.file/inside.file/foo]
} {1}

test filesystem-1.8 {link normalisation} {unixOnly} {
   string equal [file normalize dir.file/linkinside.filefoo] [file normalize dir.link/inside.filefoo]
} {0}

file delete -force gorp.file link.file dir.file dir.link

test filesystem-2.0 {new native path} {
   foreach f [lsort [glob -nocomplain /usr/bin/c*]] {
       catch {file readlink $f}
   }
   # if we reach here we've succeeded.
   expr 1
} {1}













