1
  C   ˆl–Ðz¾”JC]Š�rãm\eõ1hß�þB ’5›’9–2²�ÏÂ„q·ßoÁ_ŠI|¥�+Wé3ž¯ÁÀ ?÷     #!/usr/bin/env python

# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Unit tests for the MSVSSettings.py file."""

try:
  from StringIO import StringIO
except ImportError:
  from io import StringIO
import unittest
import gyp.MSVSSettings as MSVSSettings


class TestSequenceFunctions(unittest.TestCase):

  def setUp(self):
    self.stderr = StringIO()

  def _ExpectedWarnings(self, expected):
    """Compares recorded lines to expected warnings."""
    self.stderr.seek(0)
    actual = self.stderr.read().split('\n')
    actual = [line for line in actual if line]
    self.assertEqual(sorted(expected), sorted(actual))

  def testValidateMSVSSettings_tool_names(self):
    """Tests that only MSVS tool names are allowed."""
    MSVSSettings.ValidateMSVSSettings(
        {'VCCLCompilerTool': {},
         'VCLinkerTool': {},
         'VCMIDLTool': {},
         'foo': {},
         'VCResourceCompilerTool': {},
         'VCLibrarianTool': {},
         'VCManifestTool': {},
         'ClCompile': {}},
        self.stderr)
    self._ExpectedWarnings([
        'Warning: unrecognized tool foo',
        'Warning: unrecognized tool ClCompile'])

  def testValidateMSVSSettings_settings(self):
    """Tests that for invalid MSVS settings."""
    MSVSSettings.ValidateMSVSSettings(
        {'VCCLCompilerTool': {
            'AdditionalIncludeDirectories': 'folder1;folder2',
            'AdditionalOptions': ['string1', 'string2'],
            'AdditionalUsingDirectories': 'folder1;folder2',
            'AssemblerListingLocation': 'a_file_name',
            'AssemblerOutput': '0',
            'BasicRuntimeChecks': '5',
            'BrowseInformation': 'fdkslj',
            'BrowseInformationFile': 'a_file_name',
            'BufferSecurityCheck': 'true',
            'CallingConvention': '-1',
            'CompileAs': '1',
            'DebugInformationFormat': '2',
            'DefaultCharIsUnsigned': 'true',
            'Detect64BitPortabilityProblems': 'true',
            'DisableLanguageExtensions': 'true',
            'DisableSpecificWarnings': 'string1;string2',
            'EnableEnhancedInstructionSet': '1',
            'EnableFiberSafeOptimizations': 'true',
            'EnableFunctionLevelLinking': 'true',
            'EnableIntrinsicFunctions': 'true',
            'EnablePREfast': 'true',
            'Enableprefast': 'bogus',
            'ErrorReporting': '1',
            'ExceptionHandling': '1',
            'ExpandAttributedSource': 'true',
            'FavorSizeOrSpeed': '1',
            'FloatingPointExceptions': 'true',
            'FloatingPointModel': '1',
            'ForceConformanceInForLoopScope': 'true',
            'ForcedIncludeFiles': 'file1;file2',
            'ForcedUsingFiles': 'file1;file2',
            'GeneratePreprocessedFile': '1',
            'GenerateXMLDocumentationFiles': 'true',
            'IgnoreStandardIncludePath': 'true',
            'InlineFunctionExpansion': '1',
            'KeepComments': 'true',
            'MinimalRebuild': 'true',
            'ObjectFile': 'a_file_name',
            'OmitDefaultLibName': 'true',
            'OmitFramePointers': 'true',
            'OpenMP': 'true',
            'Optimization': '1',
            'PrecompiledHeaderFile': 'a_file_name',
            'PrecompiledHeaderThrough': 'a_file_name',
            'PreprocessorDefinitions': 'string1;string2',
            'ProgramDataBaseFileName': 'a_file_name',
            'RuntimeLibrary': '1',
            'RuntimeTypeInfo': 'true',
            'ShowIncludes': 'true',
            'SmallerTypeCheck': 'true',
            'StringPooling': 'true',
            'StructMemberAlignment': '1',
            'SuppressStartupBanner': 'true',
            'TreatWChar_tAsBuiltInType': 'true',
            'UndefineAllPreprocessorDefinitions': 'true',
            'UndefinePreprocessorDefinitions': 'string1;string2',
            'UseFullPaths': 'true',