source [file dirname [info script]]/testing.tcl

needs cmd file
needs cmd exec

cd [file dirname [info script]]

file delete -force tmp
file mkdir tmp
file copy testio.in tmp/file
file mkdir tmp/dir


test mkdir-1.1 "Simple dir" {
	file mkdir tmp/abc
	file isdir tmp/abc
} {1}

test mkdir-1.2 "Create missing parents" {
	file mkdir tmp/def/ghi/jkl
	file isdir tmp/def/ghi/jkl
} {1}

test mkdir-1.3 "Existing dir" {
	file mkdir tmp/dir
	file isdir tmp/dir
} {1}

test mkdir-1.4 "Child of existing dir" {
	file mkdir tmp/dir/child
	file isdir tmp/dir/child
} {1}

test mkdir-1.5 "Create dir over existing file" {
	list [catch {file mkdir tmp/file} msg] [file isdir tmp/file]
} {1 0}

test mkdir-1.6 "Create dir below existing file" {
	list [catch {file mkdir tmp/file/dir} msg] [file isdir tmp/file/dir]
} {1 0}

test mkdir-1.8 "Multiple dirs" {
	file mkdir tmp/1 tmp/2 tmp/3
	list [file isdir tmp/1] [file isdir tmp/2] [file isdir tmp/3]
} {1 1 1}

test mkdir-1.7 "Stop on failure" {
	catch {file mkdir tmp/4 tmp/file tmp/5}
	list [file isdir tmp/4] [file isdir tmp/5]
} {1 0}

test rmdir-2.0 "Remove existing dir" {
	file delete tmp/1
	file isdir tmp/1
} {0}

test rmdir-2.1 "Remove missing dir" {
	file delete tmp/1
} {}

test rmdir-2.2 "Remove non-empty dir" {
	catch {file delete tmp/def}
} {1}

file delete -force tmp

testreport
