System.Data.SQLite
Check-in [b23c0f4675]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Enhance database file cleanup semantics in the test suite infrastructure.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b23c0f4675f0f17afc280fcb36d4186bdb1f7f0e
User & Date: mistachkin 2017-12-01 00:00:57
Context
2017-12-04
16:32
Minor correction to the 'data-1.81' test cleanup. check-in: 16d05f978b user: mistachkin tags: trunk
2017-12-01
00:00
Enhance database file cleanup semantics in the test suite infrastructure. check-in: b23c0f4675 user: mistachkin tags: trunk
2017-11-30
23:59
Cleanup the database file for test 'tkt-0e48e80333-1.1'. check-in: bf8c54d97e user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to lib/System.Data.SQLite/common.eagle.

2934
2935
2936
2937
2938
2939
2940
2941

2942


2943
2944
2945
2946
2947
2948
2949















































2950
2951
2952
2953
2954
2955
2956
2957
2958


2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977

2978
2979
2980
2981
2982
2983
2984
      #       database files are stored in the temporary directory.
      #
      if {!$isMemory && $qualify} then {
        set fileName [file join [getDatabaseDirectory] [file tail $fileName]]
      }

      #
      # NOTE: Check if the file still exists.

      #


      if {!$isMemory && $delete && [file exists $fileName]} then {
        #
        # NOTE: Skip deleting database files if somebody sets the global
        #       variable to prevent it.
        #
        if {![info exists ::no(cleanupDbFile)]} then {
          #















































          # NOTE: Attempt to delete the test database file now.
          #
          if {[set code [catch {file delete $fileName} error]]} then {
            #
            # NOTE: We somehow failed to delete the file, report why.
            #
            tputs $::test_channel [appendArgs \
                "==== WARNING: failed to delete database file \"" $fileName \
                "\" during cleanup, error: " \n\t $error \n]


          }
        } else {
          #
          # NOTE: Show that we skipped deleting the file.
          #
          set code 0

          tputs $::test_channel [appendArgs \
              "==== WARNING: skipped deleting database file \"" $fileName \
              "\" during cleanup\n"]
        }
      } else {
        #
        # NOTE: The file does not exist, success!
        #
        set code 0
      }

      return $code

    }
 
    proc saveEnvironmentVariables { names {varName ""} } {
      #
      # NOTE: For each name, does the live environment variable exist?  If
      #       so, save the value for later; otherwise, make sure the saved
      #       value does not exist either.  The live environment variables







|
>

>
>







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


|






>
>





<
<




<
<
<
<
<


<
>







2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015


3016
3017
3018
3019





3020
3021

3022
3023
3024
3025
3026
3027
3028
3029
      #       database files are stored in the temporary directory.
      #
      if {!$isMemory && $qualify} then {
        set fileName [file join [getDatabaseDirectory] [file tail $fileName]]
      }

      #
      # NOTE: Check if the file still exists; initially, assume all files will
      #       be deleted successfully, if necessary.
      #
      set success true

      if {!$isMemory && $delete && [file exists $fileName]} then {
        #
        # NOTE: Skip deleting database files if somebody sets the global
        #       variable to prevent it.
        #
        if {![info exists ::no(cleanupDbFile)]} then {
          #
          # NOTE: Attempt to delete the test WAL file, if any, now.
          #
          set walFileName [appendArgs $fileName -wal]

          if {[file exists $walFileName]} then {
            #
            # NOTE: If there is a WAL file, it should be zero bytes at this
            #       point.
            #
            if {[set size [file size $walFileName]] == 0} then {
              #
              # NOTE: We somehow failed to delete the WAL file, report why.
              #
              if {[catch {file delete $walFileName} error]} then {
                tputs $::test_channel [appendArgs \
                    "==== WARNING: failed to delete WAL file \"" $walFileName \
                    "\" during cleanup, error: " \n\t $error \n]

                set success false
              }
            } else {
              tputs $::test_channel [appendArgs \
                  "==== WARNING: WAL file \"" $walFileName "\" is " $size \
                  " bytes in size, skipping all file deletions...\n"]

              return 1; # error
            }
          }

          #
          # NOTE: Attempt to delete the test SHM file, if any, now.
          #
          set shmFileName [appendArgs $fileName -shm]

          if {[file exists $shmFileName] && \
              [catch {file delete $shmFileName} error]} then {
            #
            # NOTE: We somehow failed to delete the SHM file, report why.
            #
            tputs $::test_channel [appendArgs \
                "==== WARNING: failed to delete SHM file \"" $shmFileName \
                "\" during cleanup, error: " \n\t $error \n]

            set success false
          }

          #
          # NOTE: Attempt to delete the test database file now.
          #
          if {[catch {file delete $fileName} error]} then {
            #
            # NOTE: We somehow failed to delete the file, report why.
            #
            tputs $::test_channel [appendArgs \
                "==== WARNING: failed to delete database file \"" $fileName \
                "\" during cleanup, error: " \n\t $error \n]

            set success false
          }
        } else {
          #
          # NOTE: Show that we skipped deleting the file.
          #


          tputs $::test_channel [appendArgs \
              "==== WARNING: skipped deleting database file \"" $fileName \
              "\" during cleanup\n"]
        }





      }


      return [expr {$success ? 0 : 1}]
    }
 
    proc saveEnvironmentVariables { names {varName ""} } {
      #
      # NOTE: For each name, does the live environment variable exist?  If
      #       so, save the value for later; otherwise, make sure the saved
      #       value does not exist either.  The live environment variables