Author: bamboo
Date: 2006-04-17 14:41:27 -0400 (Mon, 17 Apr 2006)
New Revision: 59546

Modified:
   trunk/cecil/tests/ChangeLog
   trunk/cecil/tests/Mono.Cecil.Tests/AssemblyCreationTestFixture.boo
   trunk/cecil/tests/Mono.Cecil.Tests/Globals.boo
   trunk/cecil/tests/Mono.Cecil.Tests/RegressionTestFixture.boo
   trunk/cecil/tests/Mono.Cecil.Tests/RoundtripTestFixture.boo
Log:
execute peverify.exe for additional level of protection

Modified: trunk/cecil/tests/ChangeLog
===================================================================
--- trunk/cecil/tests/ChangeLog 2006-04-17 18:22:43 UTC (rev 59545)
+++ trunk/cecil/tests/ChangeLog 2006-04-17 18:41:27 UTC (rev 59546)
@@ -1,3 +1,11 @@
+2006-03-17     Rodrigo B. de Oliveira  <[EMAIL PROTECTED]>
+
+       * Mono.Cecil.Tests/Globals.boo
+         Mono.Cecil.Tests/RegressionTestFixture.boo
+         Mono.Cecil.Tests/AssemblyCreationTestFixture.boo
+         Mono.Cecil.Tests/RoundtripTestFixture.boo:
+               Execute peverify.exe for additional level of protection.
+
 2006-03-06  Rodrigo B. de Oliveira  <[EMAIL PROTECTED]>
 
        * Mono.Cecil.Tests/RoundtripTestFixture.boo:

Modified: trunk/cecil/tests/Mono.Cecil.Tests/AssemblyCreationTestFixture.boo
===================================================================
--- trunk/cecil/tests/Mono.Cecil.Tests/AssemblyCreationTestFixture.boo  
2006-04-17 18:22:43 UTC (rev 59545)
+++ trunk/cecil/tests/Mono.Cecil.Tests/AssemblyCreationTestFixture.boo  
2006-04-17 18:41:27 UTC (rev 59546)
@@ -22,7 +22,7 @@
                worker.Emit(OpCodes.Call, ImportConsoleWriteLine())
                worker.Emit(OpCodes.Ret)        
                
-               ExecuteAssemblyAndExpect("Hello, world!")
+               ExecuteAndExpect("Hello, world!")
                
        [Test]
        def HelloGenericWorld():
@@ -45,7 +45,7 @@
                
                worker.Emit(OpCodes.Ret)
                
-               ExecuteAssemblyAndExpect("Foo")
+               ExecuteAndExpect("Foo")
                
                
        def SetUpAssembly(assemblyName as string):
@@ -66,11 +66,10 @@
        def ImportConsoleWriteLine():
                return Import(typeof(Console).GetMethod("WriteLine", (string,)))
                
-       def ExecuteAssemblyAndExpect(expected as string):
+       def ExecuteAndExpect(expected as string):
                fname = BuildTempPath("${_assembly.Name.Name}.exe")
                AssemblyFactory.SaveAssembly(_assembly, fname)
-               output = ExecuteAssembly(fname)
-               Assert.AreEqual(expected.Trim(), output.Trim())
+               ExecuteAssemblyAndExpect(fname, expected)
                
        def Import(type as System.Type):
                return _assembly.MainModule.Import(type)

Modified: trunk/cecil/tests/Mono.Cecil.Tests/Globals.boo
===================================================================
--- trunk/cecil/tests/Mono.Cecil.Tests/Globals.boo      2006-04-17 18:22:43 UTC 
(rev 59545)
+++ trunk/cecil/tests/Mono.Cecil.Tests/Globals.boo      2006-04-17 18:41:27 UTC 
(rev 59546)
@@ -13,9 +13,23 @@
        
 def ExecuteAssembly(fname as string):
        CopyBooLangTo(Path.GetDirectoryName(fname))
-       return shellm(fname, (of string:,))     
+       return shell(fname, "")
+       
+def ExecuteAssemblyAndExpect(fname as string, expected as string):
+       output = ExecuteAssembly(fname)
+       NUnit.Framework.Assert.AreEqual(expected.Trim(), 
output.Trim().Replace("\r\n", "\n"))
+       VerifyAssembly(fname)
 
 def CopyBooLangTo(path as string):
        fname = typeof(List).Module.FullyQualifiedName
        target = Path.Combine(path, Path.GetFileName(fname))
        File.Copy(fname, target) unless File.Exists(target)
