# Path: dependency/Builder.py
# class Builder(object):
#     """
#     base class for splicing the compile command
#     """
#     def __init__(self, obj, compiler, workspace):
#         """
#         init function
#         Args:
#             obj : the cvs path of object file
#             compiler : the path of compiler
#             workspace : the workspace path
#         """
#         self.obj = obj
#         self.obj_dir = os.path.dirname(obj)
#         self.compiler = compiler
#         self.workspace = workspace
#         self.build_cmd = None      # build cmd
#         self.error = "OK"
# 
#     def __str__(self):
#         """
#         """
#         return self.build_cmd
#     
#     def GetBuildCmd(self):
#         """
#         return the build cmd
#         """
#         return self.build_cmd
# 
#     def Error(self):
#         """
#         return the error message
#         """
#         return self.error
# 
# Path: util/Function.py
# DIGITS = [str(x) for x in xrange(0, 10)] 
# ALPHABETS = []
# def CheckName(v):
# def DelFiles(path):
# def MoveFiles(src, dst):
# def Mkdir(target_dir):
# def CalcHash(data, method='MD5'):
# def GetFileHash(path, method='MD5'):
# def RunCommand(cmd, ignore_stderr_when_ok=False):
# def RunCommand_tty(cmd):


import os
import sys
import unittest
from dependency import Builder
from util import Function
        self.assertEqual(right_header_cmd, builder.GetHeaderCmd())
        with open('hello.h', 'wb') as f:
            f.write("#include <stdio.h>\n\
void hello()\n\
{\n\
    print(\"hello - hello\");\n\
}\n")
        with open('world.h', 'wb') as f:
            f.write("#include <stdio.h>\n\
void world()\n\
{\n\
    print(\"hello - world\");\n\
}\n")
        with open('get_header_files.cpp', 'wb') as f:
            f.write("#include <stdio.h>\n\
#include <pthread.h>\n\
#include \"hello.h\"\n\
#include \"world.h\"\n\
int main()\n\
{\n\
    hello();\n\
    world();\n\
    return 0;\n\
}\n")
        ret = builder.CalcHeaderFiles()
        self.assertEqual(True, ret['ret'])
        self.assertEqual(sorted(["hello.h", 'world.h']), sorted(ret['headers']))

        Function.DelFiles('get_header_files.cpp')
        Function.DelFiles('hello.h')

# Path: dependency/Builder.py
# class Builder(object):
#     """
#     base class for splicing the compile command
#     """
#     def __init__(self, obj, compiler, workspace):
#         """
#         init function
#         Args:
#             obj : the cvs path of object file
#             compiler : the path of compiler
#             workspace : the workspace path
#         """
#         self.obj = obj
#         self.obj_dir = os.path.dirname(obj)
#         self.compiler = compiler
#         self.workspace = workspace
#         self.build_cmd = None      # build cmd
#         self.error = "OK"
# 
#     def __str__(self):
#         """
#         """
#         return self.build_cmd
#     
#     def GetBuildCmd(self):
#         """
#         return the build cmd
#         """
#         return self.build_cmd
# 
#     def Error(self):
#         """
#         return the error message
#         """
#         return self.error
# 
# Path: util/Function.py
# DIGITS = [str(x) for x in xrange(0, 10)] 
# ALPHABETS = []
# def CheckName(v):
# def DelFiles(path):
# def MoveFiles(src, dst):
# def Mkdir(target_dir):
# def CalcHash(data, method='MD5'):
# def GetFileHash(path, method='MD5'):
# def RunCommand(cmd, ignore_stderr_when_ok=False):
# def RunCommand_tty(cmd):


# Path: unittest/test_Builder.py
import os
import sys
import unittest
from dependency import Builder
from util import Function

        self.assertEqual(right_header_cmd, builder.GetHeaderCmd())
        with open('hello.h', 'wb') as f:
            f.write("#include <stdio.h>\n\
void hello()\n\
{\n\
    print(\"hello - hello\");\n\
}\n")
        with open('world.h', 'wb') as f:
            f.write("#include <stdio.h>\n\
void world()\n\
{\n\
    print(\"hello - world\");\n\
}\n")
        with open('get_header_files.cpp', 'wb') as f:
            f.write("#include <stdio.h>\n\
#include <pthread.h>\n\
#include \"hello.h\"\n\
#include \"world.h\"\n\
int main()\n\
{\n\
    hello();\n\
    world();\n\
    return 0;\n\
}\n")
        ret = builder.CalcHeaderFiles()
        self.assertEqual(True, ret['ret'])
        self.assertEqual(sorted(["hello.h", 'world.h']), sorted(ret['headers']))

        Function.DelFiles('get_header_files.cpp')
        Function.DelFiles('hello.h')

        Function.DelFiles('world.h')