Beispiel #1
0
 def test_config_read_from_file(self):
     ini = """
         [skool2asm]
         Base=16
         Case=1
         CreateLabels=1
         EntryLabel=L_{address}
         EntryPointLabel={main}__{index}
         Quiet=1
         Set-bullet=-
         Set-indent=4
         Templates=templates.ini
         Warnings=0
     """
     self.write_text_file(dedent(ini).strip(), 'skoolkit.ini')
     skoolfile = 'test.skool'
     skool2asm.main((skoolfile, ))
     fname, options, config = run_args
     self.assertEqual(fname, skoolfile)
     self.assertTrue(options.quiet)
     self.assertIsNone(options.writer)
     self.assertEqual(options.case, 1)
     self.assertEqual(options.base, 16)
     self.assertEqual(options.asm_mode, 1)
     self.assertFalse(options.warn)
     self.assertEqual(options.fix_mode, 0)
     self.assertTrue(options.create_labels)
     self.assertEqual(options.start, 0)
     self.assertEqual(options.end, 65536)
     self.assertEqual(sorted(options.properties), ['bullet=-', 'indent=4'])
     self.assertEqual(config['Templates'], 'templates.ini')
     self.assertEqual(config['EntryLabel'], 'L_{address}')
     self.assertEqual(config['EntryPointLabel'], '{main}__{index}')
Beispiel #2
0
 def test_config_read_from_file(self):
     ini = """
         [skool2asm]
         Base=16
         Case=1
         CreateLabels=1
         Quiet=1
         Set-bullet=-
         Set-indent=4
         Warnings=0
     """
     self.write_text_file(dedent(ini).strip(), 'skoolkit.ini')
     skoolfile = 'test.skool'
     skool2asm.main((skoolfile, ))
     fname, options = run_args
     self.assertEqual(fname, skoolfile)
     self.assertTrue(options.quiet)
     self.assertIsNone(options.writer)
     self.assertEqual(options.case, 1)
     self.assertEqual(options.base, 16)
     self.assertEqual(options.asm_mode, 1)
     self.assertFalse(options.warn)
     self.assertEqual(options.fix_mode, 0)
     self.assertTrue(options.create_labels)
     self.assertEqual(options.start, 0)
     self.assertEqual(options.end, 65536)
     self.assertEqual(sorted(options.properties), ['bullet=-', 'indent=4'])
Beispiel #3
0
 def test_config_read_from_file(self):
     ini = """
         [skool2asm]
         Base=16
         Case=1
         CreateLabels=1
         Quiet=1
         Set-bullet=-
         Set-indent=4
         Templates=templates.ini
         Warnings=0
     """
     self.write_text_file(dedent(ini).strip(), 'skoolkit.ini')
     skoolfile = 'test.skool'
     skool2asm.main((skoolfile,))
     fname, options = run_args
     self.assertEqual(fname, skoolfile)
     self.assertTrue(options.quiet)
     self.assertIsNone(options.writer)
     self.assertEqual(options.case, 1)
     self.assertEqual(options.base, 16)
     self.assertEqual(options.asm_mode, 1)
     self.assertFalse(options.warn)
     self.assertEqual(options.templates, 'templates.ini')
     self.assertEqual(options.fix_mode, 0)
     self.assertTrue(options.create_labels)
     self.assertEqual(options.start, 0)
     self.assertEqual(options.end, 65536)
     self.assertEqual(sorted(options.properties), ['bullet=-', 'indent=4'])
Beispiel #4
0
 def test_default_option_values(self):
     skoolfile = 'test.skool'
     skool2asm.main((skoolfile,))
     fname, options = run_args
     self.assertEqual(fname, skoolfile)
     self.assertFalse(options.quiet)
     self.assertIsNone(options.writer)
     self.assertIsNone(options.case)
     self.assertIsNone(options.base)
     self.assertEqual(options.asm_mode, 1)
     self.assertTrue(options.warn)
     self.assertEqual(options.fix_mode, 0)
     self.assertFalse(options.create_labels)
     self.assertEqual(options.start, 0)
     self.assertEqual(options.end, 65536)
Beispiel #5
0
 def test_default_option_values(self):
     skoolfile = 'test.skool'
     skool2asm.main((skoolfile, ))
     fname, options = run_args
     self.assertEqual(fname, skoolfile)
     self.assertFalse(options.quiet)
     self.assertIsNone(options.writer)
     self.assertEqual(options.case, 0)
     self.assertEqual(options.base, 0)
     self.assertEqual(options.asm_mode, 1)
     self.assertTrue(options.warn)
     self.assertEqual(options.fix_mode, 0)
     self.assertFalse(options.create_labels)
     self.assertEqual(options.start, 0)
     self.assertEqual(options.end, 65536)
     self.assertEqual(options.properties, [])
     self.assertEqual(options.params, [])