+       
+def VerifyAssembly(location as string):
+       try:
+               process = shellp("peverify.exe", "\"${location}\"")
+       except x:
+               raise "Failed to run peverify.exe, maybe it's not on your 
path?\n${x}"
+       output = process.StandardOutput.ReadToEnd()
+       process.WaitForExit()
+       if 0 != process.ExitCode: raise output

Modified: trunk/cecil/tests/Mono.Cecil.Tests/RegressionTestFixture.boo
===================================================================
--- trunk/cecil/tests/Mono.Cecil.Tests/RegressionTestFixture.boo        
2006-04-17 18:22:43 UTC (rev 59545)
+++ trunk/cecil/tests/Mono.Cecil.Tests/RegressionTestFixture.boo        
2006-04-17 18:41:27 UTC (rev 59546)
@@ -40,7 +40,12 @@
                return CecilAssemblyPrinter.ToString(asm)
                
        static def GetTestCasesLocation():
-               return Path.Combine(
-                       
Path.GetDirectoryName(typeof(RegressionTestFixture).Module.FullyQualifiedName),
-                       "../TestCases")
+               basePath = 
Path.GetDirectoryName(System.Uri(typeof(RegressionTestFixture).Assembly.CodeBase).LocalPath)
+               while true:
+                       location = Path.Combine(basePath, "TestCases")
+                       return location if Directory.Exists(location)
+                       oldBasePath = basePath
+                       basePath = Path.GetDirectoryName(basePath)
+                       break if oldBasePath == basePath
+               raise "TestCases path not found!"
        

Modified: trunk/cecil/tests/Mono.Cecil.Tests/RoundtripTestFixture.boo
===================================================================
--- trunk/cecil/tests/Mono.Cecil.Tests/RoundtripTestFixture.boo 2006-04-17 
18:22:43 UTC (rev 59545)
+++ trunk/cecil/tests/Mono.Cecil.Tests/RoundtripTestFixture.boo 2006-04-17 
18:41:27 UTC (rev 59546)
@@ -33,9 +33,10 @@
                }
        }
 }"""
-               InstrumentAndExecute("1\n2\n3", "GenericEnumerator", code) do 
(assembly as AssemblyDefinition):
-                       pass // no instrumentation for now
+               InstrumentAndExecute("1\n2\n3", "GenericEnumerator", code, 
NoInstrumentation)           
                
+       def NoInstrumentation(assembly as AssemblyDefinition):
+               pass
                
        [Test]
        def ReplaceByGenericInstanceMethod():
@@ -82,18 +83,22 @@
                for instr as Instruction in body.Instructions:
                        if instr.OpCode.Value == opcode.Value:
                                return instr
+                               
+       callable Instrumentation(assembly as AssemblyDefinition)
 
        def InstrumentAndExecute(expectedOutput as string, assemblyName as 
string, code as string,
-                                                       instrument as 
callable(AssemblyDefinition)):
+                                                       instrument as 
Instrumentation):
+                                                               
+               assembly = Instrument(assemblyName, code, instrument)
+               
+               roundtripped = BuildTempPath(Path.Combine("after", 
"${assemblyName}.exe"))
+               AssemblyFactory.SaveAssembly(assembly, roundtripped)
+               ExecuteAssemblyAndExpect(roundtripped, expectedOutput)
+               
+       def Instrument(assemblyName as string, code as string, instrument as 
Instrumentation):
                fname = BuildTempPath(Path.Combine("before", 
"${assemblyName}.exe"))
                EmitCSharpAssembly(fname, code)
                assembly = AssemblyFactory.GetAssembly(fname)
-               
                instrument(assembly) if instrument is not null
-               
-               roundtripped = BuildTempPath(Path.Combine("after", 
"${assemblyName}.exe"))
-               AssemblyFactory.SaveAssembly(assembly, roundtripped)
-               
-               output = ExecuteAssembly(roundtripped)
-               Assert.AreEqual(expectedOutput.Trim(), output.Trim())
+               return assembly
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to