Skip to content

Commit

Permalink
Merge pull request KusionStack#96 from KusionStack/bugfix-test-scripts
Browse files Browse the repository at this point in the history
chore: update test scripts to be compatible with new kusion compile output
  • Loading branch information
howieyuen authored Apr 7, 2023
2 parents 44e62b8 + 67240d4 commit ec711ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest
name: parse deps and get affected stacks/projecrs by diff files
container:
image: kusionstack/kusionctl:latest
image: kusionstack/kusion:latest
env:
changePaths: ${{needs.diff.outputs.CHANGED_FILE}}
steps:
Expand Down
14 changes: 8 additions & 6 deletions hack/test_konfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,22 @@ def test_konfigs(test_dir):
kusion_cmd.append("-Y")
kusion_cmd.append("kcl.yaml")
kusion_cmd.append("-o")
kusion_cmd.append("stdout")
kusion_cmd.append("test.yaml")
else:
kusion_cmd.append(f"{MAIN_FILE}")
process = subprocess.run(
kusion_cmd, capture_output=True, cwd=test_dir, env=dict(os.environ)
)
stdout, stderr = process.stdout, process.stderr
print(f"STDOUT:\n{stdout.decode()}")
stderr = process.stderr
assert (
process.returncode == 0 and len(stderr) == 0
), f"Error executing file {kcl_file_name}.\nexit code = {process.returncode}\nstderr = {stderr}"
test_yaml = test_dir / "test.yaml"
if process.returncode == 0 and len(stderr) == 0:
try:
with open(golden_file, "r") as golden:
compare_results(stdout.decode(), golden)
golden = open(golden_file, "r")
test = open(test_yaml)
compare_results(test, golden)
os.remove(test_yaml)
except FileNotFoundError:
raise Exception(f"Error reading expected result from file {golden_file}")
raise Exception(f"Error reading expected result from file {test_yaml}")

0 comments on commit ec711ac

Please sign in to comment.