Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# -------------------------------------------------------------------------------------------------- 

2# Copyright (c) Lukas Vik. All rights reserved. 

3# 

4# This file is part of the tsfpga project. 

5# https://tsfpga.com 

6# https://gitlab.com/tsfpga/tsfpga 

7# -------------------------------------------------------------------------------------------------- 

8 

9from unittest.mock import patch 

10from pathlib import Path 

11 

12from tsfpga.vivado.common import run_vivado_tcl 

13 

14THIS_DIR = Path(__file__).parent 

15 

16 

17def test_run_vivado_tcl(): 

18 vivado_path = THIS_DIR / "vivado.exe" 

19 tcl_file = THIS_DIR / "script.tcl" 

20 expected_cmd = [ 

21 str(vivado_path.resolve()), 

22 "-mode", 

23 "batch", 

24 "-notrace", 

25 "-source", 

26 str(tcl_file.resolve()), 

27 ] 

28 

29 with patch("tsfpga.vivado.common.Process") as mocked_process: 

30 mocked_process.NonZeroExitCode = ValueError 

31 assert run_vivado_tcl(vivado_path, tcl_file) 

32 mocked_process.assert_called_once_with(args=expected_cmd, cwd=THIS_DIR) 

33 

34 with patch("tsfpga.vivado.common.Process") as mocked_process: 

35 mocked_process.NonZeroExitCode = ValueError 

36 assert run_vivado_tcl(vivado_path, tcl_file, no_log_file=True) 

37 mocked_process.assert_called_once_with( 

38 args=expected_cmd + ["-nojournal", "-nolog"], cwd=THIS_DIR 

39 ) 

40 

41 with patch("tsfpga.vivado.common.Process") as mocked_process: 

42 mocked_process.NonZeroExitCode = ValueError 

43 mocked_process.return_value.consume_output.side_effect = ValueError("Non-zero exit code!") 

44 assert not run_vivado_tcl(vivado_path, tcl_file, no_log_file=True)