Exemplo n.º 1
0
import os

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

sys.path.insert(
    1, os.path.abspath(os.path.join(script_dir, os.path.join('..', '..'))))

import pake

# Force the test to occur in the correct place
os.chdir(script_dir)

pk = pake.init()

pake.export('TEST_EXPORT', 'test"test')

pake.export('TEST_EXPORT1', [1, 'te"st', [3, 4, "test'test"]])

pake.export('TEST_EXPORT2', {0: 1, 1: 'te"st', 2: [3, 4, "test'test"]})

pake.export('TEST_EXPORT3', {1, 'te"st', 3, 4, "test'test"})

pake.export('TEST_EXPORT4', (1, 'te"st', [3, 4, "test'test"]))

pake.export('TEST_EXPORT5', '')


@pk.task(i='test_data/one.c', o='test_data/do_single.o')
def do_single(ctx):
    file_helper = pake.FileHelper(ctx)
Exemplo n.º 2
0
    def test_subpake_ignore_errors(self):
        return_code_pakefile = os.path.join(script_dir,
                                            'returncode_pakefile.py')

        pake.de_init(clear_conf=False)

        def assert_return_code(code, ignore_errors, **kwargs):
            nonlocal self
            if ignore_errors:
                self.assertEqual(
                    pake.subpake(return_code_pakefile,
                                 ignore_errors=True,
                                 **kwargs), code)
            else:
                try:
                    self.assertEqual(
                        pake.subpake(return_code_pakefile,
                                     ignore_errors=False,
                                     call_exit=False,
                                     **kwargs), code)

                except pake.SubpakeException as err:
                    err.write_info(pake.conf.stdout
                                   )  # Prevent unit test resource warnings
                    self.assertEqual(err.returncode, code)

        # ====== Non Silent Path =======

        collect_output_test_lock = threading.Lock()

        pake.de_init(clear_conf=False)

        pake.export('RETURNCODE', 42)

        assert_return_code(42, ignore_errors=True)
        assert_return_code(42, ignore_errors=False)

        pake.export('TERMINATE', True)

        assert_return_code(42, ignore_errors=True)
        assert_return_code(42, ignore_errors=False)

        pake.EXPORTS.clear()

        # ====== Non Silent / Collect Output Path =======

        pake.de_init(clear_conf=False)

        pake.export('RETURNCODE', 42)

        assert_return_code(42, ignore_errors=True, collect_output=True)
        assert_return_code(42, ignore_errors=False, collect_output=True)

        assert_return_code(42,
                           ignore_errors=True,
                           collect_output=True,
                           collect_output_lock=collect_output_test_lock)

        assert_return_code(42,
                           ignore_errors=False,
                           collect_output=True,
                           collect_output_lock=collect_output_test_lock)

        pake.export('TERMINATE', True)

        assert_return_code(42, ignore_errors=True, collect_output=True)
        assert_return_code(42, ignore_errors=False, collect_output=True)

        pake.EXPORTS.clear()

        # ======= Silent Path =========

        pake.de_init(clear_conf=False)

        pake.export('RETURNCODE', 42)

        assert_return_code(42, ignore_errors=True, silent=True)
        assert_return_code(42, ignore_errors=False, silent=True)

        pake.export('TERMINATE', True)

        assert_return_code(42, ignore_errors=True, silent=True)
        assert_return_code(42, ignore_errors=False, silent=True)

        pake.EXPORTS.clear()

        # ======= Silent / Collect Output Path =========

        pake.de_init(clear_conf=False)

        pake.export('RETURNCODE', 42)

        assert_return_code(42,
                           ignore_errors=True,
                           silent=True,
                           collect_output=True)
        assert_return_code(42,
                           ignore_errors=False,
                           silent=True,
                           collect_output=True)

        assert_return_code(42,
                           ignore_errors=True,
                           silent=True,
                           collect_output=True,
                           collect_output_lock=collect_output_test_lock)

        assert_return_code(42,
                           ignore_errors=False,
                           silent=True,
                           collect_output=True,
                           collect_output_lock=collect_output_test_lock)

        pake.export('TERMINATE', True)

        assert_return_code(42,
                           ignore_errors=True,
                           silent=True,
                           collect_output=True)
        assert_return_code(42,
                           ignore_errors=False,
                           silent=True,
                           collect_output=True)

        assert_return_code(42,
                           ignore_errors=True,
                           silent=True,
                           collect_output=True,
                           collect_output_lock=collect_output_test_lock)

        assert_return_code(42,
                           ignore_errors=False,
                           silent=True,
                           collect_output=True,
                           collect_output_lock=collect_output_test_lock)

        pake.EXPORTS.clear()
Exemplo n.º 3
0
 def set_init_sync_output_value(value):
     pake.export('INIT_SYNC_OUTPUT_VALUE', value)
Exemplo n.º 4
0
 def set_expected_value(value):
     pake.export('SYNC_OUTPUT_EXPECTED_VALUE', value)
Exemplo n.º 5
0
include_directory_path = os.path.join(os.getcwd(), inc_dir)

m_cc_flags = ['-m64', '-D', '_LIBASM_IO_OBJFMT_' + obj_format_upper + '_']
m_as_flags = [
    '-f', obj_format, '-D', '_LIBASM_IO_BUILDING_', '-I',
    include_directory_path + '/'
]

asm_files = pake.glob(os.path.join(src_dir, '*.asm'))
c_files = pake.glob(os.path.join(src_dir, '*.c'))

asm_objects = pake.pattern(os.path.join(obj_dir, '%' + obj_ext))
c_objects = pake.pattern(os.path.join(obj_dir, '%' + obj_ext))

pake.export('AS', assembler)
pake.export('CC', compiler)
pake.export('OBJ_EXT', obj_ext)
pake.export('EXE_EXT', exe_ext)
pake.export('M_ASM_LIB_PATH', m_asm_lib_path)
pake.export('M_CC_FLAGS', m_cc_flags)
pake.export('M_AS_FLAGS', m_as_flags)


@pk.task(i=os.path.join(inc_dir,
                        'libasm_io_cdecl_' + c_symbol_underscores + '.inc'),
         o=os.path.join(inc_dir, 'libasm_io_cdecl.inc'))
def libasm_io_cdecl(ctx):
    file_helper = pake.FileHelper(ctx)
    file_helper.copy(ctx.inputs[0], ctx.outputs[0])