# Path: project_generator/commands/build.py
# def run(args):
# def setup(subparser):
# 
# Path: tests/test_commands/simple_project.py



import argparse
import os
import yaml
import shutil
from unittest import TestCase
from nose.tools import *
from project_generator.commands import build
from .simple_project import project_1_yaml, projects_yaml, project_2_yaml
    def setUp(self):
        if not os.path.exists('test_workspace'):
            os.makedirs('test_workspace')
        # write project file
        with open(os.path.join(os.getcwd(), 'test_workspace/project_1.yaml'), 'wt') as f:
            f.write(yaml.dump(project_1_yaml, default_flow_style=False))
        # write project file
        with open(os.path.join(os.getcwd(), 'test_workspace/project_2.yaml'), 'wt') as f:
            f.write(yaml.dump(project_2_yaml, default_flow_style=False))
        # write projects file
        with open(os.path.join(os.getcwd(), 'test_workspace/projects.yaml'), 'wt') as f:
            f.write(yaml.dump(projects_yaml, default_flow_style=False))
        with open(os.path.join(os.getcwd(), 'test_workspace/linker.ld'), 'wt'):
            pass
        with open(os.path.join(os.getcwd(), 'test_workspace/main.cpp'), 'wt') as f:
            f.write("int __bss_start__ = 0;\nint __bss_end__ = 0;\nint _exit = 0;\nint main() {}\n")

        self.parser = argparse.ArgumentParser()
        subparsers = self.parser.add_subparsers(help='commands')
        self.subparser = subparsers.add_parser('build', help=build.help)
        build.setup(self.subparser)

    def tearDown(self):
        # remove created directory
        shutil.rmtree('test_workspace', ignore_errors=True)
        shutil.rmtree('generated_projects', ignore_errors=True)

    def test_build_project_unknown_tool(self):
        args = self.parser.parse_args(['build','-f','test_workspace/projects.yaml','-p',
            'project_2'])

# Path: project_generator/commands/build.py
# def run(args):
# def setup(subparser):
# 
# Path: tests/test_commands/simple_project.py



# Path: tests/test_commands/test_build.py
import argparse
import os
import yaml
import shutil
from unittest import TestCase
from nose.tools import *
from project_generator.commands import build
from .simple_project import project_1_yaml, projects_yaml, project_2_yaml

    def setUp(self):
        if not os.path.exists('test_workspace'):
            os.makedirs('test_workspace')
        # write project file
        with open(os.path.join(os.getcwd(), 'test_workspace/project_1.yaml'), 'wt') as f:
            f.write(yaml.dump(project_1_yaml, default_flow_style=False))
        # write project file
        with open(os.path.join(os.getcwd(), 'test_workspace/project_2.yaml'), 'wt') as f:
            f.write(yaml.dump(project_2_yaml, default_flow_style=False))
        # write projects file
        with open(os.path.join(os.getcwd(), 'test_workspace/projects.yaml'), 'wt') as f:
            f.write(yaml.dump(projects_yaml, default_flow_style=False))
        with open(os.path.join(os.getcwd(), 'test_workspace/linker.ld'), 'wt'):
            pass
        with open(os.path.join(os.getcwd(), 'test_workspace/main.cpp'), 'wt') as f:
            f.write("int __bss_start__ = 0;\nint __bss_end__ = 0;\nint _exit = 0;\nint main() {}\n")

        self.parser = argparse.ArgumentParser()
        subparsers = self.parser.add_subparsers(help='commands')
        self.subparser = subparsers.add_parser('build', help=build.help)
        build.setup(self.subparser)

    def tearDown(self):
        # remove created directory
        shutil.rmtree('test_workspace', ignore_errors=True)
        shutil.rmtree('generated_projects', ignore_errors=True)

    def test_build_project_unknown_tool(self):
        args = self.parser.parse_args(['build','-f','test_workspace/projects.yaml','-p',
            'project_2'])

        result = build.run(args)