Beispiel #1
0
        public WinDirStatViewModel()
        {
            model                            = new WinDirStatModel();
            settings                         = new WinDirStatSettings(this);
            extensions                       = new ExtensionRecordsViewModel(this);
            icons                            = new IconCache(this);
            fileComparer                     = new FileComparer();
            extensionComparer                = new ExtensionComparer();
            selectedFiles                    = new ObservableCollection <FileNodeViewModel>();
            selectedExtension                = null;
            model.PropertyChanged           += OnModelPropertyChanged;
            selectedFiles.CollectionChanged += OnSelectedFilesChanged;
            settings.PropertyChanged        += OnSettingsPropertyChanged;
            ramTimer                         = new DispatcherTimer(
                settings.RAMInterval,
                DispatcherPriority.Normal,
                OnRAMUsageTick,
                Application.Current.Dispatcher);
            statusTimer = new DispatcherTimer(
                settings.StatusInterval,
                DispatcherPriority.Normal,
                OnStatusTick,
                Application.Current.Dispatcher);
            statusTimer.Stop();
            validateTimer = new DispatcherTimer(
                settings.ValidateInterval,
                DispatcherPriority.Background,
                OnValidateTick,
                Application.Current.Dispatcher);
            validateTimer.Stop();

            ramUsage = GC.GetTotalMemory(false);
        }
Beispiel #2
0
        public void SameContent_CompareFiles_ReturnsTrue()
        {
            bool actual   = FileComparer.CompareFiles("SameContent.dll", "SameContent2.dll");
            bool expected = true;

            Assert.AreEqual(expected, actual);
        }
Beispiel #3
0
    public static async Task <VerifyResult> VerifyStreams(Stream stream, FilePair file)
    {
        stream.MoveToStart();

        try
        {
            await FileHelpers.WriteStream(file.Received, stream);

            var verifyResult = FileComparer.DoCompare(file.Received, file.Verified);

            if (verifyResult == VerifyResult.Equal)
            {
                File.Delete(file.Received);
                return(verifyResult);
            }

            return(verifyResult);
        }
        finally
        {
#if NETSTANDARD2_1
            await stream.DisposeAsync();
#else
            stream.Dispose();
#endif
        }
    }
Beispiel #4
0
    public static async Task <(Equality equality, string?message)> Streams(VerifySettings settings, Stream stream, FilePair file)
    {
        try
        {
            await FileHelpers.WriteStream(file.Received, stream);

            var result = await FileComparer.DoCompare(settings, file);

            if (result.equality == Equality.Equal)
            {
                File.Delete(file.Received);
                return(result);
            }

            return(result);
        }
        finally
        {
#if NETSTANDARD2_1
            await stream.DisposeAsync();
#else
            stream.Dispose();
#endif
        }
    }
Beispiel #5
0
        public override void ExecuteTask(ISpecialExecutionTaskTestAction testAction)
        {
            IParameter expectedFilePathParameter = testAction.GetParameter("ExpectedFile", false, new[] { ActionMode.Input });
            IParameter actualFilePathParameter   = testAction.GetParameter("ActualFile", false, new[] { ActionMode.Input });

            string expectedFilePath = Environment.ExpandEnvironmentVariables(expectedFilePathParameter.GetAsInputValue().Value);
            string actualFilePath   = Environment.ExpandEnvironmentVariables(actualFilePathParameter.GetAsInputValue().Value);
            string result           = String.Empty;

            try
            {
                result = FileComparer.Compare(expectedFilePath, actualFilePath);
            }
            catch (FileNotFoundException exc)
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Failed, exc.Message);
                return;
            }

            if (result == String.Empty)
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Ok, "The contents of the files are identical.");
            }
            else
            {
                testAction.SetResult(SpecialExecutionTaskResultState.Failed, result);
            }
        }
Beispiel #6
0
        public CheckInformation GetCheckInformation()
        {
            DirectoryInfo dirinfo = new DirectoryInfo(InPath);

            FileInfo[] files;
            if (dirinfo.Exists)
            {
                files = dirinfo.GetFiles("*.xml");
                if (files.Length > 0)
                {
                    FileComparer fc = new FileComparer();
                    Array.Sort(files, fc);
                    CheckInformation info = CheckInformation.LoadFromXmlFile(files[0].FullName);
                    return(info);
                }
                else
                {
                    return(new CheckInformation()
                    {
                        LoadSuccess = false, ExceptionMessage = "存放客户信息的路径里无客户信息文件。 " + InPath
                    });
                }
            }
            else
            {
                return(new CheckInformation()
                {
                    LoadSuccess = false, ExceptionMessage = "存放客户信息的文件夹不存在,请核对配置文件或者启动参数的路径是否正确。 " + InPath
                });
            }
        }
Beispiel #7
0
        private void button2_Click(object sender, EventArgs e)
        {
            handle_select        = false;
            this.blockbox.Text   = "";
            blocklist.DataSource = null;
            bool genera = extendedCheck.Checked;

            stopcollect       = false;
            groupBox1.Enabled = false;
            groupBox2.Enabled = false;
            f = new Facet();
            blocklist.DataSource = null;
            GC.Collect();
            String[]  files = Directory.GetFiles(textBox2.Text, "*.dat");
            IComparer icomp = new FileComparer();

            Array.Sort(files, icomp);
            progressBar1.Minimum = 0;
            progressBar1.Maximum = (parseOnly.Checked && numBlocks.Value > 0) ? (int)numBlocks.Value : files.Length;
            progressBar1.Value   = 0;
            errwr = new StreamWriter("error.log");
            outwr = null;
            if (genera)
            {
                outwr = new StreamWriter("outuput.log");
            }
            int div = (parseOnly.Checked && numBlocks.Value > 0) ? (int)numBlocks.Value : files.Length / 3;

            if (div > 50)
            {
                bw1.RunWorkerAsync(files);
            }
            else
            {
                foreach (String s in files)
                {
                    Parser    p = new Parser(s, errwr, outwr, writeOnlyCheck.Checked, DelimiterCheck.Checked, StaticCheck.Checked, TileCheck.Checked);
                    BlockFile b = p.Parse();
                    if (numBlocks.Value > 0 && f.blockfileslist.Count >= numBlocks.Value)
                    {
                        stopcollect = true;
                        if (parseOnly.Checked)
                        {
                            break;
                        }
                    }
                    if (!stopcollect)
                    {
                        f.blockfiles.AddLast(b);
                        f.blockfileslist.Add(b);
                    }
                    Inc();
                    if (closed)
                    {
                        break;
                    }
                }
                bw1_RunWorkerCompleted(null, null);
            }
        }
Beispiel #8
0
    async Task HandleScanMove(KeyValuePair <string, TrackedMove> pair)
    {
        void RemoveAndKill(KeyValuePair <string, TrackedMove> keyValuePair)
        {
            if (moves.TryRemove(keyValuePair.Key, out var removed))
            {
                KillProcesses(removed);
            }
        }

        var move = pair.Value;

        if (!File.Exists(move.Temp))
        {
            RemoveAndKill(pair);
            return;
        }

        if (!File.Exists(move.Target))
        {
            return;
        }

        if (await FileComparer.FilesAreEqual(move.Temp, move.Target))
        {
            RemoveAndKill(pair);
            return;
        }
    }
