<commit_before>import os
import subprocess
import pytest

main_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

def write(filename, content):
    open(filename, "w").write(content)

def compile(filename, mode, tmpdir):
    cmd = " ".join(["python", "-m", "prophyc", mode, "--python_out",
                    tmpdir, os.path.join(tmpdir, filename)])
    subprocess.check_call(cmd, cwd = main_dir, shell = True)

def test_isar_input(tmpdir_cwd):
    content = """\
<dom>
    <constant name="MAX_NUM_OF_L2DEPLOYABLE_NODE" value="10"/>
    <typedef name="TPoolId" type="u32"/>
    <typedef name="TNumberOfItems" primitiveType="32 bit integer unsigned"/>
    <enum name="EL2DeployableNode">
        <enum-member name="EL2DeployableNode_Basic1" value="0"/>
        <enum-member name="EL2DeployableNode_Basic2" value="1"/>
        <enum-member name="EL2DeployableNode_Basic3" value="2"/>
        <enum-member name="EL2DeployableNode_Basic4" value="3"/>
    </enum>
    <typedef name="TAaSysComNid" primitiveType="16 bit integer unsigned"/>
    <struct name="SL2PoolInfo">
        <member comment="Pool ID&#13;&#10;In a non Super Pool configuration can be set to 0." name="poolId" type="TPoolId"/>
        <member comment="NID for each deployable node type." name="deploymentInfo" type="SL2DeploymentInfo">
            <dimension isVariableSize="true" minSize="1" size="MAX_NUM_OF_L2DEPLOYABLE_NODE" variableSizeFieldComment="Currently either 4 or 8" variableSizeFieldName="numOfDeploymentInfo"/>
        </member>
    </struct>
    <struct name="SL2DeploymentInfo">
        <member comment="Deployable node type" name="l2NodeType" type="EL2DeployableNode"/>
        <member comment="NID" name="nodeAddr" type="TAaSysComNid"/>
    </struct>
</dom>
"""

    write("isar.xml", content)
    compile("isar.xml", mode = '--isar', tmpdir = str(tmpdir_cwd))<commit_msg>Use correct python interpreter depends on python version<commit_after>import os
import sys
import subprocess
import pytest

main_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

def write(filename, content):
    open(filename, "w").write(content)

def compile(filename, mode, tmpdir):
    cmd = " ".join([sys.executable, "-m", "prophyc", mode, "--python_out",
                    tmpdir, os.path.join(tmpdir, filename)])
    subprocess.check_call(cmd, cwd = main_dir, shell = True)

def test_isar_input(tmpdir_cwd):
    content = """\
<dom>
    <constant name="MAX_NUM_OF_L2DEPLOYABLE_NODE" value="10"/>
    <typedef name="TPoolId" type="u32"/>
    <typedef name="TNumberOfItems" primitiveType="32 bit integer unsigned"/>
    <enum name="EL2DeployableNode">
        <enum-member name="EL2DeployableNode_Basic1" value="0"/>
        <enum-member name="EL2DeployableNode_Basic2" value="1"/>
        <enum-member name="EL2DeployableNode_Basic3" value="2"/>
        <enum-member name="EL2DeployableNode_Basic4" value="3"/>
    </enum>
    <typedef name="TAaSysComNid" primitiveType="16 bit integer unsigned"/>
    <struct name="SL2PoolInfo">
        <member comment="Pool ID&#13;&#10;In a non Super Pool configuration can be set to 0." name="poolId" type="TPoolId"/>
        <member comment="NID for each deployable node type." name="deploymentInfo" type="SL2DeploymentInfo">
            <dimension isVariableSize="true" minSize="1" size="MAX_NUM_OF_L2DEPLOYABLE_NODE" variableSizeFieldComment="Currently either 4 or 8" variableSizeFieldName="numOfDeploymentInfo"/>
        </member>
    </struct>
    <struct name="SL2DeploymentInfo">
        <member comment="Deployable node type" name="l2NodeType" type="EL2DeployableNode"/>
        <member comment="NID" name="nodeAddr" type="TAaSysComNid"/>
    </struct>
</dom>
"""

    write("isar.xml", content)
    compile("isar.xml", mode = '--isar', tmpdir = str(tmpdir_cwd))
{'fraction_non_alphanumeric': 0.14844981607987387, 'fraction_numerical': 0.018917498686284815, 'mean_word_length': 4.339410939691445, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '7639364', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1232, 'n_words': 262}