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

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

Overview
Comment:Enhancements to test suite file and directory handling.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | testSuiteFiles
Files: files | file ages | folders
SHA1: f5a10b02b194123448c82f8d94f4b536c6c41357
User & Date: mistachkin 2020-06-01 23:36:43
Context
2020-06-01
23:36
Enhancements to test suite file and directory handling. Leaf check-in: f5a10b02b1 user: mistachkin tags: testSuiteFiles
22:50
Enhancements to the NuGet packaging automation. check-in: f33042c238 user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Tests/basic.eagle.

1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
....
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
      ![file isdirectory $directory(base)]} then {
    error [appendArgs "base directory \"" $directory(base) "\" is invalid"]
  }

  set directory(data) [file join $directory(base) \
      [appendArgs sqlite .data. [pid]]]

  file mkdir $directory(data)

  tputs $test_channel [appendArgs "---- created data directory \"" \
      $directory(data) \"\n]

  set directory(temp) [file join $directory(base) \
      [appendArgs sqlite .temp. [pid]]]

  file mkdir $directory(temp)

  tputs $test_channel [appendArgs "---- created temporary directory \"" \
      $directory(temp) \"\n]

  proc threadStart {} {
    while {$::i < 1000} {
      set ::found(temp) [expr \
................................................................................
    object invoke -flags +NonPublic System.Data.SQLite.UnsafeNativeMethods \
        sqlite3_win32_set_directory 2 null
  }

  if {[info exists directory(data)] && \
      [file exists $directory(data)] && \
      [file isdirectory $directory(data)]} then {
    file delete -recursive -force $directory(data)
  }

  if {[info exists directory(temp)] && \
      [file exists $directory(temp)] && \
      [file isdirectory $directory(temp)]} then {
    file delete -recursive -force $directory(temp)
  }

  if {[info exists t] && [cleanupThread $t]} then {
    unset t
  }

  catch {object removecallback threadStart}







|







|







 







|





|







1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
....
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
      ![file isdirectory $directory(base)]} then {
    error [appendArgs "base directory \"" $directory(base) "\" is invalid"]
  }

  set directory(data) [file join $directory(base) \
      [appendArgs sqlite .data. [pid]]]

  createDirectory $directory(data)

  tputs $test_channel [appendArgs "---- created data directory \"" \
      $directory(data) \"\n]

  set directory(temp) [file join $directory(base) \
      [appendArgs sqlite .temp. [pid]]]

  createDirectory $directory(temp)

  tputs $test_channel [appendArgs "---- created temporary directory \"" \
      $directory(temp) \"\n]

  proc threadStart {} {
    while {$::i < 1000} {
      set ::found(temp) [expr \
................................................................................
    object invoke -flags +NonPublic System.Data.SQLite.UnsafeNativeMethods \
        sqlite3_win32_set_directory 2 null
  }

  if {[info exists directory(data)] && \
      [file exists $directory(data)] && \
      [file isdirectory $directory(data)]} then {
    deleteDirectoryTree $directory(data)
  }

  if {[info exists directory(temp)] && \
      [file exists $directory(temp)] && \
      [file isdirectory $directory(temp)]} then {
    deleteDirectoryTree $directory(temp)
  }

  if {[info exists t] && [cleanupThread $t]} then {
    unset t
  }

  catch {object removecallback threadStart}

Changes to Tests/tkt-0e48e80333.eagle.

103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
...
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
  tlog $output
  tlog "\n---- END STDOUT OUTPUT\n"

  set code
} -cleanup {
  cleanupDb tkt-0e48e80333-1.1.db

  catch {file delete $scriptFileName}
  catch {file delete $configFileName}

  catch {info previouspid true}

  unset -nocomplain code output error scriptFileName configFileName

  restoreMdaConfigEnvironment
  restoreEagleShellEnvironment
................................................................................
  tputs $test_channel [appendArgs \
      "---- executed a total of " $count " queries\n"]

  list $code $error
} -cleanup {
  cleanupDb $fileName

  catch {file delete $scriptFileName}
  catch {file delete $configFileName}

  catch {info previouspid true}

  unset -nocomplain dummy count
  unset -nocomplain code output error scriptFileName configFileName
  unset -nocomplain db fileName








|
|







 







|
|







103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
...
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
  tlog $output
  tlog "\n---- END STDOUT OUTPUT\n"

  set code
} -cleanup {
  cleanupDb tkt-0e48e80333-1.1.db

  catch {deleteFile $scriptFileName}
  catch {deleteFile $configFileName}

  catch {info previouspid true}

  unset -nocomplain code output error scriptFileName configFileName

  restoreMdaConfigEnvironment
  restoreEagleShellEnvironment
................................................................................
  tputs $test_channel [appendArgs \
      "---- executed a total of " $count " queries\n"]

  list $code $error
} -cleanup {
  cleanupDb $fileName

  catch {deleteFile $scriptFileName}
  catch {deleteFile $configFileName}

  catch {info previouspid true}

  unset -nocomplain dummy count
  unset -nocomplain code output error scriptFileName configFileName
  unset -nocomplain db fileName

Changes to Tests/tkt-448d663d11.eagle.

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
..
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
...
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
...
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
...
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
{delete}}

###############################################################################

runTest {test tkt-448d663d11-1.2 {missing journal mode, WAL db} -body {
  set fileName tkt-448d663d11-1.2.db
  file copy -force $walDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName "" "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite file_wal.db} -result {wal}}

###############################################################################

runTest {test tkt-448d663d11-1.3 {missing journal mode, non-WAL db} -body {
  set fileName tkt-448d663d11-1.3.db
  file copy -force $nonWalDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName "" "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
................................................................................
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
{delete}}

###############################################################################

runTest {test tkt-448d663d11-1.5 {'Default' journal mode, WAL db} -body {
  set fileName tkt-448d663d11-1.5.db
  file copy -force $walDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName Default "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite file_wal.db} -result {wal}}

###############################################################################

runTest {test tkt-448d663d11-1.6 {'Default' journal mode, non-WAL db} -body {
  set fileName tkt-448d663d11-1.6.db
  file copy -force $nonWalDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName Default "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
................................................................................
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
{delete}}

###############################################################################

runTest {test tkt-448d663d11-1.8 {'Delete' journal mode, WAL db} -body {
  set fileName tkt-448d663d11-1.8.db
  file copy -force $walDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName Delete "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite file_wal.db} -result {delete}}

###############################################################################

runTest {test tkt-448d663d11-1.9 {'Delete' journal mode, non-WAL db} -body {
  set fileName tkt-448d663d11-1.9.db
  file copy -force $nonWalDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName Delete "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
................................................................................
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
{wal}}

###############################################################################

runTest {test tkt-448d663d11-1.15 {'Wal' journal mode, non-WAL db} -body {
  set fileName tkt-448d663d11-1.15.db
  file copy -force $nonWalDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName Wal "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite file_nonWal.db} -result {wal}}

###############################################################################

runTest {test tkt-448d663d11-1.16 {'Wal' journal mode, WAL db} -body {
  set fileName tkt-448d663d11-1.16.db
  file copy -force $walDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName Wal "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
................................................................................
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
{delete}}

###############################################################################

runTest {test tkt-448d663d11-1.18 {'Bad' journal mode, non-WAL db} -body {
  set fileName tkt-448d663d11-1.18.db
  file copy -force $nonWalDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName Bad "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite file_nonWal.db} -result {delete}}

###############################################################################

runTest {test tkt-448d663d11-1.19 {'Bad' journal mode, WAL db} -body {
  set fileName tkt-448d663d11-1.19.db
  file copy -force $walDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName Bad "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\







|













|







 







|













|







 







|













|







 







|













|







 







|













|







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
..
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
...
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
...
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
...
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
{delete}}

###############################################################################

runTest {test tkt-448d663d11-1.2 {missing journal mode, WAL db} -body {
  set fileName tkt-448d663d11-1.2.db
  forceCopyFile $walDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName "" "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite file_wal.db} -result {wal}}

###############################################################################

runTest {test tkt-448d663d11-1.3 {missing journal mode, non-WAL db} -body {
  set fileName tkt-448d663d11-1.3.db
  forceCopyFile $nonWalDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName "" "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
................................................................................
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
{delete}}

###############################################################################

runTest {test tkt-448d663d11-1.5 {'Default' journal mode, WAL db} -body {
  set fileName tkt-448d663d11-1.5.db
  forceCopyFile $walDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName Default "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite file_wal.db} -result {wal}}

###############################################################################

runTest {test tkt-448d663d11-1.6 {'Default' journal mode, non-WAL db} -body {
  set fileName tkt-448d663d11-1.6.db
  forceCopyFile $nonWalDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName Default "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
................................................................................
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
{delete}}

###############################################################################

runTest {test tkt-448d663d11-1.8 {'Delete' journal mode, WAL db} -body {
  set fileName tkt-448d663d11-1.8.db
  forceCopyFile $walDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName Delete "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite file_wal.db} -result {delete}}

###############################################################################

runTest {test tkt-448d663d11-1.9 {'Delete' journal mode, non-WAL db} -body {
  set fileName tkt-448d663d11-1.9.db
  forceCopyFile $nonWalDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName Delete "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
................................................................................
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
{wal}}

###############################################################################

runTest {test tkt-448d663d11-1.15 {'Wal' journal mode, non-WAL db} -body {
  set fileName tkt-448d663d11-1.15.db
  forceCopyFile $nonWalDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName Wal "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite file_nonWal.db} -result {wal}}

###############################################################################

runTest {test tkt-448d663d11-1.16 {'Wal' journal mode, WAL db} -body {
  set fileName tkt-448d663d11-1.16.db
  forceCopyFile $walDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName Wal "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
................................................................................
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
{delete}}

###############################################################################

runTest {test tkt-448d663d11-1.18 {'Bad' journal mode, non-WAL db} -body {
  set fileName tkt-448d663d11-1.18.db
  forceCopyFile $nonWalDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName Bad "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite file_nonWal.db} -result {delete}}

###############################################################################

runTest {test tkt-448d663d11-1.19 {'Bad' journal mode, WAL db} -body {
  set fileName tkt-448d663d11-1.19.db
  forceCopyFile $walDbFile [file join [getDatabaseDirectory] $fileName]
  setupDb $fileName Bad "" "" "" "" true false
  sql execute -execute scalar $db "PRAGMA journal_mode;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\

Changes to Tests/tkt-d4728aecb7.eagle.

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
      System.Data.SQLite.UnsafeNativeMethods GetSettingValue d472_2 null]]

  lappend result [string map [list \\ /] [object invoke -flags +NonPublic \
      System.Data.SQLite.UnsafeNativeMethods GetSettingValue d472_3 null]]

  set result
} -cleanup {
  catch {file delete $fileName}

  unset -nocomplain result fileName

  moveSystemDataSQLiteDllConfig true
} -isolationLevel AppDomain -constraints {eagle command.object dotNet\
compile.ISOLATED_INTERPRETERS System.Data.SQLite\
defineConstant.System.Data.SQLite.USE_INTEROP_DLL} -result [list [appendArgs \







|







108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
      System.Data.SQLite.UnsafeNativeMethods GetSettingValue d472_2 null]]

  lappend result [string map [list \\ /] [object invoke -flags +NonPublic \
      System.Data.SQLite.UnsafeNativeMethods GetSettingValue d472_3 null]]

  set result
} -cleanup {
  catch {deleteFile $fileName}

  unset -nocomplain result fileName

  moveSystemDataSQLiteDllConfig true
} -isolationLevel AppDomain -constraints {eagle command.object dotNet\
compile.ISOLATED_INTERPRETERS System.Data.SQLite\
defineConstant.System.Data.SQLite.USE_INTEROP_DLL} -result [list [appendArgs \

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

1636
1637
1638
1639
1640
1641
1642






































































































































1643
1644
1645
1646
1647
1648
1649
....
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
....
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
....
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
....
6241
6242
6243
6244
6245
6246
6247







6248
6249
6250
6251
6252
6253
6254
            {[info body changeNativeRuntimeOption]}

        catch {
          changeNativeRuntimeOption [hasRuntimeOption native]
        }
      } [getTestOverridesPreamble [list path test_channel]] $suffix]]]
    }






































































































































 
    proc tryCopyExternalFile {
            fileName {platform ""} {newFileName ""} {verbose true} } {
      set sourceFileName [getExternalFileName $fileName]

      if {![file exists $sourceFileName]} then {
        if {$verbose} then {
................................................................................
        set targetFileName [getBinaryFileName $fileName $platform]
      }

      set targetDirectory [file dirname $targetFileName]

      if {[catch {
        if {![file exists $targetDirectory]} then {
          file mkdir $targetDirectory
        }

        file copy -force $sourceFileName $targetFileName
      }] == 0} then {
        tputs $::test_channel [appendArgs \
            "---- copied external file from \"" $sourceFileName "\" to \"" \
            $targetFileName \"\n]
      } else {
        tputs $::test_channel [appendArgs \
            "---- failed to copy external file from \"" $sourceFileName \
................................................................................
            $fileName $managedOnly $platform]
      }

      set targetDirectory [file dirname $targetFileName]

      if {[catch {
        if {![file exists $targetDirectory]} then {
          file mkdir $targetDirectory
        }

        file copy -force $sourceFileName $targetFileName
      }] == 0} then {
        tputs $::test_channel [appendArgs \
            "---- copied binary file from \"" $sourceFileName "\" to \"" \
            $targetFileName \"\n]
      } else {
        tputs $::test_channel [appendArgs \
            "---- failed to copy binary file from \"" $sourceFileName \
................................................................................
        set targetFileName [getBinaryFileName $fileName $platform]
      }

      set targetDirectory [file dirname $targetFileName]

      if {[catch {
        if {![file exists $targetDirectory]} then {
          file mkdir $targetDirectory
        }

        file copy -force $sourceFileName $targetFileName
      }] == 0} then {
        tputs $::test_channel [appendArgs \
            "---- copied build file from \"" $sourceFileName "\" to \"" \
            $targetFileName \"\n]
      } else {
        tputs $::test_channel [appendArgs \
            "---- failed to copy build file from \"" $sourceFileName \
................................................................................
        #
        # NOTE: If necessary, disable shared-cache mode now.
        #
        if {[hasRuntimeOption sharedCache]} then {
          enableSharedCache $::test_channel false
        }








        #
        # NOTE: Restore the previously saved environment variables that we
        #       changed for the test suite.
        #
        restoreEnvironmentVariables \
            [list Initialize_SQLiteLog] ::testSuiteSavedEnv
      }







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







 







|


|







 







|


|







 







|


|







 







>
>
>
>
>
>
>







1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
....
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
....
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
....
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
....
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
            {[info body changeNativeRuntimeOption]}

        catch {
          changeNativeRuntimeOption [hasRuntimeOption native]
        }
      } [getTestOverridesPreamble [list path test_channel]] $suffix]]]
    }
 
    proc deleteFile { fileName } {
      if {![info exists ::no(deleteFile)]} then {
        file delete $fileName
        unset -nocomplain ::test_copied_file_names($fileName)

        if {[array size ::test_copied_file_names] == 0} then {
          unset -nocomplain ::test_copied_file_names
        }
      }
    }
 
    proc deleteDirectory { directory } {
      if {![info exists ::no(deleteDirectory)]} then {
        file rmdir $directory
        unset -nocomplain ::test_created_directories($directory)

        if {[array size ::test_created_directories] == 0} then {
          unset -nocomplain ::test_created_directories
        }
      }
    }
 
    proc deleteDirectoryTree { directory } {
      if {![info exists ::no(deleteDirectoryTree)]} then {
        file delete -recursive -force $directory
        unset -nocomplain ::test_created_directories($directory)

        if {[array size ::test_created_directories] == 0} then {
          unset -nocomplain ::test_created_directories
        }
      }
    }
 
    proc createDirectory { directory } {
      if {![info exists ::no(createDirectory)]} then {
        if {[file exists $directory]} then {
          error [appendArgs \
              "directory \"" $directory "\" already exists"]
        }

        file mkdir $directory
        set ::test_created_directories($directory) [clock seconds]
      }
    }
 
    proc copyFile { sourceFileName targetFileName } {
      if {![info exists ::no(copyFile)]} then {
        file copy $sourceFileName $targetFileName
        set ::test_copied_file_names($targetFileName) $sourceFileName
      }
    }
 
    proc forceCopyFile { sourceFileName targetFileName } {
      if {![info exists ::no(forceCopyFile)]} then {
        file copy -force $sourceFileName $targetFileName
        set ::test_copied_file_names($targetFileName) $sourceFileName
      }
    }
 
    proc compareDirectories {directory1 directory2} {
      if {$directory1 eq $directory2} then {
        return 0; # equal
      }

      set parts1 [file split $directory1]
      set count1 [llength $parts1]

      set parts2 [file split $directory2]
      set count2 [llength $parts2]

      if {$count1 != $count2} then {
        return [expr {sign($count1 - $count2)}]
      }

      foreach part1 $parts1 part2 $parts2 {
        set compare [string compare $part1 $part2]

        if {$compare != 0} then {
          return $compare
        }
      }

      return 0; # equal
    }
 
    proc cleanupCreatedDirectories { channel {quiet false} } {
      if {[array exists ::test_created_directories]} then {
        foreach directory [lsort -decreasing -command \
            compareDirectories [array names ::test_created_directories]] {
          if {[catch {deleteDirectory $directory} error] == 0} then {
            if {!$quiet} then {
              tputs $channel [appendArgs \
                  "---- test directory \"" $directory "\" deleted\n"]
            }
          } else {
            if {!$quiet} then {
              tputs $channel [appendArgs \
                  "==== WARNING: failed to delete test directory \"" \
                  $directory "\" during cleanup, error: " \n\t \
                  $error \n]
            }
          }
        }
      } else {
        if {!$quiet} then {
          tputs $channel "---- no created directories to cleanup\n"
        }
      }
    }
 
    proc cleanupCopiedFiles { channel {quiet false} } {
      if {[array exists ::test_copied_file_names]} then {
        foreach fileName [array names ::test_copied_file_names] {
          if {[catch {deleteFile $fileName} error] == 0} then {
            if {!$quiet} then {
              tputs $channel [appendArgs \
                  "---- test file \"" $fileName "\" deleted\n"]
            }
          } else {
            if {!$quiet} then {
              tputs $channel [appendArgs \
                  "==== WARNING: failed to delete test file \"" \
                  $fileName "\" during cleanup, error: " \n\t \
                  $error \n]
            }
          }
        }
      } else {
        if {!$quiet} then {
          tputs $channel "---- no copied files to cleanup\n"
        }
      }
    }
 
    proc tryCopyExternalFile {
            fileName {platform ""} {newFileName ""} {verbose true} } {
      set sourceFileName [getExternalFileName $fileName]

      if {![file exists $sourceFileName]} then {
        if {$verbose} then {
................................................................................
        set targetFileName [getBinaryFileName $fileName $platform]
      }

      set targetDirectory [file dirname $targetFileName]

      if {[catch {
        if {![file exists $targetDirectory]} then {
          createDirectory $targetDirectory
        }

        forceCopyFile $sourceFileName $targetFileName
      }] == 0} then {
        tputs $::test_channel [appendArgs \
            "---- copied external file from \"" $sourceFileName "\" to \"" \
            $targetFileName \"\n]
      } else {
        tputs $::test_channel [appendArgs \
            "---- failed to copy external file from \"" $sourceFileName \
................................................................................
            $fileName $managedOnly $platform]
      }

      set targetDirectory [file dirname $targetFileName]

      if {[catch {
        if {![file exists $targetDirectory]} then {
          createDirectory $targetDirectory
        }

        forceCopyFile $sourceFileName $targetFileName
      }] == 0} then {
        tputs $::test_channel [appendArgs \
            "---- copied binary file from \"" $sourceFileName "\" to \"" \
            $targetFileName \"\n]
      } else {
        tputs $::test_channel [appendArgs \
            "---- failed to copy binary file from \"" $sourceFileName \
................................................................................
        set targetFileName [getBinaryFileName $fileName $platform]
      }

      set targetDirectory [file dirname $targetFileName]

      if {[catch {
        if {![file exists $targetDirectory]} then {
          createDirectory $targetDirectory
        }

        forceCopyFile $sourceFileName $targetFileName
      }] == 0} then {
        tputs $::test_channel [appendArgs \
            "---- copied build file from \"" $sourceFileName "\" to \"" \
            $targetFileName \"\n]
      } else {
        tputs $::test_channel [appendArgs \
            "---- failed to copy build file from \"" $sourceFileName \
................................................................................
        #
        # NOTE: If necessary, disable shared-cache mode now.
        #
        if {[hasRuntimeOption sharedCache]} then {
          enableSharedCache $::test_channel false
        }

        #
        # NOTE: Cleanup any test files and directories that were copied or
        #       created during the test run.
        #
        cleanupCopiedFiles $::test_channel
        cleanupCreatedDirectories $::test_channel

        #
        # NOTE: Restore the previously saved environment variables that we
        #       changed for the test suite.
        #
        restoreEnvironmentVariables \
            [list Initialize_SQLiteLog] ::testSuiteSavedEnv
      }