Beispiel #9
0
        public void DifferentContent_CompareFiles_ReturnsFalse()
        {
            bool actual   = FileComparer.CompareFiles("Newtonsoft.Json.dll", "SameContent2.dll");
            bool expected = false;

            Assert.AreEqual(expected, actual);
        }
Beispiel #10
0
        public void CompareFilesExpectedNotExists()
        {
            string expected = Path.Combine(Environment.CurrentDirectory, @"Files\bestaatniet.txt");
            string actual   = Path.Combine(Environment.CurrentDirectory, @"Files\TG1.out.txt");
            string result   = FileComparer.Compare(expected, actual);

            Assert.AreEqual("", result);
        }
 public static void Compare(string directoryPath)
 {
     if (!Directory.Exists(directoryPath))
     {
         return;
     }
     FileComparer.Compare(new DirectoryInfo(directoryPath));
 }
Beispiel #12
0
        private void Analyze(object sender, DoWorkEventArgs e)
        {
            var files = e.Argument as List <FileData>;
            var res   = FileComparer.CompareFiles(files);

            e.Cancel = false;
            e.Result = res;
        }
Beispiel #13
0
        private void diagramManager_DiagramClosed(object sender, DiagramClosedEventArgs e)
        {
            _settings.RecentFiles.Add(e.Diagram.File);

            _settings.OpenFiles
            .FirstOrNone(file => FileComparer.Equals(file, e.Diagram.File))
            .Apply(file => _settings.OpenFiles.Remove(file));
        }
Beispiel #14
0
        public void CompareFilesSame()
        {
            string expected = Path.Combine(Environment.CurrentDirectory, @"Files\TG1.controle.txt");
            string actual   = Path.Combine(Environment.CurrentDirectory, @"Files\TG1.out.txt");
            string result   = FileComparer.Compare(expected, actual);

            Assert.AreEqual("", result);
        }
Beispiel #15
0
        public void CompareFilesActualDifferent()
        {
            string expected = Path.Combine(Environment.CurrentDirectory, @"Files\TG1.controle.txt");
            string actual   = Path.Combine(Environment.CurrentDirectory, @"Files\Anders.txt");
            string result   = FileComparer.Compare(expected, actual);

            Assert.AreEqual("ActualFile contains the following differences:" + Environment.NewLine
                            + "1,3,3,2015-11-26,3,2015-12-01,2,2014-08-24,3,2015-03-19", result);
        }
Beispiel #16
0
        public static void FilesEqual(string expectedPath, string actualPath)
        {
            string error = FileComparer.BinaryEqual(expectedPath, actualPath);

            if (error != null)
            {
                Assert.Fail(error);
            }
        }
Beispiel #17
0
 void diagramIO_DiagramFileDeleted(object sender, DiagramFileDeletedEventArgs e)
 {
     Task.Factory.StartNew(() =>
                           PreviewDiagrams.FirstOrNone(pd => FileComparer.Equals(pd.Diagram.File, e.DeletedDiagramFile)).Apply(existingPreview =>
     {
         OnDiagramDeleted(existingPreview.Diagram);
         PreviewDiagrams.Remove(existingPreview);
     }), CancellationToken.None, TaskCreationOptions.None, _uiScheduler);
 }
        private List <SysFileIf> SelectFilesInFolder(DirectoryInfo curDir, List <SysSorter> condition)
        {
            List <SysFileIf> sortList = GetFileList(curDir);

            sortList = SelectSortFiles(sortList, "FileOnly");
            FileComparer newComparer = new FileComparer(condition);

            sortList.Sort(newComparer);
            return(sortList);
        }
 public async Task BinaryEquals()
 {
     File.Copy("sample.bmp", "sample.tmp", true);
     try
     {
         Assert.True(await FileComparer.DefaultCompare(VerifySettings.Default, "sample.bmp", "sample.tmp"));
     }
     finally
     {
         File.Delete("sample.tmp");
     }
 }
        public void QuickStart_BarcodeQRCode()
        {
            byte[] dataQR = BarcodesMaker.GetQRCode("QRCode example",
                                                    QRCodeEncodingMethod.Binary,
                                                    QRCodeErrorCorrection.M,
                                                    8);
            using (Image image = Image.FromStream(new MemoryStream(dataQR)))
            {
                image.Save("QRCode.png", System.Drawing.Imaging.ImageFormat.Png);
            }

            FileComparer.AreEqual("etalon_QRCode.png", "QRCode.png").Should().Be(true);
        }
 public override void Execute()
 {
     if (FileComparer.IsSourceBigger(SourceFile, DestinationFile))
     {
         FileDelete(DestinationFile);
         FileMove();
         DestinationFileResult = new FileInfo(DestinationFile);
     }
     else
     {
         throw new InvalidOperationException($"Error moving source file. Destination file: '{DestinationFile}' exists and is larger than Source file: '{SourceFile}'.");
     }
 }
Beispiel #22
0
 public override void Execute()
 {
     if (FileComparer.IsSourceModifiedMoreRecently(SourceFile, DestinationFile))
     {
         FileDelete(DestinationFile);
         FileCopy();
         DestinationFileResult = new FileInfo(DestinationFile);
     }
     else
     {
         throw new InvalidOperationException($"Error moving source file. Destination file: '{DestinationFile}' exists and is newer than Source file: '{SourceFile}'");
     }
 }
Beispiel #23
0
 public bool Equals(ReferenceItem other)
 {
     if (other == null)
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Reference == other.Reference &&
            FileComparer.Equals(File, other.File) &&
            FileComparer.Equals(ReportedBy, other.ReportedBy));
 }
