diff --git a/src/DrawResources/TestCommands.tcl b/src/DrawResources/TestCommands.tcl index ccc0727437..f75c88d7a5 100644 --- a/src/DrawResources/TestCommands.tcl +++ b/src/DrawResources/TestCommands.tcl @@ -478,7 +478,7 @@ help testdiff { Where dir1 and dir2 are directories containing logs of two test runs. Allowed options are: -save filename: save resulting log in specified file (default name is - \$dir1/diff-\$dir2.log); HTML log is saved with same name + /diff-.log); HTML log is saved with same name and extension .html -status {same|ok|all}: filter cases for comparing by their status: same - only cases with same status are compared (default) @@ -574,7 +574,7 @@ help testfile { Unless the file is already in the repository, tries to load it, reports the recognized file format, file size, number of faces and edges in the - loaded shape (if any), and makes snapshot (in the subdirectory tmp). + loaded shape (if any), and makes snapshot (in the temporary directory). Finally it advises whether the file should be put to public section of the repository. } @@ -702,18 +702,19 @@ proc testfile {filelist} { # add stats puts "$file: $format size=[expr $size / 1024] KiB, nbfaces=$faces, nbedges=$edges -> $dir" - file mkdir tmp/$dir + set tmpdir [_get_temp_dir] + file mkdir $tmpdir/$dir # make snapshot pload AISV uplevel vdisplay a uplevel vfit uplevel vzfit - uplevel vdump tmp/$dir/[file rootname [file tail $file]].png + uplevel vdump $tmpdir/$dir/[file rootname [file tail $file]].png set has_images t } if { $has_images } { - puts "Snapshots are saved in subdirectory tmp" + puts "Snapshots are saved in subdirectory [_get_temp_dir]" } } @@ -879,10 +880,18 @@ proc _run_test {scriptsdir group gridname casefile echo} { # evaluate test case if [catch { + # set variables identifying test case uplevel set casename [file tail $casefile] uplevel set groupname $group uplevel set gridname $gridname + # set variables for saving of images if not yet set + if { ! [uplevel info exists imagedir] } { + uplevel set imagedir [_get_temp_dir] + uplevel set test_image \$casename + } + + # execute test scripts if { [file exists $scriptsdir/$group/begin] } { puts "Executing $scriptsdir/$group/begin..."; flush stdout uplevel source $scriptsdir/$group/begin @@ -1879,3 +1888,43 @@ proc load_data_file {file format shape} { default { error "Cannot read $format file $file" } } } + +# procedure to get name of temporary directory, +# ensuring it is existing and writeable +proc _get_temp_dir {} { + global env + + # check typical environment variables + foreach var {TempDir Temp Tmp} { + # check different case + foreach name [list [string toupper $var] $var [string tolower $var]] { + if { [info exists env($name)] && [file isdirectory $env($name)] && + [file writable $env($name)] } { + return [regsub -all {\\} $env($name) /] + } + } + } + + # check platform-specific locations + set fallback tmp + if { "$tcl_platform(platform)" == "windows" } { + set paths "c:/TEMP c:/TMP /TEMP /TMP" + if { [info exists env(HOMEDRIVE)] && [info exists env(HOMEPATH)] } { + set fallback [regsub -all {\\} "$env(HOMEDRIVE)$(HOMEPATH)/tmp" /] + } + } else { + set paths "/tmp /var/tmp /usr/tmp" + if { [info exists env(HOME)] } { + set fallback "$env(HOME)/tmp" + } + } + foreach dir $paths { + if { [file isdirectory $dir] && [file iswritable $dir] } { + return $dir + } + } + + # fallback case: use subdir /tmp of home or current dir + file mkdir $fallback + return $fallback +} diff --git a/tests/bugs/xde/bug23193 b/tests/bugs/xde/bug23193 index c68c540ea4..777be09178 100755 --- a/tests/bugs/xde/bug23193 +++ b/tests/bugs/xde/bug23193 @@ -11,21 +11,11 @@ if {[array get env os_type] != ""} { set os $env(os_type) } -if { [string compare $os "windows"] == 0 } { - set aFile C:/temp/bug23193_sample.stl -} else { - set aFile /tmp/bug23193_sample.stl -} - -file delete ${aFile} -if { [file exists ${aFile}] } { - puts "Error : There is old ${aFile} file" -} +set aFile $imagedir/bug23193_sample.stl vinit stepread [locate_data_file bug23193_sample.stp] a * writestl a_1 ${aFile} 0 -catch {exec chmod 777 ${aFile}} meshfromstl m1 ${aFile} meshcolors m1 elem2 1 diff --git a/tests/bugs/xde/bug23384 b/tests/bugs/xde/bug23384 index ea35d4831f..7e2f4c6019 100644 --- a/tests/bugs/xde/bug23384 +++ b/tests/bugs/xde/bug23384 @@ -17,17 +17,12 @@ regexp {Total number of labels for shapes in the document += +([-0-9.+eE]+)} $in regexp {Number of labels with name += +([-0-9.+eE]+)} $info1 full nbname param write.stepcaf.subshapes.name 1 -if { [string compare $os "windows"] == 0 } { - WriteStep doc C:/temp/doc_subshapes.stp -} else { - WriteStep doc /tmp/doc_subshapes.stp -} + + WriteStep doc $imagedir/doc_subshapes.stp + param read.stepcaf.subshapes.name 1 -if { [string compare $os "windows"] == 0 } { - ReadStep after_doc C:/temp/doc_subshapes.stp -} else { - ReadStep after_doc /tmp/doc_subshapes.stp -} + + ReadStep after_doc $imagedir/doc_subshapes.stp set info2 [XStat after_doc] regexp {level N 0 +: +([-0-9.+eE]+)} $info2 full l0_1