microsoft/qdk

Public

mirrored fromhttps://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
iadavis/pipeline-issue-debugging

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

source/pip/tests-integration/test_adaptive_rif_qir.py

49lines · modecode

1# Copyright (c) Microsoft Corporation.
2# Licensed under the MIT License.
3
4
5import pytest
6
7from qsharp import TargetProfile
8from utils import (
9 assert_strings_equal_ignore_line_endings,
10 compile_qsharp,
11 get_input_files,
12 get_output_ll_file,
13 get_output_out_file,
14 QIR_RUNNER_AVAILABLE,
15 read_file,
16 save_qir_to_temp_file_and_execute,
17 SKIP_REASON,
18)
19
20TARGET_PROFILE = TargetProfile.Adaptive_RIF
21
22
23# This function is used to generate the expected output files for the tests
24# Rename the function to start with test_ to generate the expected output files
25def generate_test_outputs():
26 from utils import generate_test_outputs
27
28 generate_test_outputs(TARGET_PROFILE)
29
30
31@pytest.mark.parametrize("file_path", get_input_files(TARGET_PROFILE))
32@pytest.mark.skipif(not QIR_RUNNER_AVAILABLE, reason=SKIP_REASON)
33def test_adaptive_rif_qir(file_path: str) -> None:
34 source = read_file(file_path, TARGET_PROFILE)
35 ll_file_path = get_output_ll_file(file_path, TARGET_PROFILE)
36 expected_qir = read_file(ll_file_path, TARGET_PROFILE)
37 actual_qir = compile_qsharp(source, TARGET_PROFILE)
38 assert actual_qir == expected_qir
39
40
41@pytest.mark.parametrize("file_path", get_input_files(TARGET_PROFILE))
42@pytest.mark.skipif(not QIR_RUNNER_AVAILABLE, reason=SKIP_REASON)
43def test_adaptive_rif_output(file_path: str) -> None:
44 source = read_file(file_path, TARGET_PROFILE)
45 qir = compile_qsharp(source, TARGET_PROFILE)
46 output_file_path = get_output_out_file(file_path, TARGET_PROFILE)
47 expected_output = read_file(output_file_path, TARGET_PROFILE)
48 actual_output = save_qir_to_temp_file_and_execute(qir)
49 assert_strings_equal_ignore_line_endings(actual_output, expected_output)
50