lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mhern...@apache.org
Subject [Lucene.Net] svn commit: r1142085 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g: .gitignore test/core/Index/TestBackwardsCompatibility.cs test/core/Lucene.Net.Test.csproj test/core/Util/LuceneTestCase.cs test/core/Util/Paths.cs test/core/Util/TestPaths.cs
Date Fri, 01 Jul 2011 20:32:37 GMT
Author: mherndon
Date: Fri Jul  1 20:32:36 2011
New Revision: 1142085

URL: http://svn.apache.org/viewvc?rev=1142085&view=rev
Log:
merging the ignore file again, git svn is having issues with it

Added:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Util/Paths.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Util/TestPaths.cs
Modified:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/.gitignore
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Index/TestBackwardsCompatibility.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Lucene.Net.Test.csproj
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Util/LuceneTestCase.cs

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/.gitignore
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/.gitignore?rev=1142085&r1=1142084&r2=1142085&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/.gitignore (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/.gitignore Fri Jul  1 20:32:36 2011
@@ -9,4 +9,5 @@ obj
 *.vs10x
 *.VisualState.xml
 *.userprefs
-*.pidb
\ No newline at end of file
+*.pidb
+test-results

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Index/TestBackwardsCompatibility.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Index/TestBackwardsCompatibility.cs?rev=1142085&r1=1142084&r2=1142085&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Index/TestBackwardsCompatibility.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Index/TestBackwardsCompatibility.cs
Fri Jul  1 20:32:36 2011
@@ -30,6 +30,7 @@ using ScoreDoc = Lucene.Net.Search.Score
 using TermQuery = Lucene.Net.Search.TermQuery;
 using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
 using _TestUtil = Lucene.Net.Util._TestUtil;
+using Lucene.Net.Util;
 
 namespace Lucene.Net.Index
 {
@@ -123,7 +124,7 @@ namespace Lucene.Net.Index
 		{
 			for (int i = 0; i < oldNames.Length; i++)
 			{
-				System.String dirName = "../../test/core/index/index." + oldNames[i];
+				System.String dirName = Paths.CombinePath(Paths.ProjectRootDirectory, "test/core/index/index."
+ oldNames[i]);
 				Unzip(dirName, oldNames[i]);
 				System.String fullPath = FullDir(oldNames[i]);
 				Directory dir = FSDirectory.Open(new System.IO.FileInfo(fullPath));
@@ -142,7 +143,7 @@ namespace Lucene.Net.Index
 		{
 			for (int i = 0; i < oldNames.Length; i++)
 			{
-                System.String dirName = "../../test/core/index/index." + oldNames[i];
+                System.String dirName = Paths.CombinePath(Paths.ProjectRootDirectory, "test/core/index/index."
+ oldNames[i]);
 				Unzip(dirName, oldNames[i]);
 				searchIndex(oldNames[i], oldNames[i]);
 				RmDir(oldNames[i]);
@@ -154,7 +155,7 @@ namespace Lucene.Net.Index
 		{
 			for (int i = 0; i < oldNames.Length; i++)
 			{
-                System.String dirName = "../../test/core/index/index." + oldNames[i];
+                System.String dirName = Paths.CombinePath(Paths.ProjectRootDirectory, "test/core/index/index."
+ oldNames[i]);
 				Unzip(dirName, oldNames[i]);
 				ChangeIndexNoAdds(oldNames[i], true);
 				RmDir(oldNames[i]);
@@ -170,7 +171,7 @@ namespace Lucene.Net.Index
 		{
 			for (int i = 0; i < oldNames.Length; i++)
 			{
-                System.String dirName = "../../test/core/index/index." + oldNames[i];
+                System.String dirName = Paths.CombinePath(Paths.ProjectRootDirectory, "test/core/index/index."
+ oldNames[i]);
 				Unzip(dirName, oldNames[i]);
 				ChangeIndexWithAdds(oldNames[i], true);
 				RmDir(oldNames[i]);

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Lucene.Net.Test.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Lucene.Net.Test.csproj?rev=1142085&r1=1142084&r2=1142085&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Lucene.Net.Test.csproj (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Lucene.Net.Test.csproj Fri Jul
 1 20:32:36 2011
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="4.0">
   <PropertyGroup>
     <ProjectType>Local</ProjectType>
@@ -7,13 +7,9 @@
     <ProjectGuid>{AAF68BCF-F781-45FC-98B3-2B9CEE411E01}</ProjectGuid>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ApplicationIcon>
-    </ApplicationIcon>
     <AssemblyKeyContainerName>
     </AssemblyKeyContainerName>
     <AssemblyName>Lucene.Net.Test</AssemblyName>
-    <AssemblyOriginatorKeyFile>
-    </AssemblyOriginatorKeyFile>
     <DefaultClientScript>JScript</DefaultClientScript>
     <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
     <DefaultTargetSchema>IE50</DefaultTargetSchema>
@@ -21,8 +17,6 @@
     <OutputType>Library</OutputType>
     <RootNamespace>Lucene.Net.Test</RootNamespace>
     <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
-    <StartupObject>
-    </StartupObject>
     <FileUpgradeFlags>
     </FileUpgradeFlags>
     <UpgradeBackupLocation>
@@ -47,9 +41,7 @@
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <OutputPath>..\..\bin\core\Debug\</OutputPath>
-    <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
     <BaseAddress>285212672</BaseAddress>
-    <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
     <ConfigurationOverrideFile>
     </ConfigurationOverrideFile>
     <DefineConstants>TRACE;DEBUG;SHARP_ZIP_LIB</DefineConstants>
@@ -57,54 +49,31 @@
     </DocumentationFile>
     <DebugSymbols>true</DebugSymbols>
     <FileAlignment>4096</FileAlignment>
-    <NoStdLib>false</NoStdLib>
-    <NoWarn>
-    </NoWarn>
     <Optimize>false</Optimize>
     <RegisterForComInterop>false</RegisterForComInterop>
     <RemoveIntegerChecks>false</RemoveIntegerChecks>
-    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
     <WarningLevel>4</WarningLevel>
     <DebugType>full</DebugType>
     <ErrorReport>prompt</ErrorReport>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <OutputPath>..\..\bin\core\</OutputPath>
-    <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
     <BaseAddress>285212672</BaseAddress>
-    <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
     <ConfigurationOverrideFile>
     </ConfigurationOverrideFile>
     <DefineConstants>TRACE;SHARP_ZIP_LIB</DefineConstants>
     <DocumentationFile>
     </DocumentationFile>
-    <DebugSymbols>false</DebugSymbols>
     <FileAlignment>4096</FileAlignment>
-    <NoStdLib>false</NoStdLib>
-    <NoWarn>
-    </NoWarn>
     <Optimize>true</Optimize>
     <RegisterForComInterop>false</RegisterForComInterop>
     <RemoveIntegerChecks>false</RemoveIntegerChecks>
-    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
     <WarningLevel>4</WarningLevel>
     <DebugType>none</DebugType>
     <ErrorReport>prompt</ErrorReport>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral,
processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\lib\ICSharpCode\SharpZipLib\0.85\ICSharpCode.SharpZipLib.dll</HintPath>
-    </Reference>
     <Reference Include="Microsoft.CSharp" />
-    <Reference Include="nunit.framework, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77,
processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\lib\NUnit.org\NUnit\2.5.9\bin\net-2.0\framework\nunit.framework.dll</HintPath>
-    </Reference>
-    <Reference Include="nunit.mocks, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77,
processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\lib\NUnit.org\NUnit\2.5.9\bin\net-2.0\framework\nunit.mocks.dll</HintPath>
-    </Reference>
     <Reference Include="System">
       <Name>System</Name>
     </Reference>
@@ -117,6 +86,18 @@
     <Reference Include="System.Xml">
       <Name>System.XML</Name>
     </Reference>
+    <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral,
PublicKeyToken=1b03e6acf1164f73">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\lib\ICSharpCode\SharpZipLib\0.85\ICSharpCode.SharpZipLib.dll</HintPath>
+    </Reference>
+    <Reference Include="nunit.framework, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\lib\NUnit.org\NUnit\2.5.9\bin\net-2.0\framework\nunit.framework.dll</HintPath>
+    </Reference>
+    <Reference Include="nunit.mocks, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\lib\NUnit.org\NUnit\2.5.9\bin\net-2.0\framework\nunit.mocks.dll</HintPath>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Analysis\BaseTokenStreamTestCase.cs" />
@@ -505,6 +486,8 @@
     <None Include="Index\index.23.nocfs.zip" />
     <None Include="Index\index.24.cfs.zip" />
     <None Include="Index\index.24.nocfs.zip" />
+    <Compile Include="Util\Paths.cs" />
+    <Compile Include="Util\TestPaths.cs" />
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="Messages\MessagesTestBundle.ja.resources">

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Util/LuceneTestCase.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Util/LuceneTestCase.cs?rev=1142085&r1=1142084&r2=1142085&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Util/LuceneTestCase.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Util/LuceneTestCase.cs Fri Jul
 1 20:32:36 2011
@@ -49,12 +49,14 @@ namespace Lucene.Net.Util
 	public abstract class LuceneTestCase
 	{
 		public static  System.IO.FileInfo TEMP_DIR;
+
+
         static LuceneTestCase()
         {
-            String s = System.Environment.GetEnvironmentVariable("TEMP");
-            if (s == null)
-                throw new  Exception("To run tests, you need to define system property 'temp'");
-            TEMP_DIR = new System.IO.FileInfo(s);
+			// TODO: remove dependency on TEMP_DIR and remove static constructor from test base.
+            String directory = Paths.TempDirectory;
+
+            TEMP_DIR = new System.IO.FileInfo(directory);
         }
 
 		[NonSerialized]

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Util/Paths.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Util/Paths.cs?rev=1142085&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Util/Paths.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Util/Paths.cs Fri Jul  1 20:32:36
2011
@@ -0,0 +1,169 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.IO;
+
+namespace Lucene.Net.Util
+{
+	/// <summary>
+	/// The static accessor class for file paths used in testing. 
+	/// </summary>
+	public static class Paths
+	{
+		private static string s_tempDirectory = null;
+		private static string s_testDocDirectory = null;
+        private static string s_assemblyDirectory = null;
+        private static string s_projectRootDirectory = null;
+		
+		/// <summary>
+		/// Gets the temp directory.
+		/// </summary>
+		/// <value>
+		/// The temp directory.
+		/// </value>
+		/// <remarks>
+		/// 	<para>
+		/// 		The temp directory first looks at the app settings for the &qt;tempDir&qt;

+		/// 		key. If the path does not exists or the setting is empty, the temp directory
+		/// 		fall back to using the environment's temp directory path and 
+		/// 		append &qt;lucene-net&qt; to it. 
+		/// 	</para>
+		/// </remarks>
+		public static string TempDirectory
+		{
+			get
+			{
+				if(s_tempDirectory == null)
+				{
+					string tempDirectory = Lucene.Net.Support.AppSettings.Get("tempDir", "");
+					
+					if(string.IsNullOrWhiteSpace(tempDirectory) || 
+						!Directory.Exists(tempDirectory))
+					{
+						tempDirectory = CombinePath(Path.GetTempPath(), "lucene-net");
+						
+						if(!Directory.Exists(tempDirectory))
+							Directory.CreateDirectory(tempDirectory);
+						
+					}
+					s_tempDirectory = tempDirectory;
+				}
+		
+				return s_tempDirectory;
+			}	
+		}
+		
+		/// <summary>
+		/// Gets the test document directory.
+		/// </summary>
+		/// <value>
+		/// The test document directory.
+		/// </value>
+		public static string TestDocDirectory
+		{
+			get
+			{
+				if(s_testDocDirectory == null)
+				{
+					s_testDocDirectory = CombinePath(TempDirectory, "TestDoc");	
+				}
+				return s_testDocDirectory;
+			}
+		}
+
+        /// <summary>
+        /// Gets the directory where the compiled assembly Lucene.Net.Tests is found.
+        /// We use Assembly.CodeBase in case NUnit or the current test runner 
+        /// has shadow copy enabled. 
+        /// </summary>
+        public static string AssemblyDirectory
+        {
+            get
+            {
+                if(s_assemblyDirectory == null)
+                {
+                    s_assemblyDirectory = typeof(Paths).Assembly.CodeBase;
+                  
+
+                    // ensure that we're only getting the directory.
+                    s_assemblyDirectory = Path.GetDirectoryName(s_assemblyDirectory);
+                    
+                    // CodeBase uses unc path, get rid of the file prefix if it exists. 

+                    if (s_assemblyDirectory.StartsWith("file:"))
+                        s_assemblyDirectory = s_assemblyDirectory.Replace(("file:" + Path.DirectorySeparatorChar).ToString(),
"");
+                }
+                return s_assemblyDirectory;
+            }
+        }
+
+        /// <summary>
+        /// Gets the root directory for the project. e.g. if you were working on trunk
+        /// it would be the trunk directory. 
+        /// </summary>
+        public static string ProjectRootDirectory
+        {
+            get
+            {
+                if (s_projectRootDirectory == null)
+                {
+                    // we currently assume that the assembly's directory is root/bin/[Section]/[Build]
+                    // where [Section] is either core, demo, or contrib, and [Build] is either
Debug or Release.  
+                    var assemblyLocation = AssemblyDirectory;
+                    s_projectRootDirectory = CombinePath(assemblyLocation, "..", "..", "..");
+                }
+                return s_projectRootDirectory;
+            }
+
+        }
+		
+		/// <summary>
+		/// Combines the path.
+		/// </summary>
+		/// <returns>
+		/// The path.
+		/// </returns>
+		/// <param name='startSegment'>
+		/// Start segment of the path.
+		/// </param>
+		/// <param name='segments'>
+		/// Path segments e.g. directory or file names.
+		/// </param>
+		/// <exception cref='ArgumentNullException'>
+		/// Is thrown when an argument passed to a method is invalid because it is <see langword="null"
/> .
+		/// </exception>
+		/// <exception cref='InvalidOperationException'>
+		/// Is thrown when an operation cannot be performed.
+		/// </exception>
+		internal static string CombinePath(string startSegment, params string[] segments)
+		{
+			if(startSegment == null)
+				throw new ArgumentNullException(startSegment);
+			
+			if(segments == null || segments.Length == 0)
+				throw new InvalidOperationException("Paths can not be combined"+
+					" unless the startSegment and one additional segment is present.");
+			
+			string path = startSegment;
+			
+			foreach(string segment in segments)
+				path = System.IO.Path.Combine(path, segment);
+			
+			return path;
+		}
+	}
+}

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Util/TestPaths.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Util/TestPaths.cs?rev=1142085&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Util/TestPaths.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Util/TestPaths.cs Fri Jul  1
20:32:36 2011
@@ -0,0 +1,52 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.IO;
+
+namespace Lucene.Net.Util
+{
+	using NUnit.Framework;
+	
+	[TestFixture]
+	[Category("Infrastructure")]
+	public class TestPaths
+	{
+		
+		[Test]
+		public void ValidateTempDirectory()
+		{
+			string tempDir = null;
+			
+			try 
+			{
+			   tempDir = Paths.TempDirectory;
+			} 
+			catch(Exception ex) 
+			{	
+				Assert.Fail(
+					"An exception occurred when attempting to get the temp directory. " +
+					" The tests are heavily dependant on being able to access that directory existing "
+
+					" and being accessible to the account running the tests. \n\n exception: " +
+					ex.Message + "\n\n stack trace: " + ex.StackTrace); 
+			}
+			Console.WriteLine(tempDir);
+			Assert.True(Directory.Exists(tempDir), "The temp directory should exist: " + tempDir);
+		}
+	}
+}
+



Mime
View raw message