<commit_before>/*
 * SessionTerminalShellTests.cpp
 *
 * Copyright (C) 2009-17 by RStudio, Inc.
 *
 * Unless you have received this program directly from RStudio pursuant
 * to the terms of a commercial license agreement with RStudio, then
 * this program is licensed to you under the terms of version 3 of the
 * GNU Affero General Public License. This program is distributed WITHOUT
 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
 *
 */

#include <session/SessionTerminalShell.hpp>

#include <core/system/System.hpp>

#include <tests/TestThat.hpp>

namespace rstudio {
namespace session {
namespace console_process {
namespace tests {

using namespace console_process;

context("session terminal shell tests")
{
#ifdef _WIN32

   test_that("Can generate json array of shells")
   {
      AvailableTerminalShells shells;
      size_t origCount = shells.count();
      expect_true(origCount > 0);
      core::json::Array arr;
      shells.toJson(&arr);
      expect_true(origCount == arr.size());
   }

   test_that("Windows has 32-bit command prompt")
   {
      AvailableTerminalShells shells;
      expect_true(shells.count() > 0);
      TerminalShell shell;
      expect_true(shells.getInfo(TerminalShell::Cmd32, &shell));
      expect_true(shell.type == TerminalShell::Cmd32);
      expect_true(shell.path.exists());
   }

   test_that("Windows has 32-bit powershell")
   {
      AvailableTerminalShells shells;
      expect_true(shells.count() > 0);
      TerminalShell shell;
      expect_true(shells.getInfo(TerminalShell::PS32, &shell));
      expect_true(shell.type == TerminalShell::PS32);
      expect_true(shell.path.exists());
   }

   test_that("64-bit Windows has 64-bit command prompt")
   {
      if (core::system::isWin64())
      {
         AvailableTerminalShells shells;
         expect_true(shells.count() > 0);
         TerminalShell shell;
         expect_true(shells.getInfo(TerminalShell::Cmd64, &shell));
         expect_true(shell.type == TerminalShell::Cmd64);
         expect_true(shell.path.exists());
      }
   }

   test_that("64-bit Windows has 64-bit powershell")
   {
      if (core::system::isWin64())
      {
         AvailableTerminalShells shells;
         expect_true(shells.count() > 0);
         TerminalShell shell;
         expect_true(shells.getInfo(TerminalShell::PS64, &shell));
         expect_true(shell.type == TerminalShell::PS64);
         expect_true(shell.path.exists());
      }
   }

   test_that("WSL Bash is detected if installed")
   {
         AvailableTerminalShells shells;
         expect_true(shells.count() > 0);
         TerminalShell shell;
         if (shells.getInfo(TerminalShell::WSLBash, &shell))
         {
            expect_true(shell.type == TerminalShell::WSLBash);
            expect_true(shell.path.exists());
         }
   }

   test_that("Git Bash is detected if installed")
   {
      AvailableTerminalShells shells;
      TerminalShell shell;
      if (shells.getInfo(TerminalShell::GitBash, &shell))
      {
         expect_true(shell.type == TerminalShell::GitBash);
         expect_true(shell.path.exists());
      }
   }

   // Only uncomment this test on a system known to have Windows Services
   // for Linux installed.
   test_that("WSL Bash is detected")
   {
      AvailableTerminalShells shells;
      TerminalShell shell;
      expect_true(shells.getInfo(TerminalShell::WSLBash, &shell));
      expect_true(shell.type == TerminalShell::WSLBash);
      expect_true(shell.path.exists());
   }

#endif
}

} // namespace tests
} // namespace console_process
} // namespace session
} // namespace rstudio<commit_msg>turn off unit test that only works on Win-10 x64 with WSL installed<commit_after>/*
 * SessionTerminalShellTests.cpp
 *
 * Copyright (C) 2009-17 by RStudio, Inc.
 *
 * Unless you have received this program directly from RStudio pursuant
 * to the terms of a commercial license agreement with RStudio, then
 * this program is licensed to you under the terms of version 3 of the
 * GNU Affero General Public License. This program is distributed WITHOUT
 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
 *
 */

#include <session/SessionTerminalShell.hpp>

#include <core/system/System.hpp>

#include <tests/TestThat.hpp>

namespace rstudio {
namespace session {
namespace console_process {
namespace tests {

using namespace console_process;

context("session terminal shell tests")
{
#ifdef _WIN32

   test_that("Can generate json array of shells")
   {
      AvailableTerminalShells shells;
      size_t origCount = shells.count();
      expect_true(origCount > 0);
      core::json::Array arr;
      shells.toJson(&arr);
      expect_true(origCount == arr.size());
   }

   test_that("Windows has 32-bit command prompt")
   {
      AvailableTerminalShells shells;
      expect_true(shells.count() > 0);
      TerminalShell shell;
      expect_true(shells.getInfo(TerminalShell::Cmd32, &shell));
      expect_true(shell.type == TerminalShell::Cmd32);
      expect_true(shell.path.exists());
   }

   test_that("Windows has 32-bit powershell")
   {
      AvailableTerminalShells shells;
      expect_true(shells.count() > 0);
      TerminalShell shell;
      expect_true(shells.getInfo(TerminalShell::PS32, &shell));
      expect_true(shell.type == TerminalShell::PS32);
      expect_true(shell.path.exists());
   }

   test_that("64-bit Windows has 64-bit command prompt")
   {
      if (core::system::isWin64())
      {
         AvailableTerminalShells shells;
         expect_true(shells.count() > 0);
         TerminalShell shell;
         expect_true(shells.getInfo(TerminalShell::Cmd64, &shell));
         expect_true(shell.type == TerminalShell::Cmd64);
         expect_true(shell.path.exists());
      }
   }

   test_that("64-bit Windows has 64-bit powershell")
   {
      if (core::system::isWin64())
      {
         AvailableTerminalShells shells;
         expect_true(shells.count() > 0);
         TerminalShell shell;
         expect_true(shells.getInfo(TerminalShell::PS64, &shell));
         expect_true(shell.type == TerminalShell::PS64);
         expect_true(shell.path.exists());
      }
   }

   test_that("WSL Bash is detected if installed")
   {
         AvailableTerminalShells shells;
         expect_true(shells.count() > 0);
         TerminalShell shell;
         if (shells.getInfo(TerminalShell::WSLBash, &shell))
         {
            expect_true(shell.type == TerminalShell::WSLBash);
            expect_true(shell.path.exists());
         }
   }

   test_that("Git Bash is detected if installed")
   {
      AvailableTerminalShells shells;
      TerminalShell shell;
      if (shells.getInfo(TerminalShell::GitBash, &shell))
      {
         expect_true(shell.type == TerminalShell::GitBash);
         expect_true(shell.path.exists());
      }
   }

   // Only uncomment this test on a system known to have Windows Services
   // for Linux installed.
#if 0
   test_that("WSL Bash is detected")
   {
      AvailableTerminalShells shells;
      TerminalShell shell;
      expect_true(shells.getInfo(TerminalShell::WSLBash, &shell));
      expect_true(shell.type == TerminalShell::WSLBash);
      expect_true(shell.path.exists());
   }
#endif

#endif
}

} // namespace tests
} // namespace console_process
} // namespace session
} // namespace rstudio
{'fraction_non_alphanumeric': 0.11000393339451947, 'fraction_numerical': 0.01350465451684804, 'mean_word_length': 3.107700592353258, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2886948', 'n_tokens_mistral': 2393, 'n_tokens_neox': 2245, 'n_words': 530}