Beispiel #24
0
    public async Task BinaryEquals()
    {
        File.Copy("sample.bmp", "sample.tmp", true);
        try
        {
            var result = await FileComparer.DefaultCompare(new VerifySettings(), new FilePair("txt", "BinaryEquals"));

            Assert.True(result.IsEqual);
        }
        finally
        {
            File.Delete("sample.tmp");
        }
    }
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(SettingsService settings,
                             ScanningService scanning,
                             IIconCacheService iconCache,
                             IUIService ui,
                             IBitmapFactory bitmapFactory,
                             ImagesServiceBase images,
                             IClipboardService clipboard,
                             IOSService os,
                             IWindowDialogService dialogs,
                             TreemapRendererFactory treemapFactory,
                             IShortcutsService shortcuts,
                             RelayCommandService relayFactory)
        {
            Settings      = settings;
            Scanning      = scanning;
            IconCache     = iconCache;
            UI            = ui;
            BitmapFactory = bitmapFactory;
            Images        = images;
            Clipboard     = clipboard;
            OS            = os;
            Dialogs       = dialogs;
            Shortcuts     = shortcuts;
            Treemap       = treemapFactory.Create();

            Settings.PropertyChanged += OnSettingsPropertyChanged;
            Scanning.PropertyChanged += OnScanningPropertyChanged;

            Extensions = new ExtensionItemViewModelCollection(this);

            SelectedFiles = new ObservableCollection <FileItemViewModel>();
            SelectedFiles.CollectionChanged += OnSelectedFilesChanged;

            FileComparer      = new FileComparer();
            ExtensionComparer = new ExtensionComparer();
            UpdateEmptyRecycleBin();

            GCRAMUsage = GC.GetTotalMemory(false);
            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.
            }
            else
            {
                // Code runs "for real"
                ramTimer    = UI.StartTimer(Settings.RAMInterval, true, OnRAMUsageTick);
                statusTimer = UI.CreateTimer(Settings.StatusInterval, true, OnStatusTick);
            }
        }
        public void QuickStart_BarcodeGS128()
        {
            byte[] dataBarcodeGS128 = BarcodesMaker.GetBarcode("012345678912ABCD",
                                                               BarcodeType.GS1_128A,
                                                               Color.Black,
                                                               Color.White,
                                                               true,
                                                               MeasureBarcodeUnit.FromPixel(0));
            using (Image image = Image.FromStream(new MemoryStream(dataBarcodeGS128)))
            {
                image.Save("barcodeGS128.png", System.Drawing.Imaging.ImageFormat.Png);
            }

            FileComparer.AreEqual("etalon_barcodeGS128.png", "barcodeGS128.png").Should().Be(true);
        }
Beispiel #27
0
    public static async Task <EqualityResult> Streams(
        VerifySettings settings,
        Stream stream,
        FilePair file)
    {
        await FileHelpers.WriteStream(file.Received, stream);

        var result = await FileComparer.DoCompare(settings, file);

        if (result.Equality == Equality.Equal)
        {
            File.Delete(file.Received);
        }

        return(result);
    }
        private void Sort(string sSortMode)
        {
            List <SysFileIf> sortList;
            List <SysSorter> condList;

            condList = BuildCondition();
            sortList = SelectSortFiles(CurrentFiles, sSortMode);
            FileComparer newComparer = new FileComparer(condList);

            sortList.Sort(newComparer);
            FileListView.ItemsSource = null;
            AdjustList(sSortMode, sortList);
            FileListView.ItemsSource = CurrentFiles;

            ShowStatus("Sort Completed");
        }
        public void QuickStart_BarcodeEAN13_Colors_NoQuiteZones()
        {
            byte[] dataBarcode13 = BarcodesMaker.GetBarcode("0123456789123",
                                                            BarcodeType.EAN_13,
                                                            Color.Green,
                                                            Color.White,
                                                            true,
                                                            MeasureBarcodeUnit.FromPixel(0),
                                                            2,
                                                            false);
            using (Image image = Image.FromStream(new MemoryStream(dataBarcode13)))
            {
                image.Save("barcodeEAN13_2.png", System.Drawing.Imaging.ImageFormat.Png);
            }

            FileComparer.AreEqual("etalon_barcodeEAN13_2.png", "barcodeEAN13_2.png").Should().Be(true);
        }
 public async Task ShouldNotLock()
 {
     File.Copy("sample.bmp", "sample.tmp", true);
     try
     {
         using (new FileStream("sample.bmp",
                               FileMode.Open,
                               FileAccess.Read,
                               FileShare.Read))
         {
             Assert.True(await FileComparer.DefaultCompare(VerifySettings.Default, "sample.bmp", "sample.tmp"));
         }
     }
     finally
     {
         File.Delete("sample.tmp");
     }
 }