Beispiel #6
0
 def test_default_option_values(self):
     self.mock(skool2asm, 'run', mock_run)
     skool2asm.main(('test.skool',))
     fname, options, parser_mode, writer_mode = run_args
     self.assertEqual(fname, 'test.skool')
     case = base = None
     asm_mode = 1
     warn = True
     fix_mode = 0
     create_labels = False
     self.assertFalse(options.crlf)
     self.assertIsNone(options.inst_width)
     self.assertFalse(options.quiet)
     self.assertFalse(options.tabs)
     self.assertIsNone(options.writer)
     self.assertEqual(parser_mode, (case, base, asm_mode, warn, fix_mode, create_labels))
     self.assertEqual(writer_mode, (False, warn))
Beispiel #7
0
 def test_invalid_option_values_read_from_file(self):
     ini = '\n'.join(('[skool2asm]', 'Base=!', 'Case=2', 'Quiet=q'))
     self.write_text_file(ini, 'skoolkit.ini')
     skoolfile = 'test.skool'
     skool2asm.main((skoolfile, ))
     fname, options = run_args
     self.assertEqual(fname, skoolfile)
     self.assertFalse(options.quiet)
     self.assertIsNone(options.writer)
     self.assertEqual(options.case, 2)
     self.assertEqual(options.base, 0)
     self.assertEqual(options.asm_mode, 1)
     self.assertTrue(options.warn)
     self.assertEqual(options.fix_mode, 0)
     self.assertFalse(options.create_labels)
     self.assertEqual(options.start, 0)
     self.assertEqual(options.end, 65536)
     self.assertEqual(options.properties, [])
Beispiel #8
0
    def test_config_read_from_file_is_passed(self):
        templates = """
            [comment]
            ;; {text}
        """
        ini = """
            [skool2asm]
            Base=16
            Case=1
            CreateLabels=1
            EntryLabel=L_{{address}}
            EntryPointLabel={{main}}__{{index}}
            Set-bullet=-
            Set-indent=4
            Templates={}
            Warnings=0
        """.format(self.write_text_file(dedent(templates).strip()))
        self.write_text_file(dedent(ini).strip(), 'skoolkit.ini')
        skoolfile = 'test.skool'
        skool2asm.main((skoolfile, ))

        self.assertEqual(mock_skool_parser.skoolfile, skoolfile)
        self.assertEqual(mock_skool_parser.case, 1)
        self.assertEqual(mock_skool_parser.base, 16)
        self.assertEqual(mock_skool_parser.asm_mode, 1)
        self.assertFalse(mock_skool_parser.warnings)
        self.assertEqual(mock_skool_parser.fix_mode, 0)
        self.assertFalse(mock_skool_parser.html)
        self.assertTrue(mock_skool_parser.create_labels)
        self.assertTrue(mock_skool_parser.asm_labels)
        self.assertEqual(mock_skool_parser.label_fmt,
                         ('L_{address}', '{main}__{index}'))
        self.assertEqual(mock_skool_parser.min_address, 0)
        self.assertEqual(mock_skool_parser.max_address, 65536)

        self.assertIs(mock_asm_writer.parser, mock_skool_parser)
        self.assertEqual({
            'bullet': '-',
            'indent': '4',
            'warnings': '0'
        }, mock_asm_writer.properties)
        self.assertEqual({'comment': ';; {text}'}, mock_asm_writer.templates)
        self.assertTrue(mock_asm_writer.wrote)
Beispiel #9
0
    def test_default_option_values_are_passed(self):
        skoolfile = 'test.skool'
        skool2asm.main((skoolfile, ))

        self.assertEqual(mock_skool_parser.skoolfile, skoolfile)
        self.assertEqual(mock_skool_parser.case, 0)
        self.assertEqual(mock_skool_parser.base, 0)
        self.assertEqual(mock_skool_parser.asm_mode, 1)
        self.assertTrue(mock_skool_parser.warnings)
        self.assertEqual(mock_skool_parser.fix_mode, 0)
        self.assertFalse(mock_skool_parser.html)
        self.assertFalse(mock_skool_parser.create_labels)
        self.assertTrue(mock_skool_parser.asm_labels)
        self.assertEqual(mock_skool_parser.min_address, 0)
        self.assertEqual(mock_skool_parser.max_address, 65536)

        self.assertIs(mock_asm_writer.parser, mock_skool_parser)
        self.assertEqual({}, mock_asm_writer.properties)
        self.assertTrue(mock_asm_writer.wrote)
Beispiel #10
0
    def test_default_option_values_are_passed(self):
        skoolfile = 'test.skool'
        skool2asm.main((skoolfile,))

        self.assertEqual(mock_skool_parser.skoolfile, skoolfile)
        self.assertIsNone(mock_skool_parser.case)
        self.assertIsNone(mock_skool_parser.base)
        self.assertEqual(mock_skool_parser.asm_mode, 1)
        self.assertTrue(mock_skool_parser.warnings)
        self.assertEqual(mock_skool_parser.fix_mode, 0)
        self.assertFalse(mock_skool_parser.html)
        self.assertFalse(mock_skool_parser.create_labels)
        self.assertTrue(mock_skool_parser.asm_labels)
        self.assertEqual(mock_skool_parser.min_address, 0)
        self.assertEqual(mock_skool_parser.max_address, 65536)

        self.assertIs(mock_asm_writer.parser, mock_skool_parser)
        self.assertFalse(mock_asm_writer.lower)
        self.assertEqual({}, mock_asm_writer.properties)
        self.assertTrue(mock_asm_writer.wrote)
