Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F7097659
D821.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D821.diff
View Options
diff --git a/Tech.tcl b/Tech.tcl
--- a/Tech.tcl
+++ b/Tech.tcl
@@ -80,12 +80,26 @@
return 0
}
+proc should_log_tcl_command {arg} {
+ set noLogMatches {
+ "*sql*connect*"
+ "genpass *"
+ }
+ foreach noLogMatch $noLogMatches {
+ if {[string match $noLogMatch $arg]} {
+ return 0
+ }
+ }
+
+ return 1
+}
+
#.tcl with tech.log logging
proc dcc:tcl {handle idx arg} {
#Logs every .tcl commands, except sql connect
#You should add here any line with password.
catch {
- if ![string match "*sql*connect*" $arg] {
+ if [should_log_tcl_command $arg] {
log tech $handle $arg
}
}
diff --git a/tests/Tech.test b/tests/Tech.test
new file mode 100644
--- /dev/null
+++ b/tests/Tech.test
@@ -0,0 +1,36 @@
+package require tcltest
+namespace import ::tcltest::*
+
+###
+### Init
+###
+
+# Tested code
+source init.tcl
+source $dir/Tech.tcl
+
+###
+### Tests
+###
+
+test should_log_tcl_command_for_legit_command {} -body {
+ should_log_tcl_command "quux"
+} -result 1
+
+test should_log_tcl_command_for_empty_command {} -body {
+ should_log_tcl_command ""
+} -result 1
+
+test should_log_tcl_command_for_sql_connect {} -body {
+ should_log_tcl_command "sql connect localhost root somepassword"
+} -result 0
+
+test should_log_tcl_command_for_genpass {} -body {
+ should_log_tcl_command "genpass somepassword somedomain.tld"
+} -result 0
+
+###
+### Cleanup
+###
+
+cleanupTests
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Apr 21, 16:15 (17 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2590388
Default Alt Text
D821.diff (1 KB)
Attached To
Mode
D821: Refactor .tcl DCC command
Attached
Detach File
Event Timeline
Log In to Comment