diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/BatchParser/BatchParserTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/BatchParser/BatchParserTests.cs index 1d4dae0d..e3a680ac 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/BatchParser/BatchParserTests.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/BatchParser/BatchParserTests.cs @@ -1,244 +1,272 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// - -using System; -using System.Globalization; -using System.IO; -using System.Text; -using Microsoft.SqlTools.ServiceLayer.BatchParser; -using Microsoft.SqlTools.ServiceLayer.QueryExecution; -using Microsoft.SqlTools.ServiceLayer.Test.Common; -using Microsoft.SqlTools.ServiceLayer.Test.Common.Baselined; -using Xunit; - -namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.BatchParser -{ - public class BatchParserTests : BaselinedTest - { - private bool testFailed = false; - - public BatchParserTests() - { - InitializeTest(); - } - - public void InitializeTest() - { - CategoryName = "BatchParser"; - this.TraceOutputDirectory = RunEnvironmentInfo.GetTestDataLocation(); - TestInitialize(); - } - - [Fact] - public void VerifyThrowOnUnresolvedVariable() - { - string script = "print '$(NotDefined)'"; - StringBuilder output = new StringBuilder(); - - TestCommandHandler handler = new TestCommandHandler(output); - IVariableResolver resolver = new TestVariableResolver(new StringBuilder()); - Parser p = new Parser( - handler, - resolver, - new StringReader(script), - "test"); - p.ThrowOnUnresolvedVariable = true; - - handler.SetParser(p); - - Assert.Throws(() => p.Parse()); - } - - public void TokenizeWithLexer(string filename, StringBuilder output) - { - - using (Lexer lexer = new Lexer(new StreamReader(File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read)), filename)) - { - - string inputText = File.ReadAllText(filename); - inputText = inputText.Replace("\r\n", "\n"); - StringBuilder roundtripTextBuilder = new StringBuilder(); - StringBuilder outputBuilder = new StringBuilder(); - StringBuilder tokenizedInput = new StringBuilder(); - bool lexerError = false; - - Token token = null; - try - { - do - { - lexer.ConsumeToken(); - token = lexer.CurrentToken; - roundtripTextBuilder.Append(token.Text); - outputBuilder.AppendLine(GetTokenString(token)); - tokenizedInput.Append('[').Append(GetTokenCode(token.TokenType)).Append(':').Append(token.Text).Append(']'); - } while (token.TokenType != LexerTokenType.Eof); - } - catch (BatchParserException ex) - { - lexerError = true; - outputBuilder.AppendLine(string.Format(CultureInfo.CurrentCulture, "[ERROR: code {0} at {1} - {2} in {3}, message: {4}]", ex.ErrorCode, GetPositionString(ex.Begin), GetPositionString(ex.End), GetFilenameOnly(ex.Begin.Filename), ex.Message)); - } - output.AppendLine("Lexer tokenized input:"); - output.AppendLine("======================"); - output.AppendLine(tokenizedInput.ToString()); - output.AppendLine("Tokens:"); - output.AppendLine("======="); - output.AppendLine(outputBuilder.ToString()); - - if (lexerError == false) - { - // Verify that all text from tokens can be recombined into original string - Assert.Equal(inputText, roundtripTextBuilder.ToString().Replace("\r\n", "\n")); - } - } - } - - private string GetTokenCode(LexerTokenType lexerTokenType) - { - switch (lexerTokenType) - { - case LexerTokenType.Text: - return "T"; - case LexerTokenType.Whitespace: - return "WS"; - case LexerTokenType.NewLine: - return "NL"; - case LexerTokenType.Comment: - return "C"; - default: - return lexerTokenType.ToString(); - } - } - - [Fact] - public void BatchParserTest() - { - Start("err-blockComment"); - Start("err-blockComment2"); - Start("err-varDefinition"); - Start("err-varDefinition2"); - Start("err-varDefinition3"); - Start("err-varDefinition4"); - Start("err-varDefinition5"); - Start("err-varDefinition6"); - Start("err-varDefinition7"); - Start("err-varDefinition8"); - Start("err-varDefinition9"); - Start("err-variableRef"); - Start("err-variableRef2"); - Start("err-variableRef3"); - Start("err-variableRef4"); - Start("err-cycle1"); - Start("input"); - Start("input2"); - Start("pass-blockComment"); - Start("pass-lineComment"); - Start("pass-lineComment2"); - Start("pass-noBlockComments"); - Start("pass-noLineComments"); - Start("pass-varDefinition"); - Start("pass-varDefinition2"); - Start("pass-varDefinition3"); - Start("pass-varDefinition4"); - Start("pass-command-and-comment"); - Assert.False(testFailed, "At least one of test cases failed. Check output for details."); - } - - public void TestParser(string filename, StringBuilder output) - { - try - { - TestCommandHandler commandHandler = new TestCommandHandler(output); - - Parser parser = new Parser( - commandHandler, - new TestVariableResolver(output), - new StreamReader(File.Open(filename, FileMode.Open)), - filename); - - commandHandler.SetParser(parser); - - parser.Parse(); - } - catch (BatchParserException ex) - { - output.AppendLine(string.Format(CultureInfo.CurrentCulture, "[PARSER ERROR: code {0} at {1} - {2} in {3}, token text: {4}, message: {5}]", ex.ErrorCode, GetPositionString(ex.Begin), GetPositionString(ex.End), GetFilenameOnly(ex.Begin.Filename), ex.Text, ex.Message)); - } - } - - private string GetPositionString(PositionStruct pos) - { - return string.Format(CultureInfo.InvariantCulture, "{0}:{1} [{2}]", pos.Line, pos.Column, pos.Offset); - } - - private string GetTokenString(Token token) - { - if (token == null) - { - return "(null)"; - } - else - { - string tokenText = token.Text; - if (tokenText != null) - { - tokenText = tokenText.Replace("\n", "\\n").Replace("\r", "\\r").Replace("\t", "\\t"); - } - string tokenFilename = token.Filename; - tokenFilename = GetFilenameOnly(tokenFilename); - return string.Format(CultureInfo.CurrentCulture, "[Token {0} at {1}({2}:{3} [{4}] - {5}:{6} [{7}]): '{8}']", - token.TokenType, - tokenFilename, - token.Begin.Line, token.Begin.Column, token.Begin.Offset, - token.End.Line, token.End.Column, token.End.Offset, - tokenText); - } - } - - internal static string GetFilenameOnly(string fullPath) - { - return fullPath != null ? Path.GetFileName(fullPath) : null; - } - - public override void Run() - { - string inputFilename = GetTestscriptFilePath(CurrentTestName); - StringBuilder output = new StringBuilder(); - - TokenizeWithLexer(inputFilename, output); - TestParser(inputFilename, output); - - string baselineFilename = GetBaselineFilePath(CurrentTestName); - string baseline; - - try - { - baseline = GetFileContent(baselineFilename); - } - catch (FileNotFoundException) - { - baseline = string.Empty; - } - - string outputString = output.ToString(); - - Console.WriteLine(baselineFilename); - - if (string.Compare(baseline, outputString, StringComparison.Ordinal) != 0) - { - DumpToTrace(CurrentTestName, outputString); - string outputFilename = Path.Combine(TraceFilePath, GetBaselineFileName(CurrentTestName)); - Console.WriteLine(":: Output does not match the baseline!"); - Console.WriteLine("code --diff \"" + baselineFilename + "\" \"" + outputFilename + "\""); - Console.WriteLine(); - Console.WriteLine(":: To update the baseline:"); - Console.WriteLine("copy \"" + outputFilename + "\" \"" + baselineFilename + "\""); - Console.WriteLine(); - testFailed = true; - } - } - } -} +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; +using System.Globalization; +using System.IO; +using System.Text; +using Microsoft.SqlTools.ServiceLayer.BatchParser; +using Microsoft.SqlTools.ServiceLayer.Test.Common; +using Microsoft.SqlTools.ServiceLayer.Test.Common.Baselined; +using Xunit; +using Microsoft.SqlTools.ServiceLayer.QueryExecution; + +namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.BatchParser +{ + public class BatchParserTests : BaselinedTest + { + private bool testFailed = false; + + public BatchParserTests() + { + InitializeTest(); + } + + public void InitializeTest() + { + CategoryName = "BatchParser"; + this.TraceOutputDirectory = RunEnvironmentInfo.GetTraceOutputLocation(); + TestInitialize(); + } + + [Fact] + public void VerifyThrowOnUnresolvedVariable() + { + string script = "print '$(NotDefined)'"; + StringBuilder output = new StringBuilder(); + + TestCommandHandler handler = new TestCommandHandler(output); + IVariableResolver resolver = new TestVariableResolver(new StringBuilder()); + using (Parser p = new Parser( + handler, + resolver, + new StringReader(script), + "test")) + { + p.ThrowOnUnresolvedVariable = true; + handler.SetParser(p); + + Assert.Throws(() => p.Parse()); + } + } + + private static Stream GenerateStreamFromString(string s) + { + MemoryStream stream = new MemoryStream(); + StreamWriter writer = new StreamWriter(stream); + writer.Write(s); + writer.Flush(); + stream.Position = 0; + return stream; + } + + public void TokenizeWithLexer(string filename, StringBuilder output) + { + // Create a new file by changing CRLFs to LFs and generate a new steam + // or the tokens generated by the lexer will always have off by one errors + string input = File.ReadAllText(filename).Replace("\r\n", "\n"); + var inputStream = GenerateStreamFromString(input); + using (Lexer lexer = new Lexer(new StreamReader(inputStream), filename)) + { + + string inputText = File.ReadAllText(filename); + inputText = inputText.Replace("\r\n", "\n"); + StringBuilder roundtripTextBuilder = new StringBuilder(); + StringBuilder outputBuilder = new StringBuilder(); + StringBuilder tokenizedInput = new StringBuilder(); + bool lexerError = false; + + Token token = null; + try + { + do + { + lexer.ConsumeToken(); + token = lexer.CurrentToken; + roundtripTextBuilder.Append(token.Text.Replace("\r\n", "\n")); + outputBuilder.AppendLine(GetTokenString(token)); + tokenizedInput.Append('[').Append(GetTokenCode(token.TokenType)).Append(':').Append(token.Text.Replace("\r\n", "\n")).Append(']'); + } while (token.TokenType != LexerTokenType.Eof); + } + catch (BatchParserException ex) + { + lexerError = true; + outputBuilder.AppendLine(string.Format(CultureInfo.CurrentCulture, "[ERROR: code {0} at {1} - {2} in {3}, message: {4}]", ex.ErrorCode, GetPositionString(ex.Begin), GetPositionString(ex.End), GetFilenameOnly(ex.Begin.Filename), ex.Message)); + } + output.AppendLine("Lexer tokenized input:"); + output.AppendLine("======================"); + output.AppendLine(tokenizedInput.ToString()); + output.AppendLine("Tokens:"); + output.AppendLine("======="); + output.AppendLine(outputBuilder.ToString()); + + if (lexerError == false) + { + // Verify that all text from tokens can be recombined into original string + Assert.Equal(inputText, roundtripTextBuilder.ToString()); + } + } + } + + private string GetTokenCode(LexerTokenType lexerTokenType) + { + switch (lexerTokenType) + { + case LexerTokenType.Text: + return "T"; + case LexerTokenType.Whitespace: + return "WS"; + case LexerTokenType.NewLine: + return "NL"; + case LexerTokenType.Comment: + return "C"; + default: + return lexerTokenType.ToString(); + } + } + + private static void CopyToOutput(string sourceDirectory, string filename) + { + File.Copy(Path.Combine(sourceDirectory, filename), filename, true); + FileUtilities.SetFileReadWrite(filename); + } + + [Fact] + public void BatchParserTest() + { + CopyToOutput(FilesLocation, "TS-err-cycle1.txt"); + CopyToOutput(FilesLocation, "cycle2.txt"); + + Start("err-blockComment"); + Start("err-blockComment2"); + Start("err-varDefinition"); + Start("err-varDefinition2"); + Start("err-varDefinition3"); + Start("err-varDefinition4"); + Start("err-varDefinition5"); + Start("err-varDefinition6"); + Start("err-varDefinition7"); + Start("err-varDefinition8"); + Start("err-varDefinition9"); + Start("err-variableRef"); + Start("err-variableRef2"); + Start("err-variableRef3"); + Start("err-variableRef4"); + Start("err-cycle1"); + Start("input"); + Start("input2"); + Start("pass-blockComment"); + Start("pass-lineComment"); + Start("pass-lineComment2"); + Start("pass-noBlockComments"); + Start("pass-noLineComments"); + Start("pass-varDefinition"); + Start("pass-varDefinition2"); + Start("pass-varDefinition3"); + Start("pass-varDefinition4"); + Start("pass-command-and-comment"); + Assert.False(testFailed, "At least one of test cases failed. Check output for details."); + } + + public void TestParser(string filename, StringBuilder output) + { + try + { + // Create a new file by changing CRLFs to LFs and generate a new steam + // or the tokens generated by the lexer will always have off by one errors + TestCommandHandler commandHandler = new TestCommandHandler(output); + string input = File.ReadAllText(filename).Replace("\r\n", "\n"); + var inputStream = GenerateStreamFromString(input); + StreamReader streamReader = new StreamReader(inputStream); + + using (Parser parser = new Parser( + commandHandler, + new TestVariableResolver(output), + streamReader, + filename)) + { + commandHandler.SetParser(parser); + parser.Parse(); + } + } + catch (BatchParserException ex) + { + output.AppendLine(string.Format(CultureInfo.CurrentCulture, "[PARSER ERROR: code {0} at {1} - {2} in {3}, token text: {4}, message: {5}]", ex.ErrorCode, GetPositionString(ex.Begin), GetPositionString(ex.End), GetFilenameOnly(ex.Begin.Filename), ex.Text, ex.Message)); + } + } + + private string GetPositionString(PositionStruct pos) + { + return string.Format(CultureInfo.InvariantCulture, "{0}:{1} [{2}]", pos.Line, pos.Column, pos.Offset); + } + + private string GetTokenString(Token token) + { + if (token == null) + { + return "(null)"; + } + else + { + string tokenText = token.Text; + if (tokenText != null) + { + tokenText = tokenText.Replace("\r\n", "\\n").Replace("\n", "\\n").Replace("\r", "\\r").Replace("\t", "\\t"); + } + string tokenFilename = token.Filename; + tokenFilename = GetFilenameOnly(tokenFilename); + return string.Format(CultureInfo.CurrentCulture, "[Token {0} at {1}({2}:{3} [{4}] - {5}:{6} [{7}]): '{8}']", + token.TokenType, + tokenFilename, + token.Begin.Line, token.Begin.Column, token.Begin.Offset, + token.End.Line, token.End.Column, token.End.Offset, + tokenText); + } + } + + internal static string GetFilenameOnly(string fullPath) + { + return fullPath != null ? Path.GetFileName(fullPath) : null; + } + + public override void Run() + { + string inputFilename = GetTestscriptFilePath(CurrentTestName); + StringBuilder output = new StringBuilder(); + + TokenizeWithLexer(inputFilename, output); + TestParser(inputFilename, output); + + string baselineFilename = GetBaselineFilePath(CurrentTestName); + string baseline; + + try + { + baseline = GetFileContent(baselineFilename).Replace("\r\n", "\n"); + } + catch (FileNotFoundException) + { + baseline = string.Empty; + } + + string outputString = output.ToString().Replace("\r\n", "\n"); + + Console.WriteLine(baselineFilename); + + if (string.Compare(baseline, outputString, StringComparison.Ordinal) != 0) + { + DumpToTrace(CurrentTestName, outputString); + string outputFilename = Path.Combine(TraceFilePath, GetBaselineFileName(CurrentTestName)); + Console.WriteLine(":: Output does not match the baseline!"); + Console.WriteLine("code --diff \"" + baselineFilename + "\" \"" + outputFilename + "\""); + Console.WriteLine(); + Console.WriteLine(":: To update the baseline:"); + Console.WriteLine("copy \"" + outputFilename + "\" \"" + baselineFilename + "\""); + Console.WriteLine(); + testFailed = true; + } + } + } +} diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/Baselined/BaselinedTest.cs b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/Baselined/BaselinedTest.cs index f358488a..0afa62c8 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/Baselined/BaselinedTest.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/Baselined/BaselinedTest.cs @@ -1,454 +1,448 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// - -using System; -using System.Diagnostics; -using System.IO; -using System.Text; -using Xunit; - -namespace Microsoft.SqlTools.ServiceLayer.Test.Common.Baselined -{ - /// - /// This class serves as the base class for all baselined tests - /// It will provide easy services for you to interact with your test files and their baselines - /// - public abstract class BaselinedTest - { - /// - /// Holds the extension for the TestScripts - /// - private string _testScriptExtension; - - /// - /// Holds the extensionf or the Baseline files - /// - private string _baselineExtension; - - /// - /// Holds the path to the base location of both TestScripts and Baselines - /// - private string _testCategoryName; - - /// - /// Holds the ROOT Dir for trace output - /// - private string _traceOutputDir; - - /// - /// Holds the prefix for the baseline - /// - private string _baselinePrefix; - - /// - /// Holds the prefix for the Testscript - /// - private string _testscriptPrefix; - - /// - /// Holds the name of the current test - /// - private string _currentTestname; - - private string _baselineSubDir = string.Empty; - - public const string TestScriptDirectory = @"Testscripts\"; - public const string BaselineDirectory = @"Baselines\"; - - /// - /// Gets/Sets the extension for the Testscript files - /// - public string TestscriptFileExtension - { - get - { - return _testScriptExtension; - } - set - { - if (string.IsNullOrEmpty(value)) - throw new ArgumentException("TestscriptFileExtension needs a value"); - _testScriptExtension = value; - } - } - - /// - /// Gets/Sets the extension for the Baseline files - /// - public string BaselineFileExtension - { - get - { - return _baselineExtension; - } - set - { - if (string.IsNullOrEmpty(value)) - throw new ArgumentException("BaselineFileExtension needs a value"); - _baselineExtension = value; - } - } - - /// - /// Gets/Sets the path to the base location of both test scripts and baseline files - /// - /// - /// Just use the SubDir name - /// TestScripts should be in FileBaseLocation\Testscripts; and Baselines should be in FileBaseLocation\Baselines - /// The value of this will be appended to ROOT_DIR (QA\SrcUTest\Common) - /// - public string CategoryName - { - get - { - return _testCategoryName; - } - set - { - if (string.IsNullOrEmpty(value)) - throw new ArgumentException("FileBaseLocation needs a value"); - _testCategoryName = value; - } - } - - /// - /// Gets/Sets the output base directory for trace output (null = no trace output) - /// - public string TraceOutputDirectory - { - get - { - return _traceOutputDir; - } - set - { - _traceOutputDir = value; - } - } - - /// - /// Gets the full path of where the files will be pulled from - /// - public string FilesLocation - { - get - { - return Path.Combine(RunEnvironmentInfo.GetTestDataLocation(), CategoryName, TestScriptDirectory); - } - } - - /// - /// Gets or Sets the sub directory in Baselines where the exected baseline results are located - /// - public string BaselinesSubdir - { - get - { - if (this._baselineSubDir == null) - this._baselineSubDir = string.Empty; - return this._baselineSubDir; - } - set { this._baselineSubDir = value; } - } - - /// - /// Gets the full path of where the baseline files will be pulled from - /// - public string BaselineFilePath - { - get - { - return Path.Combine(RunEnvironmentInfo.GetTestDataLocation(), CategoryName, Path.Combine( BaselineDirectory, BaselinesSubdir )); - } - } - - /// - /// Gets the full path of where the Trace will output - /// - public string TraceFilePath - { - get - { - return Path.Combine(Path.GetFullPath(TraceOutputDirectory), this.CategoryName, this.BaselinesSubdir); - } - } - - /// - /// Gets/Sets the prefix used for baseline files - /// - public string BaselinePrefix - { - get - { - return _baselinePrefix; - } - set - { - if (string.IsNullOrEmpty(value)) - throw new ArgumentException("BaselinePrefix needs a value"); - _baselinePrefix = value; - } - } - - /// - /// Gets/Sets the prefix used for testscript files - /// - public string TestscriptPrefix - { - get - { - return _testscriptPrefix; - } - set - { - if (string.IsNullOrEmpty(value)) - throw new ArgumentException("TestscriptPrefix needs a value"); - _testscriptPrefix = value; - } - } - - /// - /// Gets/Sets the name of the current test - /// - public string CurrentTestName - { - get - { - return _currentTestname; - } - } - - /// - /// Constructor - /// - public BaselinedTest() - { - Initialize(); - } - - /// - /// Initializes the class - /// - private void Initialize() - { - _testScriptExtension = _baselineExtension = "txt"; //default to txt - _testCategoryName = null; - string projectPath = Environment.GetEnvironmentVariable(Constants.ProjectPath); - if (projectPath != null) - { - _traceOutputDir = Path.Combine(projectPath, "trace"); - } - else - { - _traceOutputDir = Environment.ExpandEnvironmentVariables(@"%SystemDrive%\trace\"); - } - _baselinePrefix = "BL"; - _testscriptPrefix = "TS"; - } - - /// - /// This method should be called whenever you do a [TestInitialize] - /// - public virtual void TestInitialize() - { - - if (string.IsNullOrEmpty(_testCategoryName)) - throw new ArgumentException("Set CategoryName to the name of the directory containing your Testscripts and Baseline files"); - - if (!Directory.Exists(FilesLocation)) - throw new FileNotFoundException(string.Format("Path to Testscripts ([{0}]) does not exist.", FilesLocation)); - if (!Directory.Exists(BaselineFilePath)) - throw new FileNotFoundException(string.Format("Path to Baseline Files [{0}] does not exist.", BaselineFilePath)); - if (!string.IsNullOrEmpty(TraceFilePath) && !Directory.Exists(TraceFilePath)) //if this does not exist, then we want it (pronto) - Directory.CreateDirectory(TraceFilePath); - - } - - /// - /// Compares two strings and gives appropriate output - /// - /// Actual string - /// Expected string - /// Fails test if strings do not match; comparison is done using an InvariantCulture StringComparer - public void CompareActualWithBaseline(string actualContent, string baselineContent) - { - - int _compareResult = string.Compare(actualContent, baselineContent, StringComparison.OrdinalIgnoreCase); - if (_compareResult != 0) - { - Trace.WriteLine("Debug Info:"); - Trace.WriteLine("========BEGIN=EXPECTED========"); - Trace.WriteLine(baselineContent); - Trace.WriteLine("=========END=EXPECTED========="); - Trace.WriteLine("=========BEGIN=ACTUAL========="); - Trace.WriteLine(actualContent); - Trace.WriteLine("==========END=ACTUAL=========="); - Assert.True(false, string.Format("Comparison failed! (actualContent {0} baselineContent)", (_compareResult < 0 ? "<" : ">"))); //we already know it is not equal - } - else - { - Trace.WriteLine("Compare match! All is fine..."); - } - } - - /// - /// Gets the name of the testscript with the provided name - /// - /// Name of the test - /// the path to the baseline file - /// Asserts that file exists - public string GetTestscriptFilePath(string name) - { - string retVal = Path.Combine(FilesLocation, string.Format("{0}-{1}.{2}", TestscriptPrefix, name, TestscriptFileExtension)); - Assert.True(File.Exists(retVal), string.Format("TestScript [{0}] does not exist", retVal)); - return retVal; - } - - /// - /// Gets the name of the test script with the provided name and the provided index - /// - /// Name of the test - /// File index - /// the path to the baseline file - /// Asserts that file exists - public string GetTestscriptFilePath(string name, int index) - { - string retVal = Path.Combine(FilesLocation, string.Format("{0}-{1}{2}.{3}", TestscriptPrefix, name, index.ToString(), TestscriptFileExtension)); - Assert.True(File.Exists(retVal), string.Format("TestScript [{0}] does not exist", retVal)); - return retVal; - } - - /// - /// Gets the formatted baseline file name - /// - /// Name of the test - public string GetBaselineFileName(string name) - { - return string.Format("{0}-{1}.{2}", BaselinePrefix, name, BaselineFileExtension); - } - - /// - /// Gets the file path to the baseline file for the named case - /// - /// Name of the test - /// the path to the baseline file - /// Asserts that file exists - public string GetBaselineFilePath(string name, bool assertIfNotFound) - { - string retVal = Path.Combine(BaselineFilePath, GetBaselineFileName(name)); - - if (assertIfNotFound) - { - Assert.True(File.Exists(retVal), string.Format("Baseline [{0}] does not exist", retVal)); - } - return retVal; - } - - public string GetBaselineFilePath(string name) - { - return GetBaselineFilePath(name, true); - } - - /// - /// Gets the contents of a file - /// - /// Path of the file to read - /// The contents of the file - public string GetFileContent(string path) - { - Trace.WriteLine(string.Format("GetFileContent for [{0}]", Path.GetFullPath(path))); - - using (StreamReader sr = new StreamReader(File.Open(path, FileMode.Open), Encoding.Unicode)) - { - return sr.ReadToEnd(); - } - } - - /// - /// Dumps the text to a Trace file - /// - /// Test name used to create file name - /// Text to dump to the trace file - /// Overwrites whatever is already in the file (if anything) - public string DumpToTrace(string testName, string text) - { - if (string.IsNullOrEmpty(TraceFilePath)) - { - return string.Empty; //nothing to do - } - - string traceFile = Path.Combine(TraceFilePath, GetBaselineFileName(testName)); - - if (File.Exists(traceFile)) - { - Trace.Write(string.Format("Overwriting existing trace file [{0}]", traceFile)); - File.Delete(traceFile); - } - else - { - Trace.Write(string.Format("Dumping to trace file [{0}]", traceFile)); - } - - if (Directory.Exists(TraceFilePath) == false) - { - Directory.CreateDirectory(TraceFilePath); - } - WriteTraceFile(traceFile, text); - return traceFile; - } - - /// - /// Writes the context to the trace file - /// - /// The file name for the trace output - /// The content for the trace file - public void WriteTraceFile(string traceFile, string text) - { - Stream traceStream = GetStreamFromString(traceFile); - using (StreamWriter sw = new StreamWriter(traceStream, Encoding.Unicode)) - { - sw.Write(text); - sw.Flush(); - sw.Dispose(); - } - } - - /// - /// Converts a string to a stream - /// - /// - /// - private Stream GetStreamFromString(string s) - { - MemoryStream stream = new MemoryStream(); - StreamWriter writer = new StreamWriter(stream); - writer.Write(s); - writer.Flush(); - stream.Position = 0; - return stream; - } - - /// - /// Starts the actual running of the test after nicely initializing - /// - /// Name of the test - public void Start(string testname) - { - Trace.WriteLine(string.Format("Starting test named [{0}]", testname)); - _currentTestname = testname; - - Run(); - - Trace.WriteLine("Test Completed"); - } - - /// - /// Runs the actual test - /// - /// Override this method to put in your test logic - public abstract void Run(); - - } -} +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; +using System.Diagnostics; +using System.IO; +using System.Text; +using Xunit; + +namespace Microsoft.SqlTools.ServiceLayer.Test.Common.Baselined +{ + /// + /// This class serves as the base class for all baselined tests + /// It will provide easy services for you to interact with your test files and their baselines + /// + public abstract class BaselinedTest + { + /// + /// Holds the extension for the TestScripts + /// + private string _testScriptExtension; + + /// + /// Holds the extensionf or the Baseline files + /// + private string _baselineExtension; + + /// + /// Holds the path to the base location of both TestScripts and Baselines + /// + private string _testCategoryName; + + /// + /// Holds the ROOT Dir for trace output + /// + private string _traceOutputDir; + + /// + /// Holds the prefix for the baseline + /// + private string _baselinePrefix; + + /// + /// Holds the prefix for the Testscript + /// + private string _testscriptPrefix; + + /// + /// Holds the name of the current test + /// + private string _currentTestname; + + private string _baselineSubDir = string.Empty; + + public const string TestScriptDirectory = @"Testscripts\"; + public const string BaselineDirectory = @"Baselines\"; + + /// + /// Gets/Sets the extension for the Testscript files + /// + public string TestscriptFileExtension + { + get + { + return _testScriptExtension; + } + set + { + if (string.IsNullOrEmpty(value)) + throw new ArgumentException("TestscriptFileExtension needs a value"); + _testScriptExtension = value; + } + } + + /// + /// Gets/Sets the extension for the Baseline files + /// + public string BaselineFileExtension + { + get + { + return _baselineExtension; + } + set + { + if (string.IsNullOrEmpty(value)) + throw new ArgumentException("BaselineFileExtension needs a value"); + _baselineExtension = value; + } + } + + /// + /// Gets/Sets the path to the base location of both test scripts and baseline files + /// + /// + /// Just use the SubDir name + /// TestScripts should be in FileBaseLocation\Testscripts; and Baselines should be in FileBaseLocation\Baselines + /// The value of this will be appended to ROOT_DIR (QA\SrcUTest\Common) + /// + public string CategoryName + { + get + { + return _testCategoryName; + } + set + { + if (string.IsNullOrEmpty(value)) + throw new ArgumentException("FileBaseLocation needs a value"); + _testCategoryName = value; + } + } + + /// + /// Gets/Sets the output base directory for trace output (null = no trace output) + /// + public string TraceOutputDirectory + { + get + { + return _traceOutputDir; + } + set + { + _traceOutputDir = value; + } + } + + /// + /// Gets the full path of where the files will be pulled from + /// + public string FilesLocation + { + get + { + return Path.Combine(RunEnvironmentInfo.GetTestDataLocation(), CategoryName, TestScriptDirectory); + } + } + + /// + /// Gets or Sets the sub directory in Baselines where the exected baseline results are located + /// + public string BaselinesSubdir + { + get + { + if (this._baselineSubDir == null) + this._baselineSubDir = string.Empty; + return this._baselineSubDir; + } + set { this._baselineSubDir = value; } + } + + /// + /// Gets the full path of where the baseline files will be pulled from + /// + public string BaselineFilePath + { + get + { + return Path.Combine(RunEnvironmentInfo.GetTestDataLocation(), CategoryName, Path.Combine( BaselineDirectory, BaselinesSubdir )); + } + } + + /// + /// Gets the full path of where the Trace will output + /// + public string TraceFilePath + { + get + { + return Path.Combine(Path.GetFullPath(TraceOutputDirectory), this.CategoryName, this.BaselinesSubdir); + } + } + + /// + /// Gets/Sets the prefix used for baseline files + /// + public string BaselinePrefix + { + get + { + return _baselinePrefix; + } + set + { + if (string.IsNullOrEmpty(value)) + throw new ArgumentException("BaselinePrefix needs a value"); + _baselinePrefix = value; + } + } + + /// + /// Gets/Sets the prefix used for testscript files + /// + public string TestscriptPrefix + { + get + { + return _testscriptPrefix; + } + set + { + if (string.IsNullOrEmpty(value)) + throw new ArgumentException("TestscriptPrefix needs a value"); + _testscriptPrefix = value; + } + } + + /// + /// Gets/Sets the name of the current test + /// + public string CurrentTestName + { + get + { + return _currentTestname; + } + } + + /// + /// Constructor + /// + public BaselinedTest() + { + Initialize(); + } + + /// + /// Initializes the class + /// + private void Initialize() + { + _testScriptExtension = _baselineExtension = "txt"; //default to txt + _testCategoryName = null; + string projectPath = Environment.GetEnvironmentVariable(Constants.ProjectPath); + if (projectPath != null) + { + _traceOutputDir = Path.Combine(projectPath, "trace"); + } + else + { + _traceOutputDir = Environment.ExpandEnvironmentVariables(@"%SystemDrive%\trace\"); + } + _baselinePrefix = "BL"; + _testscriptPrefix = "TS"; + } + + /// + /// This method should be called whenever you do a [TestInitialize] + /// + public virtual void TestInitialize() + { + + if (string.IsNullOrEmpty(_testCategoryName)) + throw new ArgumentException("Set CategoryName to the name of the directory containing your Testscripts and Baseline files"); + + if (!Directory.Exists(FilesLocation)) + throw new FileNotFoundException(string.Format("Path to Testscripts ([{0}]) does not exist.", FilesLocation)); + if (!Directory.Exists(BaselineFilePath)) + throw new FileNotFoundException(string.Format("Path to Baseline Files [{0}] does not exist.", BaselineFilePath)); + if (!string.IsNullOrEmpty(TraceFilePath) && !Directory.Exists(TraceFilePath)) //if this does not exist, then we want it (pronto) + Directory.CreateDirectory(TraceFilePath); + + } + + /// + /// Compares two strings and gives appropriate output + /// + /// Actual string + /// Expected string + /// Fails test if strings do not match; comparison is done using an InvariantCulture StringComparer + public void CompareActualWithBaseline(string actualContent, string baselineContent) + { + + int _compareResult = string.Compare(actualContent, baselineContent, StringComparison.OrdinalIgnoreCase); + if (_compareResult != 0) + { + Trace.WriteLine("Debug Info:"); + Trace.WriteLine("========BEGIN=EXPECTED========"); + Trace.WriteLine(baselineContent); + Trace.WriteLine("=========END=EXPECTED========="); + Trace.WriteLine("=========BEGIN=ACTUAL========="); + Trace.WriteLine(actualContent); + Trace.WriteLine("==========END=ACTUAL=========="); + Assert.True(false, string.Format("Comparison failed! (actualContent {0} baselineContent)", (_compareResult < 0 ? "<" : ">"))); //we already know it is not equal + } + else + { + Trace.WriteLine("Compare match! All is fine..."); + } + } + + /// + /// Gets the name of the testscript with the provided name + /// + /// Name of the test + /// the path to the baseline file + /// Asserts that file exists + public string GetTestscriptFilePath(string name) + { + string retVal = Path.Combine(FilesLocation, string.Format("{0}-{1}.{2}", TestscriptPrefix, name, TestscriptFileExtension)); + Assert.True(File.Exists(retVal), string.Format("TestScript [{0}] does not exist", retVal)); + return retVal; + } + + /// + /// Gets the name of the test script with the provided name and the provided index + /// + /// Name of the test + /// File index + /// the path to the baseline file + /// Asserts that file exists + public string GetTestscriptFilePath(string name, int index) + { + string retVal = Path.Combine(FilesLocation, string.Format("{0}-{1}{2}.{3}", TestscriptPrefix, name, index.ToString(), TestscriptFileExtension)); + Assert.True(File.Exists(retVal), string.Format("TestScript [{0}] does not exist", retVal)); + return retVal; + } + + /// + /// Gets the formatted baseline file name + /// + /// Name of the test + public string GetBaselineFileName(string name) + { + return string.Format("{0}-{1}.{2}", BaselinePrefix, name, BaselineFileExtension); + } + + /// + /// Gets the file path to the baseline file for the named case + /// + /// Name of the test + /// the path to the baseline file + /// Asserts that file exists + public string GetBaselineFilePath(string name, bool assertIfNotFound) + { + string retVal = Path.Combine(BaselineFilePath, GetBaselineFileName(name)); + + if (assertIfNotFound) + { + Assert.True(File.Exists(retVal), string.Format("Baseline [{0}] does not exist", retVal)); + } + return retVal; + } + + public string GetBaselineFilePath(string name) + { + return GetBaselineFilePath(name, true); + } + + /// + /// Gets the contents of a file + /// + /// Path of the file to read + /// The contents of the file + public string GetFileContent(string path) + { + Trace.WriteLine(string.Format("GetFileContent for [{0}]", Path.GetFullPath(path))); + + using (StreamReader sr = new StreamReader(File.Open(path, FileMode.Open), Encoding.UTF8)) + { + return sr.ReadToEnd(); + } + } + + /// + /// Dumps the text to a Trace file + /// + /// Test name used to create file name + /// Text to dump to the trace file + /// Overwrites whatever is already in the file (if anything) + public string DumpToTrace(string testName, string text) + { + if (string.IsNullOrEmpty(TraceFilePath)) + { + return string.Empty; //nothing to do + } + + string traceFile = Path.Combine(TraceFilePath, GetBaselineFileName(testName)); + + if (File.Exists(traceFile)) + { + Trace.Write(string.Format("Overwriting existing trace file [{0}]", traceFile)); + File.Delete(traceFile); + } + else + { + Trace.Write(string.Format("Dumping to trace file [{0}]", traceFile)); + } + + if (Directory.Exists(TraceFilePath) == false) + { + Directory.CreateDirectory(TraceFilePath); + } + WriteTraceFile(traceFile, text); + return traceFile; + } + + /// + /// Writes the context to the trace file + /// + /// The file name for the trace output + /// The content for the trace file + public void WriteTraceFile(string traceFile, string text) + { + File.WriteAllText(traceFile, text); + } + + /// + /// Converts a string to a stream + /// + /// + /// + private Stream GetStreamFromString(string s) + { + MemoryStream stream = new MemoryStream(); + StreamWriter writer = new StreamWriter(stream); + writer.Write(s); + writer.Flush(); + stream.Position = 0; + return stream; + } + + /// + /// Starts the actual running of the test after nicely initializing + /// + /// Name of the test + public void Start(string testname) + { + Trace.WriteLine(string.Format("Starting test named [{0}]", testname)); + _currentTestname = testname; + + Run(); + + Trace.WriteLine("Test Completed"); + } + + /// + /// Runs the actual test + /// + /// Override this method to put in your test logic + public abstract void Run(); + + } +} diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/RunEnvironmentInfo.cs b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/RunEnvironmentInfo.cs index 2889214e..4e6119de 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/RunEnvironmentInfo.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/RunEnvironmentInfo.cs @@ -1,73 +1,112 @@ - -// -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// - -using System; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.InteropServices; - -namespace Microsoft.SqlTools.ServiceLayer.Test.Common -{ - /// - /// Contains environment information needed when running tests. - /// - public class RunEnvironmentInfo - { - private static string cachedTestFolderPath; - - public static bool IsLabMode() - { - string bvtLabRoot = Environment.GetEnvironmentVariable(Constants.BVTLocalRoot); - if (string.IsNullOrEmpty(bvtLabRoot)) - { - return false; - } - return true; - } - - /// - /// Location of all test data (baselines, etc). - /// - /// The full path to the test data directory - public static string GetTestDataLocation() - { - string testFolderPath; - string testPath = Path.Combine("test", "Microsoft.SqlTools.ServiceLayer.Test.Common", "TestData"); - string projectPath = Environment.GetEnvironmentVariable(Constants.ProjectPath); - - if (projectPath != null) - { - testFolderPath = Path.Combine(projectPath, testPath); - } - else - { - if (cachedTestFolderPath != null) - { - testFolderPath = cachedTestFolderPath; - } - else - { - // We are running tests locally, which means we expect to be running inside the bin\debug\netcoreapp directory - // Test Files should be found at the root of the project so go back the necessary number of directories for this - // to be found. We are manually specifying the testFolderPath here for clarity on where to expect this - - string assemblyDir = Path.GetDirectoryName(typeof(Scripts).GetTypeInfo().Assembly.Location); - string defaultPath = Path.Combine(assemblyDir, GoUpNDirectories(4)); - testFolderPath = Path.Combine(defaultPath, "Microsoft.SqlTools.ServiceLayer.Test.Common", "TestData"); - - cachedTestFolderPath = testFolderPath; - } - } - return testFolderPath; - } - private static string GoUpNDirectories(int n) - { - string up = ".." + (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "\\" : "/"); - return string.Concat(Enumerable.Repeat(up, n)); - } - } -} + +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; + +namespace Microsoft.SqlTools.ServiceLayer.Test.Common +{ + /// + /// Contains environment information needed when running tests. + /// + public class RunEnvironmentInfo + { + private static string cachedTestFolderPath; + private static string cachedTraceFolderPath; + + public static bool IsLabMode() + { + string bvtLabRoot = Environment.GetEnvironmentVariable(Constants.BVTLocalRoot); + if (string.IsNullOrEmpty(bvtLabRoot)) + { + return false; + } + return true; + } + + /// + /// Location of all test data (baselines, etc). + /// + /// The full path to the test data directory + public static string GetTestDataLocation() + { + string testFolderPath; + string testPath = Path.Combine("test", "Microsoft.SqlTools.ServiceLayer.Test.Common", "TestData"); + string projectPath = Environment.GetEnvironmentVariable(Constants.ProjectPath); + + if (projectPath != null) + { + testFolderPath = Path.Combine(projectPath, testPath); + } + else + { + if (cachedTestFolderPath != null) + { + testFolderPath = cachedTestFolderPath; + } + else + { + // We are running tests locally, which means we expect to be running inside the bin\debug\netcoreapp directory + // Test Files should be found at the root of the project so go back the necessary number of directories for this + // to be found. We are manually specifying the testFolderPath here for clarity on where to expect this + + string assemblyDir = Path.GetDirectoryName(typeof(Scripts).GetTypeInfo().Assembly.Location); + string defaultPath = Path.Combine(assemblyDir, GoUpNDirectories(4)); + testFolderPath = Path.Combine(defaultPath, "Microsoft.SqlTools.ServiceLayer.Test.Common", "TestData"); + + cachedTestFolderPath = testFolderPath; + } + } + return testFolderPath; + } + + /// + /// Location of all trace data (expected output) + /// + /// The full path to the trace data directory + public static string GetTraceOutputLocation() + { + string traceFolderPath; + string testPath = @"test\Microsoft.SqlTools.ServiceLayer.Test.Common\Trace"; + string projectPath = Environment.GetEnvironmentVariable(Constants.ProjectPath); + + if (projectPath != null) + { + traceFolderPath = Path.Combine(projectPath, testPath); + } + else + { + if (cachedTraceFolderPath != null) + { + traceFolderPath = cachedTraceFolderPath; + } + else + { + // We are running tests locally, which means we expect to be running inside the bin\debug\netcoreapp directory + // Test Files should be found at the root of the project so go back the necessary number of directories for this + // to be found. We are manually specifying the testFolderPath here for clarity on where to expect this + + string assemblyDir = Path.GetDirectoryName(typeof(Scripts).GetTypeInfo().Assembly.Location); + string defaultPath = Path.Combine(assemblyDir, GoUpNDirectories(4)); + traceFolderPath = Path.Combine(defaultPath, "Microsoft.SqlTools.ServiceLayer.Test.Common", "TestData"); + + cachedTraceFolderPath = traceFolderPath; + } + } + return traceFolderPath; + } + + private static string GoUpNDirectories(int n) + { + string up = ".." + (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "\\" : "/"); + return string.Concat(Enumerable.Repeat(up, n)); + + } + } +} diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-blockComment.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-blockComment.txt index 5f18e60c..0096e7d9 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-blockComment.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-blockComment.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-blockComment2.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-blockComment2.txt index 9ea67865..29f584c4 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-blockComment2.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-blockComment2.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-cycle1.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-cycle1.txt index 99ccebc2..ce036347 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-cycle1.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-cycle1.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition.txt index 366ee9cb..b2d8d847 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition2.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition2.txt index d528a7a4..12d1f3c1 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition2.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition2.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition3.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition3.txt index af42b18f..fac12a56 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition3.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition3.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition4.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition4.txt index 6525f508..3785dafc 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition4.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition4.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition5.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition5.txt index bda188ad..b8b4484a 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition5.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition5.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition6.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition6.txt index 47a16c60..f6648d8b 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition6.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition6.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition7.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition7.txt index 2b90818b..6614f9e1 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition7.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition7.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition8.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition8.txt index 26d9035a..54c97259 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition8.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition8.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition9.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition9.txt index 2d122500..8dc07583 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition9.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-varDefinition9.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-variableRef.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-variableRef.txt index 8699187c..69ea48c7 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-variableRef.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-variableRef.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-variableRef2.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-variableRef2.txt index fd242565..6468f7f1 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-variableRef2.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-variableRef2.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-variableRef3.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-variableRef3.txt index 53d8180f..cabbdfb7 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-variableRef3.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-variableRef3.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-variableRef4.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-variableRef4.txt index 99e4ac12..8f4b116e 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-variableRef4.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-err-variableRef4.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-input.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-input.txt index c5d6a3fb..ba5b26d3 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-input.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-input.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-input2.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-input2.txt index c36560e5..97c741cb 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-input2.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-input2.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-blockComment.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-blockComment.txt index 107771e5..c6a0a854 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-blockComment.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-blockComment.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-command-and-comment.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-command-and-comment.txt index 96eb3904..eca59480 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-command-and-comment.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-command-and-comment.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-lineComment.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-lineComment.txt index 3c48e618..442a4b3c 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-lineComment.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-lineComment.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-lineComment2.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-lineComment2.txt index 08b2fb91..a03606cf 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-lineComment2.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-lineComment2.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-noBlockComments.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-noBlockComments.txt index 24d436f6..2bbe59a6 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-noBlockComments.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-noBlockComments.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-noLineComments.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-noLineComments.txt index c9b21fef..ce562f3d 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-noLineComments.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-noLineComments.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-varDefinition.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-varDefinition.txt index 0738badb..2fed3171 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-varDefinition.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-varDefinition.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-varDefinition2.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-varDefinition2.txt index 4e8dd825..4fe26858 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-varDefinition2.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-varDefinition2.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-varDefinition3.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-varDefinition3.txt index a59b0d0c..fea3cd09 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-varDefinition3.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-varDefinition3.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-varDefinition4.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-varDefinition4.txt index c6d63cdf..a636e0df 100644 Binary files a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-varDefinition4.txt and b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/Baselines/BL-pass-varDefinition4.txt differ diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/TestScripts/TS-input.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/TestScripts/TS-input.txt index 3f2bacc7..1254f3b0 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/TestScripts/TS-input.txt +++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/BatchParser/TestScripts/TS-input.txt @@ -1,4 +1,4 @@ -GO 2 +GO 2 BEGIN :r input-2.txt :r "input-2.txt" diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceProvider.cs b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceProvider.cs index a9f1e4f7..607b5f3f 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceProvider.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceProvider.cs @@ -135,7 +135,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common } TestServiceProvider.hasInitServices = true; - const string hostName = "SQ Tools Test Service Host"; + const string hostName = "SQL Tools Test Service Host"; const string hostProfileId = "SQLToolsTestService"; Version hostVersion = new Version(1, 0);