X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=_src%2F_replica%2Fvbslib%2FTestScript.vbs;fp=_src%2F_replica%2Fvbslib%2FTestScript.vbs;h=0000000000000000000000000000000000000000;hb=8cd319a3714156b275c5e3809401dfccfa472e29;hp=735d37a15d3209e7a4ad53b2e13a49d60c5921e7;hpb=96594a1f7f4a7fcb1ef2b3641e65c63a0a98635c;p=vbslib%2Fmain.git diff --git a/_src/_replica/vbslib/TestScript.vbs b/_src/_replica/vbslib/TestScript.vbs deleted file mode 100644 index 735d37a..0000000 --- a/_src/_replica/vbslib/TestScript.vbs +++ /dev/null @@ -1,792 +0,0 @@ -Option Explicit - -' vbslib ver2.00 2008/8/17 -' Copyright (c) 2008, T's-Neko -' All rights reserved. 3-clause BSD license. - - -' Global Variable -Dim g_Test, g_echo_on - -Function InitializeModule - g_echo_on = True - Set g_Test = New TestScript -End Function -Dim g_InitializeModule -Set g_InitializeModule = GetRef( "InitializeModule" ) - -Const Err_TestPass = 21 -Const Err_TestSkip = 22 -Const Err_TestFail = 23 - - -'******************************************************************************** -' <<< [call_vbs_t] >>> -' - The difference of call_vbs is not depend on vbslib. -' - path, func as string, param as variant -'******************************************************************************** -Function call_vbs_t( ByVal path, ByVal func, ByVal param ) - Dim oldDir, f, funcX, in_interpret, en, ed, es - - in_interpret = False - oldDir = g_sh.CurrentDirectory - - path = g_sh.ExpandEnvironmentStrings( path ) - path = g_fs.GetAbsolutePathName( path ) - - '----------------------------------------- - ' Interpret - On Error Resume Next 'try - g_sh.CurrentDirectory = g_fs.GetParentFolderName( path ) - If Err=0 Then Set f = g_fs.OpenTextFile( g_fs.GetFileName( path ) ) - If Err=0 Then in_interpret = True : ExecuteGlobal f.ReadAll() - If Err=&h411 Then in_interpret = False : Err.Clear ' Ignore symbol override error - If Err=0 Then in_interpret = False - If Err=0 Then Set funcX = GetRef( func ) - - en = Err.Number : es = Err.Source : ed = Err.Description : On Error GoTo 0 : If en <> 0 Then 'catch - If in_interpret Then - ed = ed + " Syntax ERROR in """ + g_fs.GetFileName( path ) _ - + """. Please double click """ _ - + g_fs.GetFileName( path ) + """." - End If - If en = &h35 Then ed = "Not found file '" + path - If en = 5 Then ed = "Not found func name '" + func + "' in " + path - End If - - - '----------------------------------------- - ' Call - If en = 0 Then - On Error Resume Next 'try - call_vbs_t = funcX( param ) - en = Err.Number : es = Err.Source : ed = Err.Description : On Error GoTo 0 : If en <> 0 Then 'catch - If en = Err_TestPass Then - en = 0 - Else - ed = ed + " - Runtime ERROR in the function of """ + func + """ in """ _ - + GetStepPath( path, g_fs.GetParentFolderName( WScript.ScriptFullName ) ) + """." - End If - End If - End If - - - '----------------------------------------- - ' Finally - f.Close - g_sh.CurrentDirectory = oldDir - - If en <> 0 Then Err.Raise en, es, ed -End Function - - - - -'******************************************************************************** -' <<< [call_vbs_d] >>> -'******************************************************************************** -Function call_vbs_d( ByVal path, ByVal func, ByVal param ) - Dim oldDir, f, funcX, in_call, in_interpret, en - - oldDir = g_sh.CurrentDirectory - - path = g_sh.ExpandEnvironmentStrings( path ) - path = g_fs.GetAbsolutePathName( path ) - - g_sh.CurrentDirectory = g_fs.GetParentFolderName( path ) - - Set f = g_fs.OpenTextFile( g_fs.GetFileName( path ) ) - ExecuteGlobal f.ReadAll() - Set funcX = GetRef( func ) ' If error, Not found func symbol - call_vbs_d = funcX( param ) - f.Close - g_sh.CurrentDirectory = oldDir -End Function - - - - -'*-------------------------------------------------------------------------* -'* Ÿ<<<< [TestScript] Class >>>> */ -'*-------------------------------------------------------------------------* - -Class TestScript - Public m_nPass ' as integer - Public m_nSkip ' as integer - Public m_nFail ' as integer - Public m_Log ' as Text File - Public m_DefLogFName ' as string - Public m_ManualTests() ' as string - Public m_Debug ' as boolean - Public m_Pass ' as boolean - -'******************************************************************************** -' <<< [TestScript::Class_Initialize] >>> -'******************************************************************************** -Private Sub Class_Initialize - m_DefLogFName = "Test_logs.txt" - m_Debug = g_Debug - ReDim m_ManualTests(-1) -End Sub - - - -'******************************************************************************** -' <<< [TestScript::Class_Terminate] >>> -'******************************************************************************** -Private Sub Class_Terminate - If Not IsEmpty( m_Log ) Then Finish -End Sub - - - -'******************************************************************************** -' <<< [TestScript::Start] >>> -'******************************************************************************** -Public Sub Start - Dim sub_test ' Boolean - - Set m_Log = g_fs.CreateTextFile( m_DefLogFName, True, False ) - ReDim m_ManualTests(-1) - - sub_test = False - If WScript.Arguments.Count >= 1 Then - If WScript.Arguments(0) = "-sub_test" Then sub_test = True - End If - - If Not sub_test Then echo "Test Start : " & g_fs.GetFileName( Wscript.ScriptFullName ) - - m_nPass = 0 - m_nSkip = 0 - m_nFail = 0 -End Sub - - - -'******************************************************************************** -' <<< [TestScript::Do_] >>> -'******************************************************************************** -Public Sub Do_( ByVal vbs_path, ByVal func, ByVal param ) - Dim e,ed,es, DefLogFName - - If g_debug Then Debug vbs_path, func, param : Exit Sub - - If IsEmpty( m_Log ) And func <> "test_current" Then - DefLogFName = m_DefLogFName - m_DefLogFName = g_fs.GetParentFolderName( vbs_path ) + "\" + DefLogFName - Start - End If - - If func <> "test_current" Then - echo "==========================================================" - If g_fs.GetFileName( g_fs.GetParentFolderName( vbs_path ) ) = "" Then - echo "<<< [" & g_fs.GetFileName( vbs_path ) & "] - " & func & " >>>" - Else - echo "<<< [" & g_fs.GetFileName( g_fs.GetParentFolderName( vbs_path ) ) & "\" _ - & g_fs.GetFileName( vbs_path ) & "] - " & func & " >>>" - End If - End If - - On Error Resume Next - call_vbs_t vbs_path, func, param - If Err.Number=0 And Not m_Pass Then Err.Raise Err_TestFail, "VBSLib TestScript", _ - "No result" + " - Runtime ERROR in the function of """ + func + """ in """ + _ - g_fs.GetFileName( vbs_path ) + """." - e = Err.Number : ed = Err.Description : es = Err.Source : On Error GoTo 0 : If e <> 0 Then - If e = Err_TestSkip Then - m_nSkip = m_nSkip + 1 - echo "[Skip] " & ed - echo " in """ & vbs_path & """" - ElseIf e = Err_TestFail Then - m_nFail = m_nFail + 1 - echo "[Fail] " & ed - echo " in """ & vbs_path & """" - Else - m_nFail = m_nFail + 1 - If e >= 0 And e <= &h7fff Then e = e + &h800A0000 - echo "[Fail] [Error] (" & Hex(e) & ") " & ed - echo " in """ & vbs_path & """" - End If - e = Empty - Else - If func <> "test_current" Then - m_nPass = m_nPass + 1 - echo "Pass." - End If - End If - - If Not IsEmpty( DefLogFName ) Then - Finish - m_DefLogFName = DefLogFName - End If - -End Sub - - - -'******************************************************************************** -' <<< [TestScript::Debug] >>> -'******************************************************************************** -Public Sub Debug( ByVal vbs_path, ByVal func, ByVal param ) - echo "==========================================================" - echo "<<< [" & g_fs.GetFileName( g_fs.GetParentFolderName( vbs_path ) ) & "\" _ - & g_fs.GetFileName( vbs_path ) & "] - " & func & " >>>" - echo "Debug Mode ..." - - m_Debug = True - call_vbs_d vbs_path, func, param - m_Debug = False - - if m_Pass Then - If func <> "test_current" Then - m_nPass = m_nPass + 1 - echo "Pass." - End If - End If -End Sub - - - -'******************************************************************************** -' <<< [TestScript::AddManualTest] >>> -'******************************************************************************** -Public Sub AddManualTest( TestSymbol ) - ReDim Preserve m_ManualTests( UBound( m_ManualTests ) + 1 ) - m_ManualTests( UBound( m_ManualTests ) ) = TestSymbol -End Sub - - - -'******************************************************************************** -' <<< [TestScript::Finish] >>> -'******************************************************************************** -Public Sub Finish - Dim TestSymbol, sub_test ' Boolean - - For Each TestSymbol In m_ManualTests - echo "[ManualTest] " + TestSymbol - Next - - sub_test = False - If WScript.Arguments.Count >= 1 Then - If WScript.Arguments(0) = "-sub_test" Then sub_test = True - End If - - If sub_test Then - If m_nFail = 0 Then WScript.Quit 0 Else WScript.Quit 1 End If - Else - echo "==========================================================" - echo "Test Finish (Pass=" & m_nPass & ", Manual=" & UBound(m_ManualTests)+1 & _ - ", Skip=" & m_nSkip & ", Fail=" & m_nFail & ")" - echo "" - End If - - m_Log = Empty -End Sub - - - - - - -End Class - -'*-------------------------------------------------------------------------* -'* Ÿ<<<< [Tests] Class >>>> */ -'*-------------------------------------------------------------------------* -Class Tests - - Private m_Sets ' As Dictionary of UnitTest. key is UnitTest::Symbol - Private m_BaseFolderPath ' as string. All Test ROOT - Private m_Prompt ' as TestPrompt or Empty - Private m_CurrentSymbol ' as string of current test symbol or ALL or ALL_R - Private m_CurrentSubSymbol ' as string - Private m_CurrentTest ' as UnitTest of m_CurrentSymbol - Public CurrentTestPriority ' as integer small is high priority - Private m_bAllTest ' as boolean - Private m_AllFName ' as string - Private m_Symbol ' as string of doing test symbol - Public bTargetDebug ' as boolean - Public c_ErrDblSymbol ' as const number - - '---------------------------------- - Public Property Get Sets : Set Sets = m_Sets : End Property - Public Property Get BaseFolderPath : BaseFolderPath = m_BaseFolderPath : End Property - Public Property Let BaseFolderPath( x ) : m_BaseFolderPath = x : End Property - Public Property Set Prompt( x ) : Set m_Prompt = x : End Property - Public Property Get Prompt : Set Prompt = m_Prompt : End Property - Public Property Get CurrentSymbol : CurrentSymbol = m_CurrentSymbol : End Property - Public Property Get CurrentTest : If IsObject(m_CurrentTest) Then Set CurrentTest = m_CurrentTest : Else CurrentTest = m_CurrentTest : End If : End Property - Public Property Get bAllTest : bAllTest = m_bAllTest : End Property - Public Property Get Symbol : Symbol = m_Symbol : End Property - -'******************************************************************************** -' <<< [Tests::Class_Initialize] >>> -'******************************************************************************** -Private Sub Class_Initialize - Set m_Sets = CreateObject("Scripting.Dictionary") - m_BaseFolderPath = g_fs.GetParentFolderName( WScript.ScriptFullName ) - m_CurrentSymbol = "ALL" - m_AllFName = "T_ALL.vbs" - m_bAllTest = False - bTargetDebug = False - c_ErrDblSymbol = 1010 -End Sub - - -'******************************************************************************** -' <<< [Tests::AddTestScriptAuto] >>> -'******************************************************************************** -Public Function AddTestScriptAuto( BasePath, FName ) - m_AllFName = FName - AddTestScriptAuto_EnumSubFolders g_fs.GetFolder( BasePath ), FName -End Function - - -Private Sub AddTestScriptAuto_EnumSubFolders( fo, FName ) - Dim subfo - - If g_fs.FileExists( fo.Path + "\" + FName ) Then - AddTestScript g_fs.GetFileName( fo.Path ), fo.Path + "\" + FName - End If - For Each subfo in fo.SubFolders - AddTestScriptAuto_EnumSubFolders subfo, FName - Next -End Sub - -'******************************************************************************** -' <<< [Tests::AddTestScript] >>> -'******************************************************************************** -Public Function AddTestScript( Symbol, Path ) - Dim test - - If Not g_fs.FileExists( Path ) Then Err.Raise 53,,"ƒtƒ@ƒCƒ‹‚ªŒ©‚‚©‚è‚Ü‚¹‚ñ " + Path - - Set test = New UnitTest - test.Symbol = Symbol - test.ScriptPath = g_fs.GetAbsolutePathName( Path ) - If m_Sets.Exists( test.Symbol ) Then _ - Err.Raise c_ErrDblSymbol,"class Tests", "[ERROR] Already defined the symbol '"+Symbol+"' in "+ _ - m_Sets.Item(Symbol).ScriptPath - m_Sets.Add test.Symbol, test - - Me.CurrentTestPriority = 1000 - If g_debug Then call_vbs_d Path, "test_current", Me _ - Else call_vbs_t Path, "test_current", Me - test.Priority = Me.CurrentTestPriority - - Set AddTestScript = test -End Function - - -'******************************************************************************** -' <<< [Tests::SetCurrentSymbol] >>> -'******************************************************************************** -Public Function SetCurrentSymbol( Symbol_or_Path ) - Dim key, item, b - - SetCurrentSymbol = 0 - - '// ALL and ALL_R is special symbol - If Symbol_or_Path = "ALL" or Symbol_or_Path = "ALL_R" Then m_CurrentSymbol = Symbol_or_Path : _ - m_CurrentTest = Empty : Exit Function - - '// Search by test symbol - For Each key in m_Sets.Keys() - If key = Symbol_or_Path Then m_CurrentSymbol = Symbol_or_Path : _ - Set m_CurrentTest = m_Sets.Item( m_CurrentSymbol ) : Exit Function - Next - - '// Search by path - For Each item in m_Sets.Items() - If item.ScriptPath = Symbol_or_Path Then m_CurrentSymbol = item.Symbol : _ - Set m_CurrentTest = m_Sets.Item( m_CurrentSymbol ) : Exit Function - Next - - '// If Symbol is path, Add test symbol - If g_fs.FileExists( Symbol_or_Path ) Then - If UCase(g_fs.GetFileName( Symbol_or_Path )) = UCase(m_AllFName) Then _ - m_CurrentSymbol = g_fs.GetFileName( g_fs.GetParentFolderName( g_fs.GetAbsolutePathName(Symbol_or_Path) ) ) _ - Else m_CurrentSymbol = g_fs.GetBaseName( Symbol_or_Path ) - - b = True : If m_Sets.Exists( m_CurrentSymbol ) Then _ - b = ( m_Sets.Item( m_CurrentSymbol ).ScriptPath <> g_fs.GetAbsolutePathName( Symbol_or_Path ) ) - If b Then 'If Not m_Sets.Exists( m_CurrentSymbol ) or _ - ' m_Sets.Item( m_CurrentSymbol ).ScriptPath <> g_fs.GetAbsolutePathName( Symbol_or_Path ) Then - AddTestScript m_CurrentSymbol, Symbol_or_Path - End If - Set m_CurrentTest = m_Sets.Item( m_CurrentSymbol ) - Exit Function - End If - - '// Error: Symbol - echo "[ERROR] Not found symbol or path """ + Symbol_or_Path + """. CurrentDirectory = " & g_sh.CurrentDirectory - SetCurrentSymbol = 1 -End Function - - - -'******************************************************************************** -' <<< [Tests::DoTest] >>> -'******************************************************************************** -Public Sub DoTest( Func, bReverse ) - If m_CurrentSymbol = "ALL" Or m_CurrentSymbol = "ALL_R" Then - Redim utests(-1) - - If bReverse Then - ShakerSort_fromDic m_Sets, utests, -1, GetRef("CmpUnitTestPriorityDec"), Empty - Else - ShakerSort_fromDic m_Sets, utests, +1, GetRef("CmpUnitTestPriorityInc"), Empty - End If - - g_Test.m_DefLogFName = m_BaseFolderPath + "\" + g_fs.GetFileName( g_Test.m_DefLogFName ) - g_Test.Start - For Each m_CurrentTest in utests - TestCurrentSetup - g_Test.Do_ m_CurrentTest.ScriptPath, "test_current", Me - TestSetup - g_Test.Do_ m_CurrentTest.ScriptPath, Func, Me - Next - g_Test.Finish - Else - g_Test.m_DefLogFName = g_fs.GetParentFolderName( m_CurrentTest.ScriptPath ) + "\" + g_fs.GetFileName( g_Test.m_DefLogFName ) - g_Test.Start - Set m_CurrentTest = m_Sets.Item( m_CurrentSymbol ) - TestCurrentSetup - g_Test.Do_ m_CurrentTest.ScriptPath, "test_current", Me - TestSetup - g_Test.Do_ m_CurrentTest.ScriptPath, Func, Me - g_Test.Finish - End If -End Sub - - -'******************************************************************************** -' <<< [Tests::DebugTest] >>> -'******************************************************************************** -Public Sub DebugTest( Func, bReverse ) - If m_CurrentSymbol = "ALL" Or m_CurrentSymbol = "ALL_R" Then - Dim items(), i - - i = m_Sets.Count - 1 - ReDim Preserve items( i ) - If bReverse Then - For Each m_CurrentTest in m_Sets.Items() - Set items( i ) = m_CurrentTest - i = i - 1 - Next - Else - i = 0 - For Each m_CurrentTest in m_Sets.Items() - Set items( i ) = m_CurrentTest - i = i + 1 - Next - End If - - g_Test.m_DefLogFName = m_BaseFolderPath + "\" + g_fs.GetFileName( g_Test.m_DefLogFName ) - g_Test.Start - For Each m_CurrentTest in items - TestCurrentSetup - g_Test.Debug m_CurrentTest.ScriptPath, "test_current", Me - TestSetup - g_Test.Debug m_CurrentTest.ScriptPath, Func, Me - Next - g_Test.Finish - Else - g_Test.m_DefLogFName = g_fs.GetParentFolderName( m_CurrentTest.ScriptPath ) + "\" + g_fs.GetFileName( g_Test.m_DefLogFName ) - g_Test.Start - Set m_CurrentTest = m_Sets.Item( m_CurrentSymbol ) - TestCurrentSetup - g_Test.Debug m_CurrentTest.ScriptPath, "test_current", Me - TestSetup - g_Test.Debug m_CurrentTest.ScriptPath, Func, Me - g_Test.Finish - End If -End Sub - - -'******************************************************************************** -' <<< [Tests::DoAllTest] >>> -'******************************************************************************** -Public Sub DoAllTest() - m_bAllTest = True - If m_CurrentSymbol = "ALL" Or m_CurrentSymbol = "ALL_R" Then - Redim utests_inc(-1), utests_dec(-1) - - ShakerSort_fromDic m_Sets, utests_inc, +1, GetRef("CmpUnitTestPriorityInc"), Empty - ShakerSort_fromDic m_Sets, utests_dec, -1, GetRef("CmpUnitTestPriorityDec"), Empty - - g_Test.m_DefLogFName = m_BaseFolderPath + "\" + g_fs.GetFileName( g_Test.m_DefLogFName ) - g_Test.Start - - For Each m_CurrentTest in utests_inc - TestCurrentSetup - g_Test.Do_ m_CurrentTest.ScriptPath, "test_current", Me - Next - For Each m_CurrentTest in utests_inc - TestSetup - g_Test.Do_ m_CurrentTest.ScriptPath, "test_build", Me - Next - For Each m_CurrentTest in utests_inc - TestSetup - g_Test.Do_ m_CurrentTest.ScriptPath, "test_setup", Me - Next - For Each m_CurrentTest in utests_dec - TestSetup - g_Test.Do_ m_CurrentTest.ScriptPath, "test_start", Me - Next - For Each m_CurrentTest in utests_dec - TestSetup - g_Test.Do_ m_CurrentTest.ScriptPath, "test_check", Me - Next - For Each m_CurrentTest in utests_dec - TestSetup - g_Test.Do_ m_CurrentTest.ScriptPath, "test_clean", Me - Next - g_Test.Finish - Else - Set m_CurrentTest = m_Sets.Item( m_CurrentSymbol ) - g_Test.m_DefLogFName = g_fs.GetParentFolderName( m_CurrentTest.ScriptPath ) + "\" + g_fs.GetFileName( g_Test.m_DefLogFName ) - g_Test.Start - TestCurrentSetup - g_Test.Do_ m_CurrentTest.ScriptPath, "test_current", Me - TestSetup - g_Test.Do_ m_CurrentTest.ScriptPath, "test_build", Me - TestSetup - g_Test.Do_ m_CurrentTest.ScriptPath, "test_setup", Me - TestSetup - g_Test.Do_ m_CurrentTest.ScriptPath, "test_start", Me - TestSetup - g_Test.Do_ m_CurrentTest.ScriptPath, "test_check", Me - TestSetup - g_Test.Do_ m_CurrentTest.ScriptPath, "test_clean", Me - g_Test.Finish - End If - m_bAllTest = False -End Sub - - - -'******************************************************************************** -' <<< [Tests::TestCurrentSetup] >>> -'******************************************************************************** -Private Sub TestCurrentSetup() - m_Symbol = m_CurrentTest.Symbol - CurrentTestPriority = m_CurrentTest.Priority - g_Test.m_Pass = True -End Sub - - -'******************************************************************************** -' <<< [Tests::TestSetup] >>> -'******************************************************************************** -Private Sub TestSetup() - m_Symbol = m_CurrentTest.Symbol - g_Test.m_Pass = False -End Sub - - -'******************************************************************************** -' <<< [Tests::SetCur] >>> -'******************************************************************************** -Public Sub SetCur( SubSymbol ) - m_CurrentSubSymbol = SubSymbol -End Sub - - -'******************************************************************************** -' <<< [Tests::IsCur] >>> -'******************************************************************************** -Public Function IsCur( SubSymbol ) - If m_CurrentSubSymbol = "ALL" Or m_CurrentSubSymbol = "ALL_R" Or _ - m_CurrentSubSymbol = SubSymbol Then - IsCur = True - Else - IsCur = False - End IF -End Function - - -End Class - -'******************************************************************************** -' <<< [CmpUnitTestPriorityInc] >>> -'******************************************************************************** -Function CmpUnitTestPriorityInc( left, right, param ) - CmpUnitTestPriorityInc = left.Priority - right.Priority -End Function - -'******************************************************************************** -' <<< [CmpUnitTestPriorityDec] >>> -'******************************************************************************** -Function CmpUnitTestPriorityDec( left, right, param ) - CmpUnitTestPriorityDec = right.Priority - left.Priority -End Function - -'*-------------------------------------------------------------------------* -'* Ÿ<<<< [UnitTest] Class >>>> */ -'*-------------------------------------------------------------------------* -Class UnitTest - - Public Symbol ' As String - Public ScriptPath ' As String - Public Priority ' As Integer - - '---------------------------------- - Private Sub Class_Initialize - Symbol = "NoSymbol" - ScriptPath = "" - End Sub - - Public Function Value - Value = "[" & Symbol & "]" & vbCR & vbLF & " " & ScriptPath - End Function - - Public Function PathToAbs( BaseFolderPath ) - Dim s - PathToAbs = True - s = g_fs.GetAbsolutePathName( BaseFolderPath & "\" & ScriptPath ) - If Not g_fs.FileExists( s ) Then echo "[ERROR] Not found " + ScriptPath + ", Base=" + BaseFolderPath : PathToAbs = False - ScriptPath = s - End Function - -End Class - - - -'*-------------------------------------------------------------------------* -'* Ÿ<<<< Test Result >>>> */ -'*-------------------------------------------------------------------------* - - -'******************************************************************************** -' <<< [Pass] >>> -'******************************************************************************** -Sub Pass - If IsEmpty( g_Test ) Then - WScript.Quit Err_TestPass - ElseIf IsEmpty( g_Test.m_Log ) Then - WScript.Echo "Pass" - WScript.Quit Err_TestPass - Else - g_Test.m_Pass = True - End If -End Sub - - - - -'******************************************************************************** -' <<< [Fail] >>> -'******************************************************************************** -Sub Fail() - If IsEmpty( g_Test ) Then - WScript.Quit Err_TestFail - ElseIf IsEmpty( g_Test.m_Log ) Then - WScript.Echo "Fail" - WScript.Quit Err_TestFail - Else - Err.Raise Err_TestFail, "VBSLib TestScript", "Fail the Test" - End If -End Sub - - - - -'******************************************************************************** -' <<< [Skip] >>> -'******************************************************************************** -Sub Skip() - If IsEmpty( g_Test ) Then - WScript.Quit Err_TestSkip - ElseIf IsEmpty( g_Test.m_Log ) Then - WScript.Echo "Skip" - WScript.Quit Err_TestSkip - Else - Err.Raise Err_TestSkip, "VBSLib TestScript", "Skip the Test" - End If -End Sub - - - - -'******************************************************************************** -' <<< [ManualTest] >>> -'******************************************************************************** -Sub ManualTest( TestSymbol ) - echo "<<< ["+TestSymbol+"] >>>" - echo "This is ManualTest." - g_Test.AddManualTest TestSymbol -End Sub - - -'*-------------------------------------------------------------------------* -'* Ÿ<<<< Tools for Test Program >>>> */ -'*-------------------------------------------------------------------------* - - -'******************************************************************************** -' <<< [EchoTestStart] >>> -'******************************************************************************** -Sub EchoTestStart( TestSymbol ) - echo "<<< ["+TestSymbol+"] >>>" -End Sub - - - -'******************************************************************************** -' <<< [echo] >>> -' return: output message -'******************************************************************************** -Function echo( ByVal msg ) - If IsObject( msg ) Then msg = msg.Value - - WScript.Echo msg - If Not IsEmpty( g_Test.m_Log ) Then g_Test.m_Log.WriteLine msg - echo = msg -End Function - - - -'******************************************************************************** -' <<< [CheckTestErrLevel] >>> -'******************************************************************************** -Sub CheckTestErrLevel( r ) - If r = Err_TestSkip Then - Skip - ElseIf r <> Err_TestPass Then - Fail - End If -End Sub - - - -'******************************************************************************** -' <<< [ConvertToAbsPath] >>> -'******************************************************************************** -Sub ConvertToAbsPath( SrcPath, DstPath ) - Dim src, dst, dst_parent, line, p1, p2, path - - Set src = g_fs.OpenTextFile( SrcPath ) - mkdir g_fs.GetParentFolderName( g_fs.GetAbsolutePathName( DstPath ) ) - Set dst = g_fs.CreateTextFile( DstPath, True, False ) - - Do Until src.AtEndOfStream - line = src.ReadLine - Do - p1 = InStr( line, "%AbsPath(" ) - If p1 = 0 Then Exit Do - p2 = InStr( p1 + 9, line, ")%" ) - path = Mid( line, p1+9, p2-p1-9 ) - path = GetAbsPath( path, g_fs.GetParentFolderName( g_fs.GetAbsolutePathName( SrcPath ) ) ) - line = Left( line, p1 - 1 ) + path + Mid( line, p2 + 2 ) - Loop - line = Replace( line, "%DesktopPath%", g_sh.SpecialFolders("Desktop") ) - dst.WriteLine line - Loop -DstPath = "a" - src = Empty - dst = Empty -End Sub - -