Beispiel #31
0
        public void sync(Folder destination, FileComparer comparer)
        {
            destination.createIfNoneExist();
            destination.refresh();
            DirectoryInfo folder = new DirectoryInfo(path);
            if ((folder.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
            {
                Log.trace("folder {0} is hidden", folder.FullName);
                return;
            }
            folder.Refresh();
            if (!folder.Exists)
            {
                //Console.WriteLine("{0} does not exist", folder.FullName);
                return;
            }
            foreach (FileInfo file in folder.GetFiles())
            {
                if ((file.Attributes & FileAttributes.Hidden)== FileAttributes.Hidden)
                {
                    Log.trace("{0} is hidden", file.FullName);
                    continue;
                }
                FileInfo destFile = destination.findFile(file.Name);
                if (comparer.match(file, destFile))
                {
                    if (CurrentMode.TransferMode == Mode.Normal)
                    {
                        Log.trace("{0} ===> {1} === exist", file.FullName, destFile.FullName);
                    }
                    continue ;
                }
                fileCopy.copy(file, destFile);
            }

            foreach (DirectoryInfo child in folder.GetDirectories())
            {
                string newPath = Path.Combine(destination.path, child.Name);
                Folder childDestination = new Folder(newPath);
                Folder childSource = new Folder(child.FullName);
                childSource.sync(childDestination, comparer);
            }
        }
 public static List<Command> CompareFiles(string oldFile, string newFile)
 {
     try
     {
         using (var comparer = new FileComparer(oldFile, newFile))
         {
             var ret = comparer.Process();
             var sum = ret.Sum(x => x.Length);
             var oldLength = new FileInfo(oldFile).Length;
             var newLength = new FileInfo(newFile).Length;
             return ret;
         }
     }
     catch
     {
         return null;
     }
 }
Beispiel #33
0
 private void button2_Click(object sender, EventArgs e)
 {
     handle_select = false;
     this.blockbox.Text = "";
     blocklist.DataSource = null;
     bool genera = extendedCheck.Checked;
     stopcollect = false;
     groupBox1.Enabled = false;
     groupBox2.Enabled = false;
     f=new Facet();
     blocklist.DataSource = null;
     GC.Collect();
     String[] files = Directory.GetFiles(textBox2.Text, "*.dat");
     IComparer icomp = new FileComparer();
     Array.Sort(files, icomp);
     progressBar1.Minimum = 0;
     progressBar1.Maximum = (parseOnly.Checked && numBlocks.Value>0) ? (int)numBlocks.Value : files.Length;
     progressBar1.Value = 0;
     errwr = new StreamWriter("error.log");
     outwr = null;
     if(genera)
         outwr = new StreamWriter("outuput.log");
     int div = (parseOnly.Checked && numBlocks.Value > 0) ? (int)numBlocks.Value : files.Length / 3;
     if (div > 50)
     {
         bw1.RunWorkerAsync(files);
     }
     else
     {
         foreach (String s in files)
         {
             Parser p = new Parser(s, errwr, outwr, writeOnlyCheck.Checked, DelimiterCheck.Checked, StaticCheck.Checked, TileCheck.Checked);
             BlockFile b = p.Parse();
             if (numBlocks.Value > 0 && f.blockfileslist.Count >= numBlocks.Value)
             {
                 stopcollect = true;
                 if (parseOnly.Checked)
                     break;
             }
             if (!stopcollect)
             {
                 f.blockfiles.AddLast(b);
                 f.blockfileslist.Add(b);
             }
             Inc();
             if (closed)
                 break;
         }
         bw1_RunWorkerCompleted(null, null);
     }
 }
Beispiel #34
0
        /// <summary>
        /// Finds source files to run against.
        /// </summary>
        /// <param name="dir">The directory to search.</param>
        /// <returns>Returns the source files.</returns>
        private static IEnumerable<string> GetSources(string dir, FileComparer comparer)
        {
            string[] files;

            try
            {
                files = Directory.GetFiles(dir, "*.*");
            }
            catch
            {
                yield break;
            }

            foreach (string f in files)
            {
                if (comparer(f))
                {
                    yield return f;
                }
            }

            string[] directories;

            try
            {
                directories = Directory.GetDirectories(dir);
            }
            catch
            {
                yield break;
            }

            foreach (string d in directories)
            {
                foreach (string file in GetSources(d))
                {
                    yield return file;
                }
            }
        }
    public void go(String[] args)
    {
        processor.SetProperty("http://saxon.sf.net/feature/trace-external-functions", "true");
        testSuiteDir = args[0];
        if (testSuiteDir.EndsWith("/"))
        {
            testSuiteDir = testSuiteDir.Substring(0, testSuiteDir.Length - 1);
        }
        saxonResultsDir = args[1];
        if (saxonResultsDir.EndsWith("/"))
        {
            saxonResultsDir = saxonResultsDir.Substring(0, testSuiteDir.Length - 1);
        }
        Hashtable exceptions = new Hashtable();

        if (args.Length > 1)
        {
            testPattern = (args[2]); // TODO: allow a regex
        }

        for (int i = 0; i < args.Length; i++)
        {
            if (args[i].Equals("-w"))
            {
                //showWarnings = true;
            }

        }

        fileComparer = new FileComparer(processor, testSuiteDir);

        XPathCompiler xpc = processor.NewXPathCompiler();
        xpc.DeclareNamespace("t", testURI);
        xpc.DeclareVariable(new QName("", "param"));
        findSourcePath = xpc.Compile("//t:test-suite/t:sources/t:source[@ID=$param]");

        findCollection = xpc.Compile("//t:test-suite/t:sources/t:collection[@ID=$param]");

        xpc = processor.NewXPathCompiler();
        xpc.DeclareNamespace("t", testURI);
        xpc.DeclareVariable(new QName("", "testcase"));
        xpc.DeclareVariable(new QName("", "moduleuri"));
        findModule = xpc.Compile("for $m in $testcase/t:module[@namespace=$moduleuri] " +
            "return concat('file:///" + testSuiteDir +
            "/', root($testcase)/t:test-suite/t:sources/t:module[@ID=string($m)]/@FileName, '.xq')");

        //xpc = processor.NewXPathCompiler();
        //xpc.DeclareNamespace("saxon", "http://saxon.sf.net/");
        //xpc.DeclareVariable(new QName("", "actual"));
        //xpc.DeclareVariable(new QName("", "gold"));
        //xpc.DeclareVariable(new QName("", "debug"));
        //compareDocuments = xpc.Compile("saxon:deep-equal($actual, $gold, (), if ($debug) then 'JNCPS?!' else 'JNCPS')");

        QName testCaseNT = new QName(testURI, "test-case");
        QName nameNT = new QName(testURI, "name");
        QName queryNT = new QName(testURI, "query");
        QName inputNT = new QName(testURI, "input");
        QName inputFileNT = new QName(testURI, "input-file");
        QName inputUriNT = new QName(testURI, "input-URI");
        QName defaultCollectionNT = new QName(testURI, "defaultCollection");
        QName outputFileNT = new QName(testURI, "output-file");
        QName expectedErrorNT = new QName(testURI, "expected-error");
        QName schemaNT = new QName(testURI, "schema");
        QName contextItemNT = new QName(testURI, "contextItem");
        QName inputQueryNT = new QName(testURI, "input-query");
        QName sourceDocumentNT = new QName(testURI, "source-document");
        QName errorNT = new QName(testURI, "error");
        QName validationNT = new QName(testURI, "validation");
        QName discretionaryItemsNT = new QName(testURI, "discretionary-items");
        QName discretionaryFeatureNT = new QName(testURI, "discretionary-feature");
        QName discretionaryChoiceNT = new QName(testURI, "discretionary-choice");
        QName initialContextNodeNT = new QName(testURI, "initial-context-node");

        QName fileAtt = new QName("", "file");
        QName filePathAtt = new QName("", "FilePath");
        QName fileNameAtt = new QName("", "FileName");
        QName errorIdAtt = new QName("", "error-id");
        QName compareAtt = new QName("", "compare");
        QName nameAtt = new QName("", "name");
        QName behaviorAtt = new QName("", "behavior");
        QName qnameAtt = new QName("", "qname");
        QName modeAtt = new QName("", "mode");
        QName validatesAtt = new QName("", "validates");
        QName variableAtt = new QName("", "variable");
        QName roleAtt = new QName("", "role");

        DocumentBuilder builder = processor.NewDocumentBuilder();
        XdmNode exceptionsDoc = builder.Build(new Uri(saxonResultsDir + "/exceptions-n.xml"));

        // The exceptions.xml file contains details of tests that aren't to be run, for example
        // because they have known bugs or require special configuration

        IEnumerator exceptionTestCases = exceptionsDoc.EnumerateAxis(XdmAxis.Descendant, new QName("", "exception"));
        while (exceptionTestCases.MoveNext())
        {
            XdmNode n = (XdmNode)exceptionTestCases.Current;
            String nameAttVal = n.StringValue;
            char[] seps = { ' ', '\n', '\t' };
            String[] parts = nameAttVal.Split(seps);
            foreach (string p in parts)
            {
                if (!exceptions.ContainsKey(p))
                {
                    exceptions.Add(p, "Exception");
                }
            }
        }

        // Hash table containing all source documents. The key is the document name in the
        // catalog, the value is the corresponding document node

        Hashtable sourceDocs = new Hashtable(50);

        // Load the catalog

        XdmNode catalog = builder.Build(new Uri(testSuiteDir + "/XQTScatalog.xml"));

        // Add all Static Typing test cases to the exceptions list

        xpc = processor.NewXPathCompiler();
        xpc.DeclareNamespace("t", testURI);
        XPathSelector st = xpc.Compile("//t:test-group[@name='StaticTyping']//t:test-case").Load();
        st.ContextItem = catalog;
        IEnumerator ste = st.GetEnumerator();
        while (ste.MoveNext())
        {
            XdmNode testCase = (XdmNode)ste.Current;
            exceptions.Add(testCase.GetAttributeValue(nameAtt), "StaticTypingException");
        }

        // Create the results file and log file

        results = new StreamWriter(saxonResultsDir + "/results"
                    + processor.ProductVersion + "n.xml");
        log = new StreamWriter(saxonResultsDir + "/log"
                    + processor.ProductVersion + "n.xml");

        log.WriteLine("Testing Saxon " + processor.ProductVersion);
        results.WriteLine("<test-suite-result xmlns='http://www.w3.org/2005/02/query-test-XQTSResult'>");

        // Pre-load all the schemas

        SchemaManager mgr = processor.SchemaManager;
        IEnumerator se = catalog.EnumerateAxis(XdmAxis.Descendant, schemaNT);
        while (se.MoveNext())
        {
            XdmNode schemaNode = (XdmNode)se.Current;
            log.WriteLine("Loading schema " + schemaNode.GetAttributeValue(fileNameAtt));
            Uri location = new Uri(testSuiteDir + "/" + schemaNode.GetAttributeValue(fileNameAtt));
            mgr.Compile(location);
        }

        total = 0;
        IEnumerator testCases = catalog.EnumerateAxis(XdmAxis.Descendant, testCaseNT);
        while (testCases.MoveNext()) {
            total++;
        }

        // Process the test cases in turn

        testCases = catalog.EnumerateAxis(XdmAxis.Descendant, testCaseNT);
        while (testCases.MoveNext())
        {
            XdmNode testCase = (XdmNode)testCases.Current;

            String testName = testCase.GetAttributeValue(nameAtt);
            if (testPattern != null && !testName.StartsWith(testPattern))
            {
                continue;
            }
            if (exceptions.ContainsKey(testName))
            {
                continue;
            }

            log.WriteLine("Test " + testName);

            // Compile the query

            String errorCode = null;

            String filePath = testCase.GetAttributeValue(filePathAtt);
            XdmNode query = getChildElement(testCase, queryNT);
            String queryName = query.GetAttributeValue(nameAtt);
            String queryPath = testSuiteDir + "/Queries/XQuery/" + filePath + queryName + ".xq";

            XQueryCompiler compiler = processor.NewXQueryCompiler();
            compiler.BaseUri = new Uri(queryPath).ToString();
            compiler.QueryResolver = new XqtsModuleResolver(testCase, findModule);
            compiler.SchemaAware = true;
                // Set all queries to schema-aware, because we don't really know whether they will have to handle typed input or not.

            ArrayList errors = new ArrayList();
            compiler.ErrorList = errors;
            XQueryEvaluator xqe = null;
            FileStream stream = null;
            try
            {
                stream = new FileStream(queryPath, FileMode.Open, FileAccess.Read, FileShare.Read);
                xqe = compiler.Compile(stream).Load();
            }
            catch (Exception e)
            {
                if (errors.Count > 0 && ((StaticError)errors[0]).ErrorCode != null)
                {
                    errorCode = ((StaticError)errors[0]).ErrorCode.LocalName;
                }
                else if (e is StaticError && ((StaticError)e).ErrorCode != null)
                {
                    log.WriteLine(e.Message);
                    errorCode = ((StaticError)e).ErrorCode.LocalName;
                }
                else
                {
                    log.WriteLine(e.Message);
                    errorCode = "ErrorXXX";
                }
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                }
            }

            // if the query compiled successfully, try to run it

            String outputPath = null;
            if (errorCode == null && xqe != null)
            {

                // Supply any input documents

                IEnumerator en = testCase.EnumerateAxis(XdmAxis.Child, inputFileNT);
                while (en.MoveNext())
                {
                    XdmNode file = (XdmNode)en.Current;
                    String var = file.GetAttributeValue(variableAtt);
                    if (var != null)
                    {
                        String sourceName = file.StringValue;
                        XdmNode sourceDoc;
                        if (sourceDocs.ContainsKey(sourceName))
                        {
                            sourceDoc = (XdmNode)sourceDocs[sourceName];
                        }
                        else
                        {
                            sourceDoc = buildSource(catalog, builder, sourceName);
                            sourceDocs.Add(sourceName, sourceDoc);
                        }
                        xqe.SetExternalVariable(new QName("", var), sourceDoc);
                    }
                }

                // Supply any input URIs

                IEnumerator eu = testCase.EnumerateAxis(XdmAxis.Child, inputUriNT);
                while (eu.MoveNext())
                {
                    XdmNode file = (XdmNode)eu.Current;
                    String var = file.GetAttributeValue(variableAtt);
                    if (var != null)
                    {
                        String sourceName = file.StringValue;
                        if (sourceName.StartsWith("collection"))
                        {
                            // Supply a collection URI.
                            // This seems to be the only way to distinguish a document URI
                            // from a collection URI.
                            String uri = "collection:" + sourceName;
                            XPathSelector xpe = findCollection.Load();
                            xpe.SetVariable(new QName("", "param"), new XdmAtomicValue(sourceName));
                            xpe.ContextItem = catalog;
                            XdmNode collectionNode = (XdmNode)xpe.EvaluateSingle();
                            if (collectionNode == null)
                            {
                                log.WriteLine("*** Collection " + sourceName + " not found");
                            }
                            processor.RegisterCollection(new Uri(uri), getCollection(collectionNode));
                            xqe.SetExternalVariable(new QName("", var), new XdmAtomicValue(uri));
                        }
                        else
                        {
                            // Supply a document URI.
                            // We exploit the fact that the short name of the document is
                            // always the same as the file name in these tests. With one exception!
                            if (sourceName == "Char010D")
                            {
                                sourceName = "0x010D";
                            }
                            String uri = "file:///" + testSuiteDir + "/TestSources/" + sourceName + ".xml";
                            xqe.SetExternalVariable(new QName("", var), new XdmAtomicValue(uri));
                        }
                    }
                }

                // Supply the default collection if required

                XdmNode defaultCollection = getChildElement(testCase, defaultCollectionNT);
                if (defaultCollection != null)
                {
                    String sourceName = defaultCollection.StringValue;
                    XPathSelector xpe = findCollection.Load();
                    xpe.SetVariable(new QName("", "param"), new XdmAtomicValue(sourceName));
                    xpe.ContextItem = catalog;
                    XdmNode collectionNode = (XdmNode)xpe.EvaluateSingle();
                    if (collectionNode == null)
                    {
                        log.WriteLine("*** Collection " + sourceName + " not found");
                    }
                    processor.RegisterCollection(null, getCollection(collectionNode));
                }

                // Supply any external variables defined as the result of a separate query

                IEnumerator ev = testCase.EnumerateAxis(XdmAxis.Child, inputQueryNT);
                while (ev.MoveNext())
                {
                    XdmNode inputQuery = (XdmNode)ev.Current;

                    String fileName = inputQuery.GetAttributeValue(nameAtt);
                    String subQueryPath = testSuiteDir + "/Queries/XQuery/" + filePath + fileName + ".xq";
                    XQueryCompiler subCompiler = processor.NewXQueryCompiler();
                    compiler.BaseUri = new Uri(subQueryPath).ToString();
                    FileStream subStream = new FileStream(subQueryPath, FileMode.Open, FileAccess.Read, FileShare.Read);
                    XdmValue value = subCompiler.Compile(subStream).Load().Evaluate();
                    String var = inputQuery.GetAttributeValue(variableAtt);
                    xqe.SetExternalVariable(new QName("", var), value);
                }

                // Supply the context item if required

                IEnumerator ci = testCase.EnumerateAxis(XdmAxis.Child, contextItemNT);
                while (ci.MoveNext())
                {
                    XdmNode file = (XdmNode)ci.Current;

                    String sourceName = file.StringValue;
                    if (!sourceDocs.ContainsKey(sourceName))
                    {
                        XdmNode doc = buildSource(catalog, builder, sourceName);
                        sourceDocs.Add(sourceName, doc);
                    }
                    XdmNode sourceDoc = (XdmNode)sourceDocs[sourceName];
                    xqe.ContextItem = sourceDoc;
                }

                // Create a serializer for the output

                outputPath = saxonResultsDir + "/results.net/" + filePath + queryName + ".out";
                Serializer sr = new Serializer();
                try
                {
                    sr.SetOutputFile(outputPath);
                    sr.SetOutputProperty(new QName("", "method"), "xml");
                    sr.SetOutputProperty(new QName("", "omit-xml-declaration"), "yes");
                    sr.SetOutputProperty(new QName("", "indent"), "no");
                }
                catch (DynamicError)
                {
                    // probably means that no output directory exists, which is probably because
                    // an error is expected
                    outputPath = saxonResultsDir + "/results.net/" + filePath + queryName + ".out";
                    sr.SetOutputFile(outputPath);
                }

                // Finally, run the query

                try
                {
                    xqe.Run(sr);
                }
                catch (DynamicError e)
                {
                    log.WriteLine(e.Message);
                    QName code = e.ErrorCode;
                    if (code != null && code.LocalName != null)
                    {
                        errorCode = code.LocalName;
                    }
                    else
                    {
                        errorCode = "ErrYYYYY";
                    }
                }
                catch (Exception e2)
                {
                    log.WriteLine("Unexpected exception: " + e2.Message);
                    log.WriteLine(e2.StackTrace);
                    errorCode = "CRASH!!!";
                }
            }

            // Compare actual results with expected results

            if (errorCode != null)
            {
                // query returned an error at compile time or run-time, check this was expected

                string expectedError = "";
                bool matched = false;
                IEnumerator en = testCase.EnumerateAxis(XdmAxis.Child, expectedErrorNT);
                while (en.MoveNext())
                {
                    XdmNode error = (XdmNode)en.Current;
                    String expectedErrorCode = error.StringValue;
                    expectedError += (expectedErrorCode + " ");
                    if (expectedErrorCode.Equals(errorCode))
                    {
                        matched = true;
                        feedback.Feedback(passed++, failed, total);
                        log.WriteLine("Error " + errorCode + " as expected");
                        results.WriteLine("<test-case name='" + testName + "' result='pass'/>");
                        break;
                    }
                }
                if (!matched)
                {
                    if (expectedError.Equals(""))
                    {
                        feedback.Feedback(passed, failed++, total);
                        log.WriteLine("Error " + errorCode + ", expected success");
                        results.WriteLine("<test-case name='" + testName + "' result='fail' comment='error " + errorCode + ", expected success'/>");
                        results.WriteLine("<--" + filePath + queryName + "-->");
                    }
                    else
                    {
                        feedback.Feedback(passed++, failed, total);
                        log.WriteLine("Error " + errorCode + ", expected " + expectedError);
                        results.WriteLine("<test-case name='" + testName + "' result='pass' comment='error " + errorCode + ", expected " + expectedError + "'/>");
                        results.WriteLine("<--" + filePath + queryName + "-->");
                    }
                }

            }
            else
            {
                // query returned no error

                bool matched = false;
                String diag = "";
                IEnumerator en = testCase.EnumerateAxis(XdmAxis.Child, outputFileNT);
                while (en.MoveNext())
                {
                    XdmNode outputFile = (XdmNode)en.Current;
                    String fileName = testSuiteDir + "/ExpectedTestResults/" + filePath + outputFile.StringValue;
                    String comparator = outputFile.GetAttributeValue(compareAtt);
                    if (comparator.Equals("Inspect"))
                    {
                        matched = true;
                        feedback.Feedback(passed++, failed, total);
                        results.WriteLine("<test-case name='" + testName + "' result='inspect'/>");
                        results.WriteLine("<--" + filePath + queryName + "-->");
                        break;
                    }
                    else
                    {
                        String comparison = fileComparer.compare(outputPath, fileName, comparator);
                        matched = (comparison == "OK" || comparison.StartsWith("#"));
                        if (matched)
                        {
                            feedback.Feedback(passed++, failed, total);
                            results.WriteLine("<test-case name='" + testName + "' result='pass'/>");
                            diag = diag + ("<!-- " + comparison + " -->\n");
                            break;
                        }
                    }
                }

                if (!matched)
                {
                    string expectedError = "";
                    IEnumerator ee = testCase.EnumerateAxis(XdmAxis.Child, expectedErrorNT);
                    while (ee.MoveNext())
                    {
                        XdmNode error = (XdmNode)ee.Current;
                        String expectedErrorCode = error.StringValue;
                        expectedError += (expectedErrorCode + " ");
                    }

                    if (expectedError.Equals(""))
                    {
                        feedback.Feedback(passed, failed++, total);
                        log.WriteLine("Results differ from expected results");
                        results.WriteLine("<test-case name='" + testName + "' result='fail'/>");
                        results.WriteLine("<--" + filePath + queryName + "-->");
                    }
                    else
                    {
                        feedback.Feedback(passed, failed++, total);
                        log.WriteLine("Error " + expectedError + "expected but not reported");
                        results.WriteLine("<test-case name='" + testName + "' result='fail' comment='expected error " + expectedError + "not reported'/>");
                        results.WriteLine("<--" + filePath + queryName + "-->");
                    }
                }
            }
        }

        results.WriteLine("</test-suite-result>");
        results.Close();
        log.Close();
    }
Beispiel #36
0
 public void init()
 {
     comparer = new FileSzieComparer();
 }
Beispiel #37
0
    public void go(String[] args)
    {
        int passed = 0;
        int failed = 0;
        int total = 0;

        
        testSuiteDir = args[0];
        if (testSuiteDir.EndsWith("/"))
        {
            testSuiteDir = testSuiteDir.Substring(0, testSuiteDir.Length - 1);
        }
        Hashtable exceptions = new Hashtable();

        if (args.Length > 1)
        {
            testPattern = (args[1]); 
        }

        for (int i = 0; i < args.Length; i++)
        {
            if (args[i].Equals("-w"))
            {
                //showWarnings = true;
            }
        }

        try
        {
            schemaAwareProcessor = new Processor(true);
        }
        catch (Exception)
        {
            Console.WriteLine("Cannot load Saxon-SA: continuing without it");
        }

        processor.SetProperty("http://saxon.sf.net/feature/preferJaxpParser", "true");

        if (schemaAwareProcessor != null)
        {
            schemaAwareProcessor.SetProperty("http://saxon.sf.net/feature/preferJaxpParser", "true");
        }
        fileComparer = new FileComparer(processor, testSuiteDir);

        String testURI = "http://www.w3.org/2005/05/xslt20-test-catalog";

        QName testCaseNT = new QName(testURI, "testcase");
        QName nameNT = new QName(testURI, "name");
        QName inputNT = new QName(testURI, "input");
        QName outputNT = new QName(testURI, "output");
        QName stylesheetNT = new QName(testURI, "stylesheet");
        QName schemaNT = new QName(testURI, "schema");
        QName initialModeNT = new QName(testURI, "initial-mode");
        QName entryNamedTemplateNT = new QName(testURI, "entry-named-template");
        QName sourceDocumentNT = new QName(testURI, "source-document");
        QName stylesheetParametersNT = new QName(testURI, "stylesheet-parameters");
        QName paramNT = new QName(testURI, "param");
        QName resultDocumentNT = new QName(testURI, "result-document");
        QName errorNT = new QName(testURI, "error");
        QName validationNT = new QName(testURI, "validation");
        QName discretionaryItemsNT = new QName(testURI, "discretionary-items");
        QName discretionaryFeatureNT = new QName(testURI, "discretionary-feature");
        QName discretionaryChoiceNT = new QName(testURI, "discretionary-choice");
        QName discretionaryVersionNT = new QName(testURI, "discretionary-version");
        QName initialContextNodeNT = new QName(testURI, "initial-context-node");


        QName fileAtt = new QName("", "file");
        QName errorIdAtt = new QName("", "error-id");
        QName typeAtt = new QName("", "type");
        QName nameAtt = new QName("", "name");
        QName behaviorAtt = new QName("", "behavior");
        QName specAtt = new QName("", "spec");
        QName qnameAtt = new QName("", "qname");
        QName modeAtt = new QName("", "mode");
        QName validatesAtt = new QName("", "validates");
        QName roleAtt = new QName("", "role");

        DocumentBuilder builder = processor.NewDocumentBuilder();
        XdmNode exceptionsDoc = builder.Build(new Uri(testSuiteDir + '/' + getResultDirectoryName() + "/exceptions.xml"));

        IEnumerator exceptionTestCases = exceptionsDoc.EnumerateAxis(XdmAxis.Descendant, testCaseNT);
        while (exceptionTestCases.MoveNext())
        {
            XdmNode n = (XdmNode)exceptionTestCases.Current;
            String nameAttVal = n.GetAttributeValue(nameAtt);
            char[] seps = { ' ', '\n', '\t' };
            String[] parts = nameAttVal.Split(seps);
            foreach (string p in parts)
            {
                if (!exceptions.ContainsKey(p))
                {
                    exceptions.Add(p, "Kilroy");
                }
            }
        }

        XdmNode catalog = builder.Build(new Uri(testSuiteDir + "/catalog.xml"));

        results = new StreamWriter(testSuiteDir + "/SaxonResults.net/results"
                    + processor.ProductVersion + ".xml");
        log = new StreamWriter(testSuiteDir + "/SaxonResults.net/log"
                    + processor.ProductVersion + "n.xml");
        log.WriteLine("Testing Saxon " + processor.ProductVersion);

        results.WriteLine("<test-suite-result>");
        results.WriteLine(" <implementation name='Saxon-SA' version='" + processor.ProductVersion +
                "' anonymous-result-column='false'>");
        results.WriteLine("  <organization name='http://www.saxonica.com/' anonymous='false'/>");
        results.WriteLine("  <submitter name='Michael Kay' email='*****@*****.**'/>");
        outputDiscretionaryItems();
        results.WriteLine(" </implementation>");

        total = 0;
        IEnumerator testCases = catalog.EnumerateAxis(XdmAxis.Descendant, testCaseNT);
        while (testCases.MoveNext())
        {
            total++;
        }

        testCases = catalog.EnumerateAxis(XdmAxis.Descendant, testCaseNT);
        while (testCases.MoveNext())
        {
            bool useAssociated = false;
            XdmNode testCase = (XdmNode)testCases.Current;

            String testName = getChildElement(testCase, nameNT).StringValue;
            if (testPattern != null && !testName.StartsWith(testPattern))
            {
                continue;
            }
            if (exceptions.ContainsKey(testName))
            {
                continue;
            }
            if (isExcluded(testName))
            {
                continue;
            }
            log.WriteLine("Test " + testName);
            XdmNode testInput = getChildElement(testCase, inputNT);

            XdmNode stylesheet = getChildElement(testInput, stylesheetNT);
            String absXSLName = null;
            if (stylesheet == null)
            {
                useAssociated = true;
            }
            else
            {
                absXSLName = testSuiteDir + "/TestInputs/" + stylesheet.GetAttributeValue(fileAtt);
            }

            XdmNode sourceDocument = getChildElement(testInput, sourceDocumentNT);
            String absXMLName = null;
            if (sourceDocument != null)
            {
                absXMLName = testSuiteDir + "/TestInputs/" + sourceDocument.GetAttributeValue(fileAtt);
            }

            bool schemaAware = false;
            bool recoverRecoverable = true;
            bool backwardsCompatibility = true;
            bool supportsDOE = true;
            bool recoverSESU0007 = false;
            bool useXSLT30 = false;
            XdmNode discretionaryItems = getChildElement(testCase, discretionaryItemsNT);
            if (discretionaryItems != null)
            {
                IEnumerator features = discretionaryItems.EnumerateAxis(XdmAxis.Child, discretionaryFeatureNT);
                while (features.MoveNext())
                {
                    XdmNode feature = (XdmNode)features.Current;
                    String featureName = feature.GetAttributeValue(nameAtt);
                    if ("schema_aware".Equals(featureName) || "Saxon-PE".Equals(featureName))   // TODO: test Saxon-PE properly
                    {
                        schemaAware = "on".Equals(feature.GetAttributeValue(behaviorAtt));
                    }
                    else if ("XML_1.1".Equals(featureName))
                    {
                        xml11 = "on".Equals(feature.GetAttributeValue(behaviorAtt));
                    }
                    else if ("backwards_compatibility".Equals(featureName))
                    {
                        backwardsCompatibility = "on".Equals(feature.GetAttributeValue(behaviorAtt));
                    }
                    else if ("disabling_output_escaping".Equals(featureName))
                    {
                        supportsDOE = "on".Equals(feature.GetAttributeValue(behaviorAtt));
                    }
                }
                IEnumerator choices = discretionaryItems.EnumerateAxis(
                        XdmAxis.Child, discretionaryChoiceNT);
                while (choices.MoveNext())
                {
                    XdmNode choice = (XdmNode)choices.Current;
                    String featureName = choice.GetAttributeValue(nameAtt);
                    if ("error".Equals(choice.GetAttributeValue(behaviorAtt)))
                    {
                        recoverRecoverable = false;
                    }
                    else if ("SESU0007".Equals(featureName))
                    {
                        recoverSESU0007 = "recovery".Equals(choice.GetAttributeValue(behaviorAtt));
                    }
                }
                IEnumerator versions = discretionaryItems.EnumerateAxis(
                        XdmAxis.Child, discretionaryVersionNT);
                while (versions.MoveNext())
                {
                    XdmNode dv = (XdmNode)versions.Current;
                    useXSLT30 = ("XSLT30" == dv.GetAttributeValue(specAtt));
                }
            }

            if (!backwardsCompatibility)
            {
                // Saxon cannot run with BC switched off
                results.WriteLine(" <testcase name='" + testName + "' result='not run' comment='requires backwards-compatibility=off'/>");
                continue;
            }

            if (!supportsDOE)
            {
                // Saxon cannot run with DOE switched off
                results.WriteLine(" <testcase name='" + testName + "' result='not run' comment='requires disable-output-escaping=off'/>");
                continue;
            }

            if (recoverSESU0007)
            {
                // Saxon cannot recover from error SESU0007
                results.WriteLine(" <testcase name='" + testName + "' result='not run' comment='requires recovery from error SESU0007'/>");
                continue;
            }

            XdmNode initialMode = getChildElement(testInput, initialModeNT);
            QName initialModeName = null;
            if (initialMode != null)
            {
                String ini = initialMode.GetAttributeValue(qnameAtt);
                initialModeName = makeQName(ini, initialMode);
            }

            XdmNode initialTemplate = getChildElement(testInput, entryNamedTemplateNT);
            QName initialTemplateName = null;
            if (initialTemplate != null)
            {
                String ini = initialTemplate.GetAttributeValue(qnameAtt);
                initialTemplateName = makeQName(ini, initialTemplate);
            }

            XdmNode initialContextNode = getChildElement(testInput, initialContextNodeNT);
            String initialContextPath = null;
            if (initialContextNode != null)
            {
                initialContextPath = initialContextNode.StringValue;
            }

            XdmNode validation = getChildElement(testInput, validationNT);
            String validationMode = null;
            if (validation != null)
            {
                validationMode = validation.GetAttributeValue(modeAtt);
            }

            Hashtable paramTable = null;
            XdmNode paramList = getChildElement(testInput, stylesheetParametersNT);
            if (paramList != null)
            {
                paramTable = new Hashtable(5);
                IEnumerator paramIter = paramList.EnumerateAxis(XdmAxis.Child, paramNT);
                while (paramIter.MoveNext())
                {
                    XdmNode param = (XdmNode)paramIter.Current;
                    QName name = makeQName(param.GetAttributeValue(qnameAtt), param);
                    String value = param.StringValue;
                    paramTable.Add(name, value);
                }
            }

            IEnumerator schemas = testInput.EnumerateAxis(XdmAxis.Child, schemaNT);
            while (schemas.MoveNext())
            {
                XdmNode schema = (XdmNode)schemas.Current;
                if (schema == null)
                {
                    break;
                }
                schemaAware = true;
                String role = schema.GetAttributeValue(roleAtt);
                if (("source-validator".Equals(role) || "source-reference".Equals(role))
                    /* && schema.GetAttributeValue(validatesAtt) != null */)
                {
                    validationMode = "strict";
                    // TODO: control which source documents are validated...
                }
            }
            XdmNode testOutput = getChildElement(testCase, outputNT);
            XdmNode resultDocument = getChildElement(testOutput, resultDocumentNT);
            // TODO: handle alternative result documents
            String refFileName = null;
            String outFileName;
            String comparator = "xml";
            if (resultDocument != null)
            {
                String relativePath = resultDocument.GetAttributeValue(fileAtt);
                int slash = relativePath.IndexOf('/');
                if (slash > 0)
                {
                    String relativeDir = relativePath.Substring(0, slash);
                    String fullDir = testSuiteDir + '/' + getResultDirectoryName() + "/" + relativeDir;
                    if (!Directory.Exists(fullDir))
                    {
                        Directory.CreateDirectory(fullDir);
                    }
                }
                refFileName = testSuiteDir + "/ExpectedTestResults/" + relativePath;
                outFileName = testSuiteDir + '/' + getResultDirectoryName() + "/" + relativePath;
                comparator = resultDocument.GetAttributeValue(typeAtt);
            }
            else
            {
                outFileName = testSuiteDir + '/' + getResultDirectoryName() + "/temp.out";
            }
            XdmNode error = getChildElement(testOutput, errorNT);
            String expectedError = null;
            if (error != null)
            {
                expectedError = error.GetAttributeValue(errorIdAtt);
            }
            bool success;
            Exception xsltOutcome =
                runXSLT(testName, absXMLName, absXSLName, initialModeName, initialTemplateName,
                    outFileName, paramTable, initialContextPath,
                    useAssociated, schemaAware, validationMode, recoverRecoverable, useXSLT30);
            if (xsltOutcome == null)
            {
                success = true;
                if (expectedError != null && resultDocument == null)
                {
                    log.WriteLine("Test failed. Expected error " + expectedError + ", got success");
                    feedback.Feedback(passed, failed++, total);
                    success = false;
                    results.WriteLine(" <testcase name='" + testName +
                            "' result='differ' comment='Expected error " +
                            expectedError + ", got success'/>");
                }
                else
                {
                    feedback.Feedback(passed++, failed, total);
                }
            }
            else
            {
                String errorCode = null;
                if (xsltOutcome is StaticError)
                {
                    errorCode = ((StaticError)xsltOutcome).ErrorCode.LocalName;
                }
                else if (xsltOutcome is DynamicError)
                {
                    errorCode = ((DynamicError)xsltOutcome).ErrorCode.LocalName;
                }
                if (expectedError != null && errorCode != null && errorCode.Equals(expectedError))
                {
                    feedback.Feedback(passed++, failed, total);
                    log.WriteLine("Test succeeded (" + expectedError + ')');
                    results.WriteLine(" <testcase name='" + testName +
                            "' result='full' comment='Error " +
                            expectedError + " as expected'/>");
                }
                else if (expectedError != null)
                {
                    feedback.Feedback(passed++, failed, total);
                    log.WriteLine("Test succeeded (??) (expected " + expectedError + ", got " + errorCode + ')');
                    results.WriteLine(" <testcase name='" + testName +
                            "' result='different-error' comment='Expected " +
                            expectedError + " got " + errorCode + "'/>");
                }
                else
                {
                    feedback.Feedback(passed, failed++, total);
                    log.WriteLine("Test failed. Expected success, got " + errorCode);
                    results.WriteLine(" <testcase name='" + testName +
                            "' result='differ' comment='Expected success, got " +
                            errorCode + "'/>");
                    results.WriteLine(" <!--" + xsltOutcome.Message + "-->");
                }
                success = false;
                continue;
            }


            if (success)
            {
                String outcome = fileComparer.compare(outFileName, refFileName, comparator);
                if (outcome == "OK")
                {
                    results.WriteLine(" <testcase name='" + testName + "' result='full'/>");
                }
                else if (outcome.StartsWith("#"))
                {
                    results.WriteLine(" <testcase name='" + testName + "' result='full' + comments='" + outcome.Substring(1) + "/>");
                }
                else
                {
                    results.WriteLine(" <testcase name='" + testName + "' result='differ' comments='" + outcome + "'/>");
                }
            }

        }

        results.WriteLine("</test-suite-result>");
        results.Close();
        log.Close();

        //} 
    }