<commit_before>﻿// Copyright (C) Pash Contributors. License GPL/BSD. See https://github.com/Pash-Project/Pash/
using System;
using System.IO;
using NUnit.Framework;

namespace TestHost.FileSystemTests
{
    class ShellExecutionTest : FileSystemTestBase
    {
        [Test]
        [TestCase("file.bat", "123")]
        public void FileShouldBeExecutedByAbsolutePath(string executableName, string executableResult)
        {
            var root = SetupExecutableWithResult(executableName, executableResult);
            var absolutePath = Path.Combine(Path.GetFullPath(root), executableName);

            var result = TestHost.ExecuteWithZeroErrors(absolutePath);
            result.Trim().ShouldEqual(executableResult);
        }

        [Test]
        [TestCase("file.bat", "123", @".\file.bat", Ignore = true, IgnoreReason = "Ignored because of bug in command parser.")]
        [TestCase(@"directory\file.bat", "123", @"directory\file.bat")]
        [TestCase(@"directory\file.bat", "123", @"directory\file.bat 127.0.0.1", Ignore = true, IgnoreReason = "Ignored because of bug in argument parser.")]
        public void FileShouldBeExecutedByRelativePath(string executableName, string executableResult, string command)
        {
            var root = SetupExecutableWithResult(executableName, executableResult);
            Environment.CurrentDirectory = root;
            
            var result = TestHost.ExecuteWithZeroErrors(command);
            result.Trim().ShouldEqual(executableResult);
        }

        [Test]
        [TestCase("file.bat", "123", "file.bat")]
        [TestCase("file.bat", "123", "file")]
        public void FileShouldBeExecutedFromSystemPath(string executableName, string executableResult, string command)
        {
            var root = SetupExecutableWithResult(executableName, executableResult);
            var path = String.Format("{0}{1}{2}", root, Path.PathSeparator, Environment.GetEnvironmentVariable("PATH"));
            Environment.SetEnvironmentVariable("PATH", path);

            var result = TestHost.ExecuteWithZeroErrors(command);
            result.Trim().ShouldEqual(executableResult);
        }
    }
}<commit_msg>Fix tests.<commit_after>﻿// Copyright (C) Pash Contributors. License GPL/BSD. See https://github.com/Pash-Project/Pash/
using System;
using System.IO;
using NUnit.Framework;

namespace TestHost.FileSystemTests
{
    class ShellExecutionTest : FileSystemTestBase
    {
        [Test]
        [Platform("Win")]
        [TestCase("file.bat", "123")]
        public void FileShouldBeExecutedByAbsolutePath(string executableName, string executableResult)
        {
            var root = SetupExecutableWithResult(executableName, executableResult);
            var absolutePath = Path.Combine(Path.GetFullPath(root), executableName);

            CatchCommandResult(absolutePath).Trim().ShouldEqual(executableResult);
        }

        [Test]
        [Platform("Win")]
        [TestCase("file.bat", "123", @".\file.bat", Ignore = true, IgnoreReason = "Ignored because of bug in command parser.")]
        [TestCase(@"directory\file.bat", "123", @"directory\file.bat")]
        [TestCase(@"directory\file.bat", "123", @"directory\file.bat 127.0.0.1", Ignore = true, IgnoreReason = "Ignored because of bug in argument parser.")]
        public void FileShouldBeExecutedByRelativePath(string executableName, string executableResult, string command)
        {
            var root = SetupExecutableWithResult(executableName, executableResult);
            Environment.CurrentDirectory = root;
            
            CatchCommandResult(command).Trim().ShouldEqual(executableResult);
        }

        [Test]
        [Platform("Win")]
        [TestCase("file.bat", "123", "file.bat")]
        [TestCase("file.bat", "123", "file")]
        public void FileShouldBeExecutedFromSystemPath(string executableName, string executableResult, string command)
        {
            var root = SetupExecutableWithResult(executableName, executableResult);
            var path = String.Format("{0}{1}{2}", root, Path.PathSeparator, Environment.GetEnvironmentVariable("PATH"));
            Environment.SetEnvironmentVariable("PATH", path);

            CatchCommandResult(command).Trim().ShouldEqual(executableResult);
        }

        /// <summary>
        /// Catches the executable result and echoes it to the output.
        /// </summary>
        /// <param name="command">Execution command.</param>
        /// <returns>Executed command result.</returns>
        private static string CatchCommandResult(string command)
        {
            var result = TestHost.ExecuteWithZeroErrors(string.Format("$result = ({0})", command), "$result");
            return result;
        }
    }
}
{'fraction_non_alphanumeric': 0.12128869235628553, 'fraction_numerical': 0.011581385554853654, 'mean_word_length': 3.015215553677092, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7553563', 'n_tokens_mistral': 1289, 'n_tokens_neox': 1210, 'n_words': 268}