Beispiel #11
0
 def test_config_read_from_file(self):
     ini = '\n'.join(
         ('[skool2asm]', 'Base=16', 'Case=1', 'CreateLabels=1', 'Quiet=1',
          'Set-bullet=-', 'Set-indent=4', 'Warnings=0'))
     self.write_text_file(ini, 'skoolkit.ini')
     skoolfile = 'test.skool'
     skool2asm.main((skoolfile, ))
     fname, options = run_args
     self.assertEqual(fname, skoolfile)
     self.assertTrue(options.quiet)
     self.assertIsNone(options.writer)
     self.assertEqual(options.case, 1)
     self.assertEqual(options.base, 16)
     self.assertEqual(options.asm_mode, 1)
     self.assertFalse(options.warn)
     self.assertEqual(options.fix_mode, 0)
     self.assertTrue(options.create_labels)
     self.assertEqual(options.start, 0)
     self.assertEqual(options.end, 65536)
     self.assertEqual(sorted(options.properties), ['bullet=-', 'indent=4'])
Beispiel #12
0
 def test_default_option_values(self):
     skoolfile = 'test.skool'
     skool2asm.main((skoolfile, ))
     fname, options, config = run_args
     self.assertEqual(fname, skoolfile)
     self.assertFalse(options.quiet)
     self.assertIsNone(options.writer)
     self.assertEqual(options.case, 0)
     self.assertEqual(options.base, 0)
     self.assertEqual(options.asm_mode, 1)
     self.assertTrue(options.warn)
     self.assertEqual(options.fix_mode, 0)
     self.assertFalse(options.create_labels)
     self.assertEqual(options.start, 0)
     self.assertEqual(options.end, 65536)
     self.assertEqual(options.properties, [])
     self.assertEqual(options.params, [])
     self.assertEqual(options.variables, [])
     self.assertFalse(options.force)
     self.assertEqual(config['Templates'], '')
     self.assertEqual(config['EntryLabel'], 'L{address}')
     self.assertEqual(config['EntryPointLabel'], '{main}_{index}')
Beispiel #13
0
 def test_invalid_option_values_read_from_file(self):
     ini = """
         [skool2asm]
         Base=!
         Case=2
         Quiet=q
     """
     self.write_text_file(dedent(ini).strip(), 'skoolkit.ini')
     skoolfile = 'test.skool'
     skool2asm.main((skoolfile,))
     fname, options = run_args
     self.assertEqual(fname, skoolfile)
     self.assertFalse(options.quiet)
     self.assertIsNone(options.writer)
     self.assertEqual(options.case, 2)
     self.assertEqual(options.base, 0)
     self.assertEqual(options.asm_mode, 1)
     self.assertTrue(options.warn)
     self.assertEqual(options.fix_mode, 0)
     self.assertFalse(options.create_labels)
     self.assertEqual(options.start, 0)
     self.assertEqual(options.end, 65536)
     self.assertEqual(options.properties, [])
Beispiel #14
0
 def test_invalid_option_values_read_from_file(self):
     ini = """
         [skool2asm]
         Base=!
         Case=2
         Quiet=q
     """
     self.write_text_file(dedent(ini).strip(), 'skoolkit.ini')
     skoolfile = 'test.skool'
     skool2asm.main((skoolfile, ))
     fname, options, config = run_args
     self.assertEqual(fname, skoolfile)
     self.assertFalse(options.quiet)
     self.assertIsNone(options.writer)
     self.assertEqual(options.case, 2)
     self.assertEqual(options.base, 0)
     self.assertEqual(options.asm_mode, 1)
     self.assertTrue(options.warn)
     self.assertEqual(options.fix_mode, 0)
     self.assertFalse(options.create_labels)
     self.assertEqual(options.start, 0)
     self.assertEqual(options.end, 65536)
     self.assertEqual(options.properties, [])
Beispiel #15
0
def run_skool2asm():
    skool2asm.main(sys.argv[1:] + [BTS_SKOOL])
Beispiel #16
0
def run_skool2asm():
    skool2asm.main(sys.argv[1:] + [ROM_SKOOL])
Beispiel #17
0
def run_skool2asm():
    skool2asm.main(['-H'] + sys.argv[1:] + [ROM_SKOOL])
#!/usr/bin/env python3

# Copyright 2012-2013, 2017 Richard Dymond ([email protected])
#
# This file is part of SkoolKit.
#
# SkoolKit is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# SkoolKit is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# SkoolKit. If not, see <http://www.gnu.org/licenses/>.

import sys

from skoolkit import skool2asm, error, SkoolKitError

try:
    skool2asm.main(sys.argv[1:])
except SkoolKitError as e:
    error(e.args[0])