System.Data.SQLite

Check-in [7d3501975e]
Login

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

Overview
Comment:Centralize save/restore handling (in the test suite) for environment variables. Stop leaking a variable in tests data-1.79 and data-1.80.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7d3501975ee234d571f512dec4606e5513067548
User & Date: mistachkin 2016-03-21 16:15:25.413
Context
2016-03-21
21:46
Preliminary work on getting the test suite to run under Mono on Unix. check-in: 085a9f8b8f user: mistachkin tags: trunk
16:18
Add preliminary test for ticket [53633bbe39]. check-in: a5653a0674 user: mistachkin tags: tkt-53633bbe39
16:15
Centralize save/restore handling (in the test suite) for environment variables. Stop leaking a variable in tests data-1.79 and data-1.80. check-in: 7d3501975e user: mistachkin tags: trunk
2016-03-11
00:35
Update scheduled release date for 1.0.100.0. check-in: 03b5dd0462 user: mistachkin tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to Tests/basic.eagle.
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
61
62
63
64
65
66
67
68

package require System.Data.SQLite.Test
runSQLiteTestPrologue
runSQLiteTestFilesPrologue

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

proc saveSQLiteConnectionEnvironment {} {
  foreach name [list \
      DefaultFlags_SQLiteConnection No_SQLiteConnectionNewParser] {
    #
    # NOTE: 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 ARE NOT changed by this
    #       procedure.
    #
    if {[uplevel 1 [list info exists env($name)]]} then {
      uplevel 1 [list set savedEnv($name) [uplevel 1 [list set env($name)]]]
    } else {
      uplevel 1 [list unset -nocomplain savedEnv($name)]
    }
  }
}

proc restoreSQLiteConnectionEnvironment {} {
  foreach name [list \
      DefaultFlags_SQLiteConnection No_SQLiteConnectionNewParser] {
    #
    # NOTE: Does the saved environment variable exist?  If so, restore the
    #       saved value and then unset it; otherwise, make sure the live
    #       environment variable does not exist either (i.e. it was not set
    #       to begin with).  Both the saved and live environment variables
    #       ARE changed by this procedure.
    #
    if {[uplevel 1 [list info exists savedEnv($name)]]} then {
      uplevel 1 [list set env($name) [uplevel 1 [list set savedEnv($name)]]]
      uplevel 1 [list unset -nocomplain savedEnv($name)]
    } else {
      uplevel 1 [list unset -nocomplain env($name)]
    }
  }
}

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

