<commit_before>from . import *


class TestXargsCommand(BrokerTestCase):

    def test_basic_usage(self):

        path = os.path.join(self.sandbox, 'one.txt')
        out = self_check_output(['-v', 'xargs', '--', 'bash', '-c', 'echo $AQUE_TID >> "%s"' % path], stdin='1\n')
        tids = [int(x) for x in out.strip().split()]
        self.worker.run_to_end()
        self.assertEqual(open(path).read().strip(), str(tids[0]))

        path = os.path.join(self.sandbox, 'four.txt')
        out = self_check_output(['-v', 'xargs', '--', 'bash', '-c', 'echo $AQUE_TID >> "%s"' % path], stdin='1 2\n3 4\n')
        tids = [int(x) for x in out.strip().split()]
        self.assertEqual(len(tids), 2)
        self.worker.run_to_end()
        self.assertEqual(open(path).read().strip(), '\n'.join(str(x) for x in tids[:-1]))

    def test_word_counts(self):

        path = os.path.join(self.sandbox, 'one.txt')
        out = self_check_output(['-v', 'xargs', '-n1', '--', 'bash', '-c', 'echo $AQUE_TID >> "%s"' % path], stdin='1\n')
        tids = [int(x) for x in out.strip().split()]
        self.worker.run_to_end()
        self.assertEqual(open(path).read().strip(), str(tids[0]))

        path = os.path.join(self.sandbox, 'four.txt')
        out = self_check_output(['-v', 'xargs', '-n1', '--', 'bash', '-c', 'echo $AQUE_TID >> "%s"' % path], stdin='1 2\n3 4\n')
        tids = [int(x) for x in out.strip().split()]
        self.assertEqual(len(tids), 5)
        self.worker.run_to_end()
        self.assertEqual(open(path).read().strip(), '\n'.join(str(x) for x in tids[:-1]))

    def test_line_counts(self):

        path = os.path.join(self.sandbox, 'one.txt')
        out = self_check_output(['-v', 'xargs', '-L1', '--', 'bash', '-c', 'echo $AQUE_TID >> "%s"' % path], stdin='1\n')
        tids = [int(x) for x in out.strip().split()]
        self.worker.run_to_end()
        self.assertEqual(open(path).read().strip(), str(tids[0]))

        path = os.path.join(self.sandbox, 'four.txt')
        out = self_check_output(['-v', 'xargs', '-L1', '--', 'bash', '-c', 'echo $AQUE_TID >> "%s"' % path], stdin='1 2\n3 4\n')
        tids = [int(x) for x in out.strip().split()]
        self.assertEqual(len(tids), 3)<commit_msg>xargs tests must drop --<commit_after>from . import *


class TestXargsCommand(BrokerTestCase):

    def test_basic_usage(self):

        path = os.path.join(self.sandbox, 'one.txt')
        out = self_check_output(['-v', 'xargs', 'bash', '-c', 'echo $AQUE_TID >> "%s"' % path], stdin='1\n')
        tids = [int(x) for x in out.strip().split()]
        self.worker.run_to_end()
        self.assertEqual(open(path).read().strip(), str(tids[0]))

        path = os.path.join(self.sandbox, 'four.txt')
        out = self_check_output(['-v', 'xargs', 'bash', '-c', 'echo $AQUE_TID >> "%s"' % path], stdin='1 2\n3 4\n')
        tids = [int(x) for x in out.strip().split()]
        self.assertEqual(len(tids), 2)
        self.worker.run_to_end()
        self.assertEqual(open(path).read().strip(), '\n'.join(str(x) for x in tids[:-1]))

    def test_word_counts(self):

        path = os.path.join(self.sandbox, 'one.txt')
        out = self_check_output(['-v', 'xargs', '-n1', 'bash', '-c', 'echo $AQUE_TID >> "%s"' % path], stdin='1\n')
        tids = [int(x) for x in out.strip().split()]
        self.worker.run_to_end()
        self.assertEqual(open(path).read().strip(), str(tids[0]))

        path = os.path.join(self.sandbox, 'four.txt')
        out = self_check_output(['-v', 'xargs', '-n1', 'bash', '-c', 'echo $AQUE_TID >> "%s"' % path], stdin='1 2\n3 4\n')
        tids = [int(x) for x in out.strip().split()]
        self.assertEqual(len(tids), 5)
        self.worker.run_to_end()
        self.assertEqual(open(path).read().strip(), '\n'.join(str(x) for x in tids[:-1]))

    def test_line_counts(self):

        path = os.path.join(self.sandbox, 'one.txt')
        out = self_check_output(['-v', 'xargs', '-L1', 'bash', '-c', 'echo $AQUE_TID >> "%s"' % path], stdin='1\n')
        tids = [int(x) for x in out.strip().split()]
        self.worker.run_to_end()
        self.assertEqual(open(path).read().strip(), str(tids[0]))

        path = os.path.join(self.sandbox, 'four.txt')
        out = self_check_output(['-v', 'xargs', '-L1', 'bash', '-c', 'echo $AQUE_TID >> "%s"' % path], stdin='1 2\n3 4\n')
        tids = [int(x) for x in out.strip().split()]
        self.assertEqual(len(tids), 3)
{'fraction_non_alphanumeric': 0.23030029351998194, 'fraction_numerical': 0.012192368480469631, 'mean_word_length': 2.862249346120314, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4599013', 'n_tokens_mistral': 1738, 'n_tokens_neox': 1674, 'n_words': 329}