Skip to content

Commit

Permalink
create output path by default (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
anhnguyen1618 authored Apr 10, 2019
1 parent 135c83d commit 7f21a61
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ before_install:
- eval `opam config env`
- opam install -y ocamlbuild ocamlfind menhir llvm
- sudo chmod +x compile.sh
- mkdir llvm_byte_code/test

matrix:
include:
Expand Down
1 change: 1 addition & 0 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ run_all_test_cases() {
}

build_ocaml_compiler() {
mkdir -p llvm_byte_code/test/ && \
ocamlbuild -tag 'debug, explain' -use-menhir -use-ocamlfind -package llvm src/parse.native && \
mv _build/src/parse.native bin/compiler
if [ $? -ne 0 ]; then
Expand Down
17 changes: 11 additions & 6 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
TEST_DIR = "./test"
TEST_FILE_PATTERN = '*.tig'
SUCCESS_CODE = 0
OUTPUT_DIR = "llvm_byte_code/test/"

GREEN_COLOR = '\033[92m'
RED_COLOR = '\033[91m'
Expand All @@ -17,8 +18,12 @@ def print_success(file_name):
def print_error(file_name):
print(RED_COLOR + X_ICON + ' ' + file_name + END_COLOR)

def create_output_dir():
if not os.path.exists(OUTPUT_DIR):
os.makedirs(OUTPUT_DIR)

def build_compiler():
create_output_dir()
cmd = ("ocamlbuild -tag 'debug, explain' -use-menhir -use-ocamlfind -package llvm src/parse.native &&"
"mv _build/src/parse.native bin/compiler")
exit_code = os.system(cmd)
Expand All @@ -27,10 +32,11 @@ def build_compiler():
exit(exit_code)

def run_single_test_without_compile(file_name):
output_file_path = OUTPUT_DIR + file_name
cmd = ("./bin/compiler test/" + file_name + " &&"
"opt -f -S llvm_byte_code/test/"+ file_name +".ll -o llvm_byte_code/test/"+ file_name +"-opt.ll -Oz &&"
"llc llvm_byte_code/test/" + file_name + "-opt.ll &&"
"clang llvm_byte_code/test/" + file_name + "-opt.s src/bindings.c -o run_prog &&"
"opt -f -S " + output_file_path +".ll -o " + output_file_path +"-opt.ll -Oz &&"
"llc " + output_file_path + "-opt.ll &&"
"clang " + output_file_path + "-opt.s src/bindings.c -o run_prog &&"
"./run_prog")

code = os.system(cmd)
Expand Down Expand Up @@ -72,14 +78,13 @@ def run_all_test():
print_error(test_fail)
else:
print "================== ALL TESTS PASSED ("+ str(number_of_tests) +" cases) =================="



parser = argparse.ArgumentParser()
parser.add_argument("-s", "--single", type=str,
help="run single test")
args = parser.parse_args()

def main():
def main():
if args.single != None:
run_single_test_compile(args.single)
else:
Expand Down

0 comments on commit 7f21a61

Please sign in to comment.