runTest {test data-1.1 {unit tests from the 'test' project} -setup {
  cleanupFile [file join [file dirname $testExeFile] Test.db3]
  set fileName [file join [getDatabaseDirectory] data-1.1.db]
} -body {
  set output ""

  set code [catch {







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







17
18
19
20
21
22
23






































24
25
26
27
28
29
30

package require System.Data.SQLite.Test
runSQLiteTestPrologue
runSQLiteTestFilesPrologue

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







































runTest {test data-1.1 {unit tests from the 'test' project} -setup {
  cleanupFile [file join [file dirname $testExeFile] Test.db3]
  set fileName [file join [getDatabaseDirectory] data-1.1.db]
} -body {
  set output ""

  set code [catch {
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
  unset -nocomplain connection db fileName savedEnv
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {{DetectTextAffinity, DetectStringType}\
{DetectTextAffinity, DetectStringType}}}

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

rename restoreSQLiteConnectionEnvironment ""
rename saveSQLiteConnectionEnvironment ""

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

runTest {test data-1.70 {LINQ w/String.Substring Method} -body {
  #
  # NOTE: Re-copy the reference database file used for this unit test to the
  #       build directory in case it has been changed by a previous test run.
  #
  file copy -force $northwindEfDbFile \
      [file join [getBuildDirectory] [file tail $northwindEfDbFile]]







<
<
<
<
<







3163
3164
3165
3166
3167
3168
3169





3170
3171
3172
3173
3174
3175
3176
  unset -nocomplain connection db fileName savedEnv
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {{DetectTextAffinity, DetectStringType}\
{DetectTextAffinity, DetectStringType}}}

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






runTest {test data-1.70 {LINQ w/String.Substring Method} -body {
  #
  # NOTE: Re-copy the reference database file used for this unit test to the
  #       build directory in case it has been changed by a previous test run.
  #
  file copy -force $northwindEfDbFile \
      [file join [getBuildDirectory] [file tail $northwindEfDbFile]]
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
  }

  sql execute -execute reader -format list -datetimeformat \
      [getDateTimeFormat] $db "SELECT x, y FROM t1;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain db fileName
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
{1 {2038-01-20 00:00:00}}}

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

runTest {test data-1.80 {page size using PRAGMA} -setup {







|







4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
  }

  sql execute -execute reader -format list -datetimeformat \
      [getDateTimeFormat] $db "SELECT x, y FROM t1;"
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain result db fileName
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
{1 {2038-01-20 00:00:00}}}

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

runTest {test data-1.80 {page size using PRAGMA} -setup {
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106

  lappend result [sql execute -execute scalar $db {
    PRAGMA page_size;
  }]
} -cleanup {
  cleanupDb $fileName

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

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

reportSQLiteResources $test_channel

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

runSQLiteTestFilesEpilogue
runSQLiteTestEpilogue
runTestEpilogue







|













4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063

  lappend result [sql execute -execute scalar $db {
    PRAGMA page_size;
  }]
} -cleanup {
  cleanupDb $fileName

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

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

reportSQLiteResources $test_channel

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

runSQLiteTestFilesEpilogue
runSQLiteTestEpilogue
runTestEpilogue
Changes to Tests/tkt-3c00ec5b52.eagle.
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
61
62
63
64
65
66
67
###############################################################################

package require System.Data.SQLite.Test
runSQLiteTestPrologue

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

proc saveSQLiteConvertEnvironment {} {
  foreach name [list \
      Use_SQLiteConvert_DefaultDbType Use_SQLiteConvert_DefaultTypeName] {
    #
    # NOTE: 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 ARE NOT changed by this
    #       procedure.
    #
    if {[uplevel 1 [list info exists env($name)]]} then {
      uplevel 1 [list set savedEnv($name) [uplevel 1 [list set env($name)]]]
    } else {
      uplevel 1 [list unset -nocomplain savedEnv($name)]
    }
  }
}

proc restoreSQLiteConvertEnvironment {} {
  foreach name [list \
      Use_SQLiteConvert_DefaultDbType Use_SQLiteConvert_DefaultTypeName] {
    #
    # NOTE: Does the saved environment variable exist?  If so, restore the
    #       saved value and then unset it; otherwise, make sure the live
    #       environment variable does not exist either (i.e. it was not set
    #       to begin with).  Both the saved and live environment variables
    #       ARE changed by this procedure.
    #
    if {[uplevel 1 [list info exists savedEnv($name)]]} then {
      uplevel 1 [list set env($name) [uplevel 1 [list set savedEnv($name)]]]
      uplevel 1 [list unset -nocomplain savedEnv($name)]
    } else {
      uplevel 1 [list unset -nocomplain env($name)]
    }
  }
}

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

runTest {test tkt-3c00ec5b52-1.1 {default types, via connection} -setup {
  setupDb [set fileName tkt-3c00ec5b52-1.1.db] "" "" "" UseConnectionTypes \
      "DefaultDbType=String;DefaultTypeName=TEXT;"
} -body {
  set connection [getDbConnection]
  set result [list]








<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







16
17
18
19
20
21
22






































23
24
25
26
27
28
29
###############################################################################

package require System.Data.SQLite.Test
runSQLiteTestPrologue

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







































runTest {test tkt-3c00ec5b52-1.1 {default types, via connection} -setup {
  setupDb [set fileName tkt-3c00ec5b52-1.1.db] "" "" "" UseConnectionTypes \
      "DefaultDbType=String;DefaultTypeName=TEXT;"
} -body {
  set connection [getDbConnection]
  set result [list]

197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
  cleanupDb $fileName
  restoreSQLiteConvertEnvironment

  unset -nocomplain db fileName savedEnv
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {{t1 sqlite_autoindex_t1_1 True}}}

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

rename restoreSQLiteConvertEnvironment ""
rename saveSQLiteConvertEnvironment ""

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

runSQLiteTestEpilogue
runTestEpilogue







<
<
<
<
<




159
160
161
162
163
164
165





166
167
168
169
  cleanupDb $fileName
  restoreSQLiteConvertEnvironment

  unset -nocomplain db fileName savedEnv
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {{t1 sqlite_autoindex_t1_1 True}}}






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

runSQLiteTestEpilogue
runTestEpilogue
Changes to lib/System.Data.SQLite/common.eagle.
2447
2448
2449
2450
2451
2452
2453
































2454
2455
2456
2457
2458
2459
2460
      # NOTE: This is self-cleaning.  If no saved environment variables now
      #       exist, remove the array.
      #
      if {[array size savedEnv] == 0} then {
        unset -nocomplain savedEnv
      }
    }

































    proc setupDbInterruptCallback { channel log } {
      tputs $channel "---- setting up debugger interrupt callback... "

      if {[catch {
        saveEnvironmentVariables [list \
            quietFindInterpreterTestPath quietSetupInterpreterTestPath]







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







2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
      # NOTE: This is self-cleaning.  If no saved environment variables now
      #       exist, remove the array.
      #
      if {[array size savedEnv] == 0} then {
        unset -nocomplain savedEnv
      }
    }

    proc saveSQLiteConnectionEnvironment {} {
      upvar 1 savedEnv savedEnv

      saveEnvironmentVariables [list \
          DefaultFlags_SQLiteConnection No_SQLiteConnectionNewParser] \
          savedEnv
    }

    proc restoreSQLiteConnectionEnvironment {} {
      upvar 1 savedEnv savedEnv

      restoreEnvironmentVariables [list \
          DefaultFlags_SQLiteConnection No_SQLiteConnectionNewParser] \
          savedEnv
    }

    proc saveSQLiteConvertEnvironment {} {
      upvar 1 savedEnv savedEnv

      saveEnvironmentVariables [list \
          Use_SQLiteConvert_DefaultDbType Use_SQLiteConvert_DefaultTypeName] \
          savedEnv
    }

    proc restoreSQLiteConvertEnvironment {} {
      upvar 1 savedEnv savedEnv

      restoreEnvironmentVariables [list \
          Use_SQLiteConvert_DefaultDbType Use_SQLiteConvert_DefaultTypeName] \
          savedEnv
    }

    proc setupDbInterruptCallback { channel log } {
      tputs $channel "---- setting up debugger interrupt callback... "

      if {[catch {
        saveEnvironmentVariables [list \
            quietFindInterpreterTestPath quietSetupInterpreterTestPath]