Skip to content

Commit

Permalink
🤪 Make dash as function
Browse files Browse the repository at this point in the history
Issue: #10
  • Loading branch information
gopinath-langote committed May 1, 2019
1 parent e3bfa9e commit 52be05a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
12 changes: 7 additions & 5 deletions 1build
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ def run(build_file_name, arguments):


def execute(command):
print("---------------------------------------------------")
print ("Name: " + command.name)
print ("Command: " + command.cmd)
print("---------------------------------------------------")
print(dash)
print("Name: " + command.name)
print("Command: " + command.cmd)
print(dash)
os.system(command.cmd)


Expand All @@ -91,7 +91,7 @@ def __parse_project_config__():
except:
raise ValueError(
"Error in parsing " + __buildFileName__() + " config file. Make sure file is in correct format.\nSample format is:\n\n" +
"---------------------------------------------------\n" + sample_yaml_file() + "\n---------------------------------------------------\n"
dash + "\n" + sample_yaml_file() + "\n" + dash + "\n"
)
else:
raise ValueError("No " + __buildFileName__() + " file found in current directory.")
Expand All @@ -118,4 +118,6 @@ def sample_yaml_file():
" - lint: ./gradlew spotlessApply"


dash = '-' * 50

run(BUILD_FILE_NAME, sys.argv)
22 changes: 12 additions & 10 deletions tests/test_1build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@

build = imp.load_source('1build', '1build')

dash = '-' * 50


def test_build_successful_command(capsys):
build.run("tests/build_file.yaml", ['file_name', 'build'])
captured = capsys.readouterr()
expected_message = "---------------------------------------------------\n" \
"Name: build\n" \
"Command: ls\n" \
"---------------------------------------------------\n"
expected_message = "" + dash + "\n" \
"Name: build\n" \
"Command: ls\n" \
+ dash + "\n"
assert expected_message in captured.out


Expand All @@ -22,12 +24,12 @@ def test_should_fail_with_invalid_file_message_if_file_is_not_in_correct_yaml_fo

invalid_file_error_message = "Error in parsing 'tests/invalid_yaml_file.yaml' config file. Make sure file is in correct format.\n" \
"Sample format is:\n\n" \
"---------------------------------------------------\n" \
"project: Sample Project\n" \
"commands:\n" \
" - build: ./gradlew clean build\n" \
" - lint: ./gradlew spotlessApply\n" \
"---------------------------------------------------"
+ dash + "\n" \
"project: Sample Project\n" \
"commands:\n" \
" - build: ./gradlew clean build\n" \
" - lint: ./gradlew spotlessApply\n" \
+ dash

assert invalid_file_error_message in captured.out

Expand Down

0 comments on commit 52be05a

Please sign in to comment.