# Path: grace/error.py
# class FileNotFoundError(Error):
#     pass
# 
# class CreateFolderError(Error):
#     pass
# 
# class RemoveFolderError(Error):
#     pass
# 
# class FileNotWritableError(Error):
#     pass
# 
# class RemoveFileError(Error):
#     pass


from builtins import object
from .error import FileNotFoundError, CreateFolderError, RemoveFolderError, FileNotWritableError, RemoveFileError
from shutil import rmtree, copy2, copytree
import os
import re
import sys
    def run(self, testname):
        if testname is None:
            print('No tests to build.')
            return

        build_path = os.path.join(self._cwd, 'build', self._config['name'] + '_' + testname)
        js_source_path = os.path.join(self._cwd, 'test', 'tests', 'test_' + testname + '.js')

        try:
            self._clean_previous_tests(build_path)
            self._build_javascript(build_path, js_source_path)
            self._build_libraries(build_path)
            self._build_html(build_path)
            self._copy_assets(build_path)
        except:
            raise

    def _clean_previous_tests(self, build_path):
        if os.path.exists(build_path):
            try:
                rmtree(build_path)
            except:
                raise RemoveFolderError('Could not delete the test folder: ' + build_path)

        try:
            os.makedirs(build_path)
        except:
            raise CreateFolderError('Could not create the test folder: ' + build_path)

    def _build_javascript(self, build_path, js_source_path):

# Path: grace/error.py
# class FileNotFoundError(Error):
#     pass
# 
# class CreateFolderError(Error):
#     pass
# 
# class RemoveFolderError(Error):
#     pass
# 
# class FileNotWritableError(Error):
#     pass
# 
# class RemoveFileError(Error):
#     pass


# Path: grace/testit.py
from builtins import object
from .error import FileNotFoundError, CreateFolderError, RemoveFolderError, FileNotWritableError, RemoveFileError
from shutil import rmtree, copy2, copytree
import os
import re
import sys

    def run(self, testname):
        if testname is None:
            print('No tests to build.')
            return

        build_path = os.path.join(self._cwd, 'build', self._config['name'] + '_' + testname)
        js_source_path = os.path.join(self._cwd, 'test', 'tests', 'test_' + testname + '.js')

        try:
            self._clean_previous_tests(build_path)
            self._build_javascript(build_path, js_source_path)
            self._build_libraries(build_path)
            self._build_html(build_path)
            self._copy_assets(build_path)
        except:
            raise

    def _clean_previous_tests(self, build_path):
        if os.path.exists(build_path):
            try:
                rmtree(build_path)
            except:
                raise RemoveFolderError('Could not delete the test folder: ' + build_path)

        try:
            os.makedirs(build_path)
        except:
            raise CreateFolderError('Could not create the test folder: ' + build_path)

    def _build_javascript(self, build_path, js_source_path):

        self._js_string_lines = []