|
From: <Or...@us...> - 2008-09-21 08:13:53
|
Revision: 368
http://acmcontester.svn.sourceforge.net/acmcontester/?rev=368&view=rev
Author: Oracle_
Date: 2008-09-21 08:13:45 +0000 (Sun, 21 Sep 2008)
Log Message:
-----------
Added global exception.
Modified Paths:
--------------
ACMServer/trunk/sharp tester/SourceTest 2.0/Main/TestEnvClass.cs
ACMServer/trunk/sharp tester/SourceTest 2.0/Test/Test.cpp
Modified: ACMServer/trunk/sharp tester/SourceTest 2.0/Main/TestEnvClass.cs
===================================================================
--- ACMServer/trunk/sharp tester/SourceTest 2.0/Main/TestEnvClass.cs 2008-09-20 22:01:36 UTC (rev 367)
+++ ACMServer/trunk/sharp tester/SourceTest 2.0/Main/TestEnvClass.cs 2008-09-21 08:13:45 UTC (rev 368)
@@ -7,16 +7,11 @@
{
public class TesterException : ApplicationException
{
+ public TesterException(string message,Exception innerException) : base(message,innerException) { }
public TesterException(string message) : base(message) { }
public TesterException() : base() { }
}
- public class IncorrectFileException : ApplicationException
- {
- public IncorrectFileException(string message) : base(message) { }
- public IncorrectFileException() : base() { }
- }
-
public class TestEnv
{
public string ProblemPath;
@@ -28,74 +23,111 @@
public TestEnv(string Source,string CompPath,string TempPath,string ProblemPath)
{
- this.Source = Source;
- this.TempPath = Path.GetFullPath(TempPath);
- if (!Directory.Exists(this.TempPath))
- Directory.CreateDirectory(this.TempPath);
- this.CompPath = Path.GetFullPath(CompPath);
- if (!File.Exists(this.CompPath))
- throw new FileNotFoundException("Compiler file do not exists!");
- this.ProblemPath = Path.GetFullPath(ProblemPath);
- if (!Directory.Exists(this.ProblemPath))
- throw new DirectoryNotFoundException("Problem path do not exists!");
+ try
+ {
+ this.Source = Source;
+ this.TempPath = Path.GetFullPath(TempPath);
+ if (!Directory.Exists(this.TempPath))
+ Directory.CreateDirectory(this.TempPath);
+ this.CompPath = Path.GetFullPath(CompPath);
+ if (!File.Exists(this.CompPath))
+ throw new FileNotFoundException("Compiler file do not exists!");
+ this.ProblemPath = Path.GetFullPath(ProblemPath);
+ if (!Directory.Exists(this.ProblemPath))
+ throw new DirectoryNotFoundException("Problem path do not exists!");
+ }
+ catch (Exception e)
+ {
+ throw new TesterException("Exception in creating TestEnv",e);
+ }
}
public void Compile()
{
- if (comp == null)
+ try
{
- if (!File.Exists(ProblemPath + "ProblemData.txt"))
- throw new FileNotFoundException("ProblemData.txt do not exists");
- DataLoader dat = new DataLoader(ProblemPath + "ProblemData.txt");
- if (!dat.Load())
- throw new IncorrectFileException("Can not load data from ProblemData.txt");
+ if (comp == null)
+ {
+ if (!File.Exists(ProblemPath + "ProblemData.txt"))
+ throw new FileNotFoundException("ProblemData.txt do not exists");
+ DataLoader dat = new DataLoader(ProblemPath + "ProblemData.txt");
+ if (!dat.Load())
+ throw new FileLoadException("Can not load data from ProblemData.txt");
- if (!File.Exists("TesterInData.txt"))
- throw new FileNotFoundException("TesterInData.txt do not exists");
- string[] InData = System.IO.File.ReadAllLines("TesterInData.txt");
- if (InData.Length < 1)
- throw new IncorrectFileException("Can not load data from ProblemData.txt");
- int buf;
- try
- {
- buf = Convert.ToInt32(InData[0]);
+ if (!File.Exists("TesterInData.txt"))
+ throw new FileNotFoundException("TesterInData.txt do not exists");
+ string[] InData = System.IO.File.ReadAllLines("TesterInData.txt");
+ if (InData.Length < 1)
+ throw new FileLoadException("Can not load data from ProblemData.txt");
+ int buf;
+ try
+ {
+ buf = Convert.ToInt32(InData[0]);
+ }
+ catch (Exception e)
+ {
+ throw new FileLoadException("Can not load sleep time from TesterInData.txt " + e.Message);
+ }
+
+ comp = new Compiler(CompPath, Source, TempPath, dat.CompilationTimeLimit, buf);
}
- catch (Exception e)
- {
- throw new IncorrectFileException("Can not load sleep time from TesterInData.txt " + e.Message);
- }
-
- comp = new Compiler(CompPath, Source, TempPath, dat.CompilationTimeLimit, buf);
+ comp.Compile();
}
- comp.Compile();
+ catch (Exception e)
+ {
+ throw new TesterException("Exception in compiling!",e);
+ }
}
- public void RunAllTests() { RunAllTests(SecureType.Double,true); }
- public void RunAllTests(SecureType SecType) { RunAllTests(SecType,true); }
+ public void RunAllTests()
+ {
+ RunAllTests(SecureType.Double,true);
+ }
+ public void RunAllTests(SecureType SecType)
+ {
+ RunAllTests(SecType,true);
+ }
public void RunAllTests(SecureType SecType, bool TestAll)
{
- if (run == null)
+ try
{
- if (comp == null)
- throw new TesterException("You should first compile source before running tests!");
- run = new Runner(SecType, ProblemPath, comp.ExeFile, TempPath, comp.CONST_SLEEP);
+ if (run == null)
+ {
+ if (comp == null)
+ throw new TesterException("You should first compile source before running tests!");
+ run = new Runner(SecType, ProblemPath, comp.ExeFile, TempPath, comp.CONST_SLEEP);
+ }
+ run.TestAll = TestAll;
+ run.RunTests();
}
- run.TestAll = TestAll;
- run.RunTests();
+ catch (Exception e)
+ {
+ throw new TesterException("Exception in running tests!",e);
+ }
}
- public void RunOneTest(int index) { RunOneTest(SecureType.Double,index); }
+ public void RunOneTest(int index)
+ {
+ RunOneTest(SecureType.Double,index);
+ }
public void RunOneTest(SecureType SecType, int index)
{
- if (run == null)
+ try
{
- if (comp == null)
- throw new TesterException("You should first compile source before running tests!");
- run = new Runner(SecType, ProblemPath, comp.ExeFile, TempPath, comp.CONST_SLEEP);
+ if (run == null)
+ {
+ if (comp == null)
+ throw new TesterException("You should first compile source before running tests!");
+ run = new Runner(SecType, ProblemPath, comp.ExeFile, TempPath, comp.CONST_SLEEP);
+ }
+ run.ExecuteTest(index);
}
- run.ExecuteTest(index);
+ catch (Exception e)
+ {
+ throw new TesterException("Exception in running test",e);
+ }
}
public void StopTesting()
Modified: ACMServer/trunk/sharp tester/SourceTest 2.0/Test/Test.cpp
===================================================================
--- ACMServer/trunk/sharp tester/SourceTest 2.0/Test/Test.cpp 2008-09-20 22:01:36 UTC (rev 367)
+++ ACMServer/trunk/sharp tester/SourceTest 2.0/Test/Test.cpp 2008-09-21 08:13:45 UTC (rev 368)
@@ -10,13 +10,17 @@
{
SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS); //for better testing
initlock();
+ if (!File::Exists(ProblemPath + "ProblemData.txt"))
+ throw gcnew FileNotFoundException("ProblemData not found!");
data = gcnew DataLoader(ProblemPath + "ProblemData.txt");
- data->Load();
+ if (!data->Load())
+ throw gcnew FileLoadException("Can not load problem data!");
testfield=gcnew TestLoader(data->InputName,data->OutputName,data->PointFileName,data->TestFolderName,ProblemPath);
testfield->Load();
results=gcnew array<TestRes^>(testfield->tests->Length);
plug=gcnew PluginLoader(System::IO::Path::GetFullPath(data->CheckPlugin));
- plug->Load();
+ if (!plug->Load())
+ throw gcnew FileLoadException("Can not load Plugin!");
exe=ExeFile;
prob=ProblemPath;
temp=TempPath;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|