3 ' vbslib ver2.00 2008/8/17
\r
4 ' Copyright (c) 2008, T's-Neko
\r
5 ' All rights reserved. 3-clause BSD license.
\r
9 Dim g_Test, g_echo_on
\r
11 Function InitializeModule
\r
13 Set g_Test = New TestScript
\r
15 Dim g_InitializeModule
\r
16 Set g_InitializeModule = GetRef( "InitializeModule" )
\r
18 Const Err_TestPass = 21
\r
19 Const Err_TestSkip = 22
\r
20 Const Err_TestFail = 23
\r
23 '********************************************************************************
\r
24 ' <<< [call_vbs_t] >>>
\r
25 ' - The difference of call_vbs is not depend on vbslib.
\r
26 ' - path, func as string, param as variant
\r
27 '********************************************************************************
\r
28 Function call_vbs_t( ByVal path, ByVal func, ByVal param )
\r
29 Dim oldDir, f, funcX, in_interpret, en, ed, es
\r
31 in_interpret = False
\r
32 oldDir = g_sh.CurrentDirectory
\r
34 path = g_sh.ExpandEnvironmentStrings( path )
\r
35 path = g_fs.GetAbsolutePathName( path )
\r
37 '-----------------------------------------
\r
39 On Error Resume Next 'try
\r
40 g_sh.CurrentDirectory = g_fs.GetParentFolderName( path )
\r
41 If Err=0 Then Set f = g_fs.OpenTextFile( g_fs.GetFileName( path ) )
\r
42 If Err=0 Then in_interpret = True : ExecuteGlobal f.ReadAll()
\r
43 If Err=&h411 Then in_interpret = False : Err.Clear ' Ignore symbol override error
\r
44 If Err=0 Then in_interpret = False
\r
45 If Err=0 Then Set funcX = GetRef( func )
\r
47 en = Err.Number : es = Err.Source : ed = Err.Description : On Error GoTo 0 : If en <> 0 Then 'catch
\r
48 If in_interpret Then
\r
49 ed = ed + " Syntax ERROR in """ + g_fs.GetFileName( path ) _
\r
50 + """. Please double click """ _
\r
51 + g_fs.GetFileName( path ) + """."
\r
53 If en = &h35 Then ed = "Not found file '" + path
\r
54 If en = 5 Then ed = "Not found func name '" + func + "' in " + path
\r
58 '-----------------------------------------
\r
61 On Error Resume Next 'try
\r
62 call_vbs_t = funcX( param )
\r
63 en = Err.Number : es = Err.Source : ed = Err.Description : On Error GoTo 0 : If en <> 0 Then 'catch
\r
64 If en = Err_TestPass Then
\r
67 ed = ed + " - Runtime ERROR in the function of """ + func + """ in """ _
\r
68 + GetStepPath( path, g_fs.GetParentFolderName( WScript.ScriptFullName ) ) + """."
\r
74 '-----------------------------------------
\r
77 g_sh.CurrentDirectory = oldDir
\r
79 If en <> 0 Then Err.Raise en, es, ed
\r
85 '********************************************************************************
\r
86 ' <<< [call_vbs_d] >>>
\r
87 '********************************************************************************
\r
88 Function call_vbs_d( ByVal path, ByVal func, ByVal param )
\r
89 Dim oldDir, f, funcX, in_call, in_interpret, en
\r
91 oldDir = g_sh.CurrentDirectory
\r
93 path = g_sh.ExpandEnvironmentStrings( path )
\r
94 path = g_fs.GetAbsolutePathName( path )
\r
96 g_sh.CurrentDirectory = g_fs.GetParentFolderName( path )
\r
98 Set f = g_fs.OpenTextFile( g_fs.GetFileName( path ) )
\r
99 ExecuteGlobal f.ReadAll()
\r
100 Set funcX = GetRef( func ) ' If error, Not found func symbol
\r
101 call_vbs_d = funcX( param )
\r
103 g_sh.CurrentDirectory = oldDir
\r
109 '*-------------------------------------------------------------------------*
\r
110 '*
\81\9f<<<< [TestScript] Class >>>> */
\r
111 '*-------------------------------------------------------------------------*
\r
114 Public m_nPass ' as integer
\r
115 Public m_nSkip ' as integer
\r
116 Public m_nFail ' as integer
\r
117 Public m_Log ' as Text File
\r
118 Public m_DefLogFName ' as string
\r
119 Public m_ManualTests() ' as string
\r
120 Public m_Debug ' as boolean
\r
121 Public m_Pass ' as boolean
\r
123 '********************************************************************************
\r
124 ' <<< [TestScript::Class_Initialize] >>>
\r
125 '********************************************************************************
\r
126 Private Sub Class_Initialize
\r
127 m_DefLogFName = "Test_logs.txt"
\r
129 ReDim m_ManualTests(-1)
\r
134 '********************************************************************************
\r
135 ' <<< [TestScript::Class_Terminate] >>>
\r
136 '********************************************************************************
\r
137 Private Sub Class_Terminate
\r
138 If Not IsEmpty( m_Log ) Then Finish
\r
143 '********************************************************************************
\r
144 ' <<< [TestScript::Start] >>>
\r
145 '********************************************************************************
\r
147 Dim sub_test ' Boolean
\r
149 Set m_Log = g_fs.CreateTextFile( m_DefLogFName, True, False )
\r
150 ReDim m_ManualTests(-1)
\r
153 If WScript.Arguments.Count >= 1 Then
\r
154 If WScript.Arguments(0) = "-sub_test" Then sub_test = True
\r
157 If Not sub_test Then echo "Test Start : " & g_fs.GetFileName( Wscript.ScriptFullName )
\r
166 '********************************************************************************
\r
167 ' <<< [TestScript::Do_] >>>
\r
168 '********************************************************************************
\r
169 Public Sub Do_( ByVal vbs_path, ByVal func, ByVal param )
\r
170 Dim e,ed,es, DefLogFName
\r
172 If g_debug Then Debug vbs_path, func, param : Exit Sub
\r
174 If IsEmpty( m_Log ) And func <> "test_current" Then
\r
175 DefLogFName = m_DefLogFName
\r
176 m_DefLogFName = g_fs.GetParentFolderName( vbs_path ) + "\" + DefLogFName
\r
180 If func <> "test_current" Then
\r
181 echo "=========================================================="
\r
182 If g_fs.GetFileName( g_fs.GetParentFolderName( vbs_path ) ) = "" Then
\r
183 echo "<<< [" & g_fs.GetFileName( vbs_path ) & "] - " & func & " >>>"
\r
185 echo "<<< [" & g_fs.GetFileName( g_fs.GetParentFolderName( vbs_path ) ) & "\" _
\r
186 & g_fs.GetFileName( vbs_path ) & "] - " & func & " >>>"
\r
190 On Error Resume Next
\r
191 call_vbs_t vbs_path, func, param
\r
192 If Err.Number=0 And Not m_Pass Then Err.Raise Err_TestFail, "VBSLib TestScript", _
\r
193 "No result" + " - Runtime ERROR in the function of """ + func + """ in """ + _
\r
194 g_fs.GetFileName( vbs_path ) + """."
\r
195 e = Err.Number : ed = Err.Description : es = Err.Source : On Error GoTo 0 : If e <> 0 Then
\r
196 If e = Err_TestSkip Then
\r
197 m_nSkip = m_nSkip + 1
\r
198 echo "[Skip] " & ed
\r
199 echo " in """ & vbs_path & """"
\r
200 ElseIf e = Err_TestFail Then
\r
201 m_nFail = m_nFail + 1
\r
202 echo "[Fail] " & ed
\r
203 echo " in """ & vbs_path & """"
\r
205 m_nFail = m_nFail + 1
\r
206 If e >= 0 And e <= &h7fff Then e = e + &h800A0000
\r
207 echo "[Fail] [Error] (" & Hex(e) & ") " & ed
\r
208 echo " in """ & vbs_path & """"
\r
212 If func <> "test_current" Then
\r
213 m_nPass = m_nPass + 1
\r
218 If Not IsEmpty( DefLogFName ) Then
\r
220 m_DefLogFName = DefLogFName
\r
227 '********************************************************************************
\r
228 ' <<< [TestScript::Debug] >>>
\r
229 '********************************************************************************
\r
230 Public Sub Debug( ByVal vbs_path, ByVal func, ByVal param )
\r
231 echo "=========================================================="
\r
232 echo "<<< [" & g_fs.GetFileName( g_fs.GetParentFolderName( vbs_path ) ) & "\" _
\r
233 & g_fs.GetFileName( vbs_path ) & "] - " & func & " >>>"
\r
234 echo "Debug Mode ..."
\r
237 call_vbs_d vbs_path, func, param
\r
241 If func <> "test_current" Then
\r
242 m_nPass = m_nPass + 1
\r
250 '********************************************************************************
\r
251 ' <<< [TestScript::AddManualTest] >>>
\r
252 '********************************************************************************
\r
253 Public Sub AddManualTest( TestSymbol )
\r
254 ReDim Preserve m_ManualTests( UBound( m_ManualTests ) + 1 )
\r
255 m_ManualTests( UBound( m_ManualTests ) ) = TestSymbol
\r
260 '********************************************************************************
\r
261 ' <<< [TestScript::Finish] >>>
\r
262 '********************************************************************************
\r
264 Dim TestSymbol, sub_test ' Boolean
\r
266 For Each TestSymbol In m_ManualTests
\r
267 echo "[ManualTest] " + TestSymbol
\r
271 If WScript.Arguments.Count >= 1 Then
\r
272 If WScript.Arguments(0) = "-sub_test" Then sub_test = True
\r
276 If m_nFail = 0 Then WScript.Quit 0 Else WScript.Quit 1 End If
\r
278 echo "=========================================================="
\r
279 echo "Test Finish (Pass=" & m_nPass & ", Manual=" & UBound(m_ManualTests)+1 & _
\r
280 ", Skip=" & m_nSkip & ", Fail=" & m_nFail & ")"
\r
294 '*-------------------------------------------------------------------------*
\r
295 '*
\81\9f<<<< [Tests] Class >>>> */
\r
296 '*-------------------------------------------------------------------------*
\r
299 Private m_Sets ' As Dictionary of UnitTest. key is UnitTest::Symbol
\r
300 Private m_BaseFolderPath ' as string. All Test ROOT
\r
301 Private m_Prompt ' as TestPrompt or Empty
\r
302 Private m_CurrentSymbol ' as string of current test symbol or ALL or ALL_R
\r
303 Private m_CurrentSubSymbol ' as string
\r
304 Private m_CurrentTest ' as UnitTest of m_CurrentSymbol
\r
305 Public CurrentTestPriority ' as integer small is high priority
\r
306 Private m_bAllTest ' as boolean
\r
307 Private m_AllFName ' as string
\r
308 Private m_Symbol ' as string of doing test symbol
\r
309 Public bTargetDebug ' as boolean
\r
310 Public c_ErrDblSymbol ' as const number
\r
312 '----------------------------------
\r
313 Public Property Get Sets : Set Sets = m_Sets : End Property
\r
314 Public Property Get BaseFolderPath : BaseFolderPath = m_BaseFolderPath : End Property
\r
315 Public Property Let BaseFolderPath( x ) : m_BaseFolderPath = x : End Property
\r
316 Public Property Set Prompt( x ) : Set m_Prompt = x : End Property
\r
317 Public Property Get Prompt : Set Prompt = m_Prompt : End Property
\r
318 Public Property Get CurrentSymbol : CurrentSymbol = m_CurrentSymbol : End Property
\r
319 Public Property Get CurrentTest : If IsObject(m_CurrentTest) Then Set CurrentTest = m_CurrentTest : Else CurrentTest = m_CurrentTest : End If : End Property
\r
320 Public Property Get bAllTest : bAllTest = m_bAllTest : End Property
\r
321 Public Property Get Symbol : Symbol = m_Symbol : End Property
\r
323 '********************************************************************************
\r
324 ' <<< [Tests::Class_Initialize] >>>
\r
325 '********************************************************************************
\r
326 Private Sub Class_Initialize
\r
327 Set m_Sets = CreateObject("Scripting.Dictionary")
\r
328 m_BaseFolderPath = g_fs.GetParentFolderName( WScript.ScriptFullName )
\r
329 m_CurrentSymbol = "ALL"
\r
330 m_AllFName = "T_ALL.vbs"
\r
332 bTargetDebug = False
\r
333 c_ErrDblSymbol = 1010
\r
337 '********************************************************************************
\r
338 ' <<< [Tests::AddTestScriptAuto] >>>
\r
339 '********************************************************************************
\r
340 Public Function AddTestScriptAuto( BasePath, FName )
\r
342 AddTestScriptAuto_EnumSubFolders g_fs.GetFolder( BasePath ), FName
\r
346 Private Sub AddTestScriptAuto_EnumSubFolders( fo, FName )
\r
349 If g_fs.FileExists( fo.Path + "\" + FName ) Then
\r
350 AddTestScript g_fs.GetFileName( fo.Path ), fo.Path + "\" + FName
\r
352 For Each subfo in fo.SubFolders
\r
353 AddTestScriptAuto_EnumSubFolders subfo, FName
\r
357 '********************************************************************************
\r
358 ' <<< [Tests::AddTestScript] >>>
\r
359 '********************************************************************************
\r
360 Public Function AddTestScript( Symbol, Path )
\r
363 If Not g_fs.FileExists( Path ) Then Err.Raise 53,,"
\83t
\83@
\83C
\83\8b\82ª
\8c©
\82Â
\82©
\82è
\82Ü
\82¹
\82ñ " + Path
\r
365 Set test = New UnitTest
\r
366 test.Symbol = Symbol
\r
367 test.ScriptPath = g_fs.GetAbsolutePathName( Path )
\r
368 If m_Sets.Exists( test.Symbol ) Then _
\r
369 Err.Raise c_ErrDblSymbol,"class Tests", "[ERROR] Already defined the symbol '"+Symbol+"' in "+ _
\r
370 m_Sets.Item(Symbol).ScriptPath
\r
371 m_Sets.Add test.Symbol, test
\r
373 Me.CurrentTestPriority = 1000
\r
374 If g_debug Then call_vbs_d Path, "test_current", Me _
\r
375 Else call_vbs_t Path, "test_current", Me
\r
376 test.Priority = Me.CurrentTestPriority
\r
378 Set AddTestScript = test
\r
382 '********************************************************************************
\r
383 ' <<< [Tests::SetCurrentSymbol] >>>
\r
384 '********************************************************************************
\r
385 Public Function SetCurrentSymbol( Symbol_or_Path )
\r
388 SetCurrentSymbol = 0
\r
390 '// ALL and ALL_R is special symbol
\r
391 If Symbol_or_Path = "ALL" or Symbol_or_Path = "ALL_R" Then m_CurrentSymbol = Symbol_or_Path : _
\r
392 m_CurrentTest = Empty : Exit Function
\r
394 '// Search by test symbol
\r
395 For Each key in m_Sets.Keys()
\r
396 If key = Symbol_or_Path Then m_CurrentSymbol = Symbol_or_Path : _
\r
397 Set m_CurrentTest = m_Sets.Item( m_CurrentSymbol ) : Exit Function
\r
401 For Each item in m_Sets.Items()
\r
402 If item.ScriptPath = Symbol_or_Path Then m_CurrentSymbol = item.Symbol : _
\r
403 Set m_CurrentTest = m_Sets.Item( m_CurrentSymbol ) : Exit Function
\r
406 '// If Symbol is path, Add test symbol
\r
407 If g_fs.FileExists( Symbol_or_Path ) Then
\r
408 If UCase(g_fs.GetFileName( Symbol_or_Path )) = UCase(m_AllFName) Then _
\r
409 m_CurrentSymbol = g_fs.GetFileName( g_fs.GetParentFolderName( g_fs.GetAbsolutePathName(Symbol_or_Path) ) ) _
\r
410 Else m_CurrentSymbol = g_fs.GetBaseName( Symbol_or_Path )
\r
412 b = True : If m_Sets.Exists( m_CurrentSymbol ) Then _
\r
413 b = ( m_Sets.Item( m_CurrentSymbol ).ScriptPath <> g_fs.GetAbsolutePathName( Symbol_or_Path ) )
\r
414 If b Then 'If Not m_Sets.Exists( m_CurrentSymbol ) or _
\r
415 ' m_Sets.Item( m_CurrentSymbol ).ScriptPath <> g_fs.GetAbsolutePathName( Symbol_or_Path ) Then
\r
416 AddTestScript m_CurrentSymbol, Symbol_or_Path
\r
418 Set m_CurrentTest = m_Sets.Item( m_CurrentSymbol )
\r
423 echo "[ERROR] Not found symbol or path """ + Symbol_or_Path + """. CurrentDirectory = " & g_sh.CurrentDirectory
\r
424 SetCurrentSymbol = 1
\r
429 '********************************************************************************
\r
430 ' <<< [Tests::DoTest] >>>
\r
431 '********************************************************************************
\r
432 Public Sub DoTest( Func, bReverse )
\r
433 If m_CurrentSymbol = "ALL" Or m_CurrentSymbol = "ALL_R" Then
\r
437 ShakerSort_fromDic m_Sets, utests, -1, GetRef("CmpUnitTestPriorityDec"), Empty
\r
439 ShakerSort_fromDic m_Sets, utests, +1, GetRef("CmpUnitTestPriorityInc"), Empty
\r
442 g_Test.m_DefLogFName = m_BaseFolderPath + "\" + g_fs.GetFileName( g_Test.m_DefLogFName )
\r
444 For Each m_CurrentTest in utests
\r
446 g_Test.Do_ m_CurrentTest.ScriptPath, "test_current", Me
\r
448 g_Test.Do_ m_CurrentTest.ScriptPath, Func, Me
\r
452 g_Test.m_DefLogFName = g_fs.GetParentFolderName( m_CurrentTest.ScriptPath ) + "\" + g_fs.GetFileName( g_Test.m_DefLogFName )
\r
454 Set m_CurrentTest = m_Sets.Item( m_CurrentSymbol )
\r
456 g_Test.Do_ m_CurrentTest.ScriptPath, "test_current", Me
\r
458 g_Test.Do_ m_CurrentTest.ScriptPath, Func, Me
\r
464 '********************************************************************************
\r
465 ' <<< [Tests::DebugTest] >>>
\r
466 '********************************************************************************
\r
467 Public Sub DebugTest( Func, bReverse )
\r
468 If m_CurrentSymbol = "ALL" Or m_CurrentSymbol = "ALL_R" Then
\r
471 i = m_Sets.Count - 1
\r
472 ReDim Preserve items( i )
\r
474 For Each m_CurrentTest in m_Sets.Items()
\r
475 Set items( i ) = m_CurrentTest
\r
480 For Each m_CurrentTest in m_Sets.Items()
\r
481 Set items( i ) = m_CurrentTest
\r
486 g_Test.m_DefLogFName = m_BaseFolderPath + "\" + g_fs.GetFileName( g_Test.m_DefLogFName )
\r
488 For Each m_CurrentTest in items
\r
490 g_Test.Debug m_CurrentTest.ScriptPath, "test_current", Me
\r
492 g_Test.Debug m_CurrentTest.ScriptPath, Func, Me
\r
496 g_Test.m_DefLogFName = g_fs.GetParentFolderName( m_CurrentTest.ScriptPath ) + "\" + g_fs.GetFileName( g_Test.m_DefLogFName )
\r
498 Set m_CurrentTest = m_Sets.Item( m_CurrentSymbol )
\r
500 g_Test.Debug m_CurrentTest.ScriptPath, "test_current", Me
\r
502 g_Test.Debug m_CurrentTest.ScriptPath, Func, Me
\r
508 '********************************************************************************
\r
509 ' <<< [Tests::DoAllTest] >>>
\r
510 '********************************************************************************
\r
511 Public Sub DoAllTest()
\r
513 If m_CurrentSymbol = "ALL" Or m_CurrentSymbol = "ALL_R" Then
\r
514 Redim utests_inc(-1), utests_dec(-1)
\r
516 ShakerSort_fromDic m_Sets, utests_inc, +1, GetRef("CmpUnitTestPriorityInc"), Empty
\r
517 ShakerSort_fromDic m_Sets, utests_dec, -1, GetRef("CmpUnitTestPriorityDec"), Empty
\r
519 g_Test.m_DefLogFName = m_BaseFolderPath + "\" + g_fs.GetFileName( g_Test.m_DefLogFName )
\r
522 For Each m_CurrentTest in utests_inc
\r
524 g_Test.Do_ m_CurrentTest.ScriptPath, "test_current", Me
\r
526 For Each m_CurrentTest in utests_inc
\r
528 g_Test.Do_ m_CurrentTest.ScriptPath, "test_build", Me
\r
530 For Each m_CurrentTest in utests_inc
\r
532 g_Test.Do_ m_CurrentTest.ScriptPath, "test_setup", Me
\r
534 For Each m_CurrentTest in utests_dec
\r
536 g_Test.Do_ m_CurrentTest.ScriptPath, "test_start", Me
\r
538 For Each m_CurrentTest in utests_dec
\r
540 g_Test.Do_ m_CurrentTest.ScriptPath, "test_check", Me
\r
542 For Each m_CurrentTest in utests_dec
\r
544 g_Test.Do_ m_CurrentTest.ScriptPath, "test_clean", Me
\r
548 Set m_CurrentTest = m_Sets.Item( m_CurrentSymbol )
\r
549 g_Test.m_DefLogFName = g_fs.GetParentFolderName( m_CurrentTest.ScriptPath ) + "\" + g_fs.GetFileName( g_Test.m_DefLogFName )
\r
552 g_Test.Do_ m_CurrentTest.ScriptPath, "test_current", Me
\r
554 g_Test.Do_ m_CurrentTest.ScriptPath, "test_build", Me
\r
556 g_Test.Do_ m_CurrentTest.ScriptPath, "test_setup", Me
\r
558 g_Test.Do_ m_CurrentTest.ScriptPath, "test_start", Me
\r
560 g_Test.Do_ m_CurrentTest.ScriptPath, "test_check", Me
\r
562 g_Test.Do_ m_CurrentTest.ScriptPath, "test_clean", Me
\r
570 '********************************************************************************
\r
571 ' <<< [Tests::TestCurrentSetup] >>>
\r
572 '********************************************************************************
\r
573 Private Sub TestCurrentSetup()
\r
574 m_Symbol = m_CurrentTest.Symbol
\r
575 CurrentTestPriority = m_CurrentTest.Priority
\r
576 g_Test.m_Pass = True
\r
580 '********************************************************************************
\r
581 ' <<< [Tests::TestSetup] >>>
\r
582 '********************************************************************************
\r
583 Private Sub TestSetup()
\r
584 m_Symbol = m_CurrentTest.Symbol
\r
585 g_Test.m_Pass = False
\r
589 '********************************************************************************
\r
590 ' <<< [Tests::SetCur] >>>
\r
591 '********************************************************************************
\r
592 Public Sub SetCur( SubSymbol )
\r
593 m_CurrentSubSymbol = SubSymbol
\r
597 '********************************************************************************
\r
598 ' <<< [Tests::IsCur] >>>
\r
599 '********************************************************************************
\r
600 Public Function IsCur( SubSymbol )
\r
601 If m_CurrentSubSymbol = "ALL" Or m_CurrentSubSymbol = "ALL_R" Or _
\r
602 m_CurrentSubSymbol = SubSymbol Then
\r
612 '********************************************************************************
\r
613 ' <<< [CmpUnitTestPriorityInc] >>>
\r
614 '********************************************************************************
\r
615 Function CmpUnitTestPriorityInc( left, right, param )
\r
616 CmpUnitTestPriorityInc = left.Priority - right.Priority
\r
619 '********************************************************************************
\r
620 ' <<< [CmpUnitTestPriorityDec] >>>
\r
621 '********************************************************************************
\r
622 Function CmpUnitTestPriorityDec( left, right, param )
\r
623 CmpUnitTestPriorityDec = right.Priority - left.Priority
\r
626 '*-------------------------------------------------------------------------*
\r
627 '*
\81\9f<<<< [UnitTest] Class >>>> */
\r
628 '*-------------------------------------------------------------------------*
\r
631 Public Symbol ' As String
\r
632 Public ScriptPath ' As String
\r
633 Public Priority ' As Integer
\r
635 '----------------------------------
\r
636 Private Sub Class_Initialize
\r
637 Symbol = "NoSymbol"
\r
641 Public Function Value
\r
642 Value = "[" & Symbol & "]" & vbCR & vbLF & " " & ScriptPath
\r
645 Public Function PathToAbs( BaseFolderPath )
\r
648 s = g_fs.GetAbsolutePathName( BaseFolderPath & "\" & ScriptPath )
\r
649 If Not g_fs.FileExists( s ) Then echo "[ERROR] Not found " + ScriptPath + ", Base=" + BaseFolderPath : PathToAbs = False
\r
657 '*-------------------------------------------------------------------------*
\r
658 '*
\81\9f<<<< Test Result >>>> */
\r
659 '*-------------------------------------------------------------------------*
\r
662 '********************************************************************************
\r
664 '********************************************************************************
\r
666 If IsEmpty( g_Test ) Then
\r
667 WScript.Quit Err_TestPass
\r
668 ElseIf IsEmpty( g_Test.m_Log ) Then
\r
669 WScript.Echo "Pass"
\r
670 WScript.Quit Err_TestPass
\r
672 g_Test.m_Pass = True
\r
679 '********************************************************************************
\r
681 '********************************************************************************
\r
683 If IsEmpty( g_Test ) Then
\r
684 WScript.Quit Err_TestFail
\r
685 ElseIf IsEmpty( g_Test.m_Log ) Then
\r
686 WScript.Echo "Fail"
\r
687 WScript.Quit Err_TestFail
\r
689 Err.Raise Err_TestFail, "VBSLib TestScript", "Fail the Test"
\r
696 '********************************************************************************
\r
698 '********************************************************************************
\r
700 If IsEmpty( g_Test ) Then
\r
701 WScript.Quit Err_TestSkip
\r
702 ElseIf IsEmpty( g_Test.m_Log ) Then
\r
703 WScript.Echo "Skip"
\r
704 WScript.Quit Err_TestSkip
\r
706 Err.Raise Err_TestSkip, "VBSLib TestScript", "Skip the Test"
\r
713 '********************************************************************************
\r
714 ' <<< [ManualTest] >>>
\r
715 '********************************************************************************
\r
716 Sub ManualTest( TestSymbol )
\r
717 echo "<<< ["+TestSymbol+"] >>>"
\r
718 echo "This is ManualTest."
\r
719 g_Test.AddManualTest TestSymbol
\r
723 '*-------------------------------------------------------------------------*
\r
724 '*
\81\9f<<<< Tools for Test Program >>>> */
\r
725 '*-------------------------------------------------------------------------*
\r
728 '********************************************************************************
\r
729 ' <<< [EchoTestStart] >>>
\r
730 '********************************************************************************
\r
731 Sub EchoTestStart( TestSymbol )
\r
732 echo "<<< ["+TestSymbol+"] >>>"
\r
737 '********************************************************************************
\r
739 ' return: output message
\r
740 '********************************************************************************
\r
741 Function echo( ByVal msg )
\r
742 If IsObject( msg ) Then msg = msg.Value
\r
745 If Not IsEmpty( g_Test.m_Log ) Then g_Test.m_Log.WriteLine msg
\r
751 '********************************************************************************
\r
752 ' <<< [CheckTestErrLevel] >>>
\r
753 '********************************************************************************
\r
754 Sub CheckTestErrLevel( r )
\r
755 If r = Err_TestSkip Then
\r
757 ElseIf r <> Err_TestPass Then
\r
764 '********************************************************************************
\r
765 ' <<< [ConvertToAbsPath] >>>
\r
766 '********************************************************************************
\r
767 Sub ConvertToAbsPath( SrcPath, DstPath )
\r
768 Dim src, dst, dst_parent, line, p1, p2, path
\r
770 Set src = g_fs.OpenTextFile( SrcPath )
\r
771 mkdir g_fs.GetParentFolderName( g_fs.GetAbsolutePathName( DstPath ) )
\r
772 Set dst = g_fs.CreateTextFile( DstPath, True, False )
\r
774 Do Until src.AtEndOfStream
\r
775 line = src.ReadLine
\r
777 p1 = InStr( line, "%AbsPath(" )
\r
778 If p1 = 0 Then Exit Do
\r
779 p2 = InStr( p1 + 9, line, ")%" )
\r
780 path = Mid( line, p1+9, p2-p1-9 )
\r
781 path = GetAbsPath( path, g_fs.GetParentFolderName( g_fs.GetAbsolutePathName( SrcPath ) ) )
\r
782 line = Left( line, p1 - 1 ) + path + Mid( line, p2 + 2 )
\r
784 line = Replace( line, "%DesktopPath%", g_sh.SpecialFolders("Desktop") )
\r