|
| 1 | +# This file is part of arduino-cli. |
| 2 | +# |
| 3 | +# Copyright 2019 ARDUINO SA (http://www.arduino.cc/) |
| 4 | +# |
| 5 | +# This software is released under the GNU General Public License version 3, |
| 6 | +# which covers the main part of arduino-cli. |
| 7 | +# The terms of this license can be found at: |
| 8 | +# https://www.gnu.org/licenses/gpl-3.0.en.html |
| 9 | +# |
| 10 | +# You can be released from the requirements of the above licenses by purchasing |
| 11 | +# a commercial license. Buying such a license is mandatory if you want to modify or |
| 12 | +# otherwise use the software for commercial activities involving the Arduino |
| 13 | +# software without disclosing the source code of your own applications. To purchase |
| 14 | +# a commercial license, send an email to license@arduino.cc. |
| 15 | +import os |
| 16 | +import platform |
| 17 | + |
| 18 | +import pytest |
| 19 | + |
| 20 | +from test.common import running_on_ci |
| 21 | + |
| 22 | + |
| 23 | +@pytest.mark.skipif(running_on_ci() and platform.system() == "Windows", |
| 24 | + reason="Test disabled on Github Actions Win VM until tmpdir inconsistent behavior bug is fixed") |
| 25 | +def test_sketch_new(run_command, working_dir): |
| 26 | + # Create a test sketch in current directory |
| 27 | + current_path = working_dir |
| 28 | + sketch_name = "SketchNewIntegrationTest" |
| 29 | + current_sketch_path = os.path.join(current_path, sketch_name) |
| 30 | + result = run_command("sketch new {}".format(sketch_name)) |
| 31 | + assert result.ok |
| 32 | + assert "Sketch created in: {}".format(current_sketch_path) in result.stdout |
| 33 | + assert os.path.isfile(os.path.join(current_sketch_path, sketch_name + ".ino")) |
| 34 | + |
| 35 | + # Create a test sketch in current directory but using an absolute path |
| 36 | + sketch_name = "SketchNewIntegrationTestAbsolute" |
| 37 | + current_sketch_path = os.path.join(current_path, sketch_name) |
| 38 | + result = run_command("sketch new {}".format(current_sketch_path)) |
| 39 | + assert result.ok |
| 40 | + assert "Sketch created in: {}".format(current_sketch_path) in result.stdout |
| 41 | + assert os.path.isfile(os.path.join(current_sketch_path, sketch_name + ".ino")) |
| 42 | + |
| 43 | + # Create a test sketch in current directory subpath but using an absolute path |
| 44 | + sketch_name = "SketchNewIntegrationTestSubpath" |
| 45 | + sketch_subpath = os.path.join("subpath", sketch_name) |
| 46 | + current_sketch_path = os.path.join(current_path, sketch_subpath) |
| 47 | + result = run_command("sketch new {}".format(sketch_subpath)) |
| 48 | + assert result.ok |
| 49 | + assert "Sketch created in: {}".format(current_sketch_path) in result.stdout |
| 50 | + assert os.path.isfile(os.path.join(current_sketch_path, sketch_name + ".ino")) |
| 51 | + |
| 52 | + # Create a test sketch in current directory using .ino extension |
| 53 | + sketch_name = "SketchNewIntegrationTestDotIno" |
| 54 | + current_sketch_path = os.path.join(current_path, sketch_name) |
| 55 | + result = run_command("sketch new {}".format(sketch_name + ".ino")) |
| 56 | + assert result.ok |
| 57 | + assert "Sketch created in: {}".format(current_sketch_path) in result.stdout |
| 58 | + assert os.path.isfile(os.path.join(current_sketch_path, sketch_name + ".ino")) |
0 commit comments