コード例 #1
0
    def test_transpiler_creates_files_with_format(self):
        self.clean_auto_funcs()

        transpiler.main(["--format", "--output-dir", "/tmp"])

        assert os.path.isfile("/tmp/auto_functions.cpp")
        assert os.path.isfile("/tmp/auto_functions.h")
コード例 #2
0
    def test_transpiler_creates_files_with_format(self):
        self.clean_auto_funcs()

        transpiler.main(["--format", "--output-dir", "/tmp"])

        assert os.path.isfile("/tmp/auto_functions.cpp")
        assert os.path.isfile("/tmp/auto_functions.h")
コード例 #3
0
    def test_transpiler_uses_input_files(self):
        self.clean_auto_funcs()

        transpiler.main(["--format", "--output-cpp", "/tmp/auto_functions.cpp", "--output-header", "/tmp/auto_functions.h", "--input-files", "tests/files/transpiler/auto_functions/wait.func"])

        assert os.path.isfile("/tmp/auto_functions.cpp")
        assert os.path.isfile("/tmp/auto_functions.h")
        assert "Wait" in open("/tmp/auto_functions.h").read()
        assert "Wait" in open("/tmp/auto_functions.cpp").read()
コード例 #4
0
    def test_transpiler_uses_input_files(self):
        self.clean_auto_funcs()

        transpiler.main(["--format", "--output-dir", "/tmp", "--input-dir", "tests/files/transpiler/auto_functions"])

        assert os.path.isfile("/tmp/auto_functions.cpp")
        assert os.path.isfile("/tmp/auto_functions.h")
        assert "Wait" in open("/tmp/auto_functions.h").read()
        assert "Wait" in open("/tmp/auto_functions.cpp").read()
コード例 #5
0
    def test_transpiler_code_compiles(self):
        self.clean_auto_funcs()

        transpiler.main([
            "--format", "--input-dir",
            "tests/files/transpiler/auto_functions_compile"
        ])

        subprocess.check_call(
            ["g++", "-o", "/dev/null", "--std=c++14", "auto_functions.cpp"])
コード例 #6
0
    def test_transpiler_deterministic_outupt(self):
        self.clean_auto_funcs()

        os.mkdir("/tmp/auto_files")

        for n in range(1,10):
            os.mkdir("/tmp/auto_files/{}".format(n))
            transpiler.main(["--format", "--input-files", "tests/files/transpiler/auto_functions_compile/mock.func", "--output-cpp", "/tmp/auto_files/{}.cpp".format(n), "--output-header", "/tmp/auto_files/{}.h".format(n)])

        for n in range(1,9):
            assert subprocess.check_output(["diff", "/tmp/auto_files/{}".format(n), "/tmp/auto_files/{}".format(n+1)]).decode("utf-8") == ""
コード例 #7
0
    def test_transpiler_handles_whitespace(self):
        self.clean_auto_funcs()

        transpiler.main(["--input-files", "tests/files/transpiler/auto_functions/with_whitespace.func", "--output-cpp", "/tmp/auto_functions.cpp", "--output-header", "/tmp/auto_functions.h"])

        assert os.path.isfile("/tmp/auto_functions.cpp")
        assert os.path.isfile("/tmp/auto_functions.h")
        assert "Whitespace" in open("/tmp/auto_functions.h").read()
        assert "Whitespace" in open("/tmp/auto_functions.cpp").read()
        for x in range(1,6):
            assert "//PASS" + str(x) in open("/tmp/auto_functions.cpp").read()
コード例 #8
0
    def test_transpiler_deterministic_outupt(self):
        self.clean_auto_funcs()

        os.mkdir("/tmp/auto_files")

        for n in range(1,10):
            os.mkdir("/tmp/auto_files/{}".format(n))
            transpiler.main(["--format", "--input-dir", "tests/files/transpiler/auto_functions_compile", "--output-dir", "/tmp/auto_files/{}".format(n)])

        for n in range(1,9):
            assert subprocess.check_output(["diff", "/tmp/auto_files/{}".format(n), "/tmp/auto_files/{}".format(n+1)]).decode("utf-8") == ""
コード例 #9
0
    def test_transpiler_works_from_other_dir(self):
        self.clean_auto_funcs()

        old_dir = os.getcwd()
        os.chdir("/tmp")

        transpiler.main(["--format", "--input-files", old_dir + "/tests/files/transpiler/auto_functions/wait.func"])

        assert os.path.isfile("/tmp/auto_functions.cpp")
        assert os.path.isfile("/tmp/auto_functions.h")
        assert "Wait" in open("/tmp/auto_functions.h").read()
        assert "Wait" in open("/tmp/auto_functions.cpp").read()

        os.chdir(old_dir)
コード例 #10
0
    def test_transpiler_works_from_other_dir(self):
        self.clean_auto_funcs()

        old_dir = os.getcwd()
        os.chdir("/tmp")

        transpiler.main(["--format", "--input-dir", old_dir + "/tests/files/transpiler/auto_functions"])

        assert os.path.isfile("/tmp/auto_functions.cpp")
        assert os.path.isfile("/tmp/auto_functions.h")
        assert "Wait" in open("/tmp/auto_functions.h").read()
        assert "Wait" in open("/tmp/auto_functions.cpp").read()

        os.chdir(old_dir)
コード例 #11
0
    def test_transpiler_code_compiles(self):
        self.clean_auto_funcs()

        transpiler.main(["--format", "--input-dir", "tests/files/transpiler/auto_functions_compile"])

        subprocess.check_call(["g++", "-o", "/dev/null", "--std=c++14", "auto_functions.cpp"])