/ Check-in [799d5f09]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Enhance checking of prerequisites in the vsixtest tool.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | vsixTest
Files: files | file ages | folders
SHA1: 799d5f09ed058898167e43bd9c8d1bf8c5df23ba
User & Date: mistachkin 2016-02-25 23:22:26
Context
2016-02-25
23:25
Add tool for smoke-testing the UWP VSIX package. check-in: d27f32c6 user: mistachkin tags: trunk
23:22
Enhance checking of prerequisites in the vsixtest tool. Closed-Leaf check-in: 799d5f09 user: mistachkin tags: vsixTest
08:02
Improve readability and logging of the vsixtest script. check-in: 4fe7c4e9 user: mistachkin tags: vsixTest
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to vsixtest/vsixtest.tcl.

    40     40   
    41     41     puts stdout "usage:\
    42     42   [file tail [info nameofexecutable]]\
    43     43   [file tail [info script]] \[vsixFile\]"
    44     44   
    45     45     exit 1
    46     46   }
           47  +
           48  +proc isWindows {} {
           49  +  #
           50  +  # NOTE: Returns non-zero only when running on Windows.
           51  +  #
           52  +  return [expr {[info exists ::tcl_platform(platform)] && \
           53  +      $::tcl_platform(platform) eq "windows"}]
           54  +}
           55  +
           56  +proc isAdministrator {} {
           57  +  #
           58  +  # NOTE: Returns non-zero only when running as "elevated administrator".
           59  +  #
           60  +  if {[isWindows]} then {
           61  +    if {[catch {exec -- whoami /groups} groups] == 0} then {
           62  +      set groups [string map [list \r\n \n] $groups]
           63  +
           64  +      foreach group [split $groups \n] {
           65  +        #
           66  +        # NOTE: Match this group line against the "well-known" SID for
           67  +        #       the "Administrators" group on Windows.
           68  +        #
           69  +        if {[regexp -- {\sS-1-5-32-544\s} $group]} then {
           70  +          #
           71  +          # NOTE: Match this group line against the attributes column
           72  +          #       sub-value that should be present when running with
           73  +          #       elevated administrator credentials.
           74  +          #
           75  +          if {[regexp -- {\sEnabled group(?:,|\s)} $group]} then {
           76  +            return true
           77  +          }
           78  +        }
           79  +      }
           80  +    }
           81  +  }
           82  +
           83  +  return false
           84  +}
    47     85   
    48     86   proc getEnvironmentVariable { name } {
    49     87     #
    50     88     # NOTE: Returns the value of the specified environment variable or an empty
    51     89     #       string for environment variables that do not exist in the current
    52     90     #       process environment.
    53     91     #
................................................................................
   152    190   # NOTE: This is the entry point for this script.
   153    191   #
   154    192   set script [file normalize [info script]]
   155    193   
   156    194   if {[string length $script] == 0} then {
   157    195     fail "script file currently being evaluated is unknown" true
   158    196   }
          197  +
          198  +if {![isWindows]} then {
          199  +  fail "this tool only works properly on Windows"
          200  +}
          201  +
          202  +if {![isAdministrator]} then {
          203  +  fail "this tool must run with \"elevated administrator\" privileges"
          204  +}
   159    205   
   160    206   set path [file normalize [file dirname $script]]
   161    207   set argc [llength $argv]; if {$argc > 1} then {fail "" true}
   162    208   
   163    209   if {$argc == 1} then {
   164    210     set vsixFileName [lindex $argv 0]
   165    211   } else {