File: swift_test.py

package info (click to toggle)
pre-commit 4.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,452 kB
  • sloc: python: 14,482; sh: 87; makefile: 4
file content (31 lines) | stat: -rw-r--r-- 846 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from __future__ import annotations

import sys

import pytest

from pre_commit.languages import swift
from testing.language_helpers import run_language


@pytest.mark.skipif(
    sys.platform == 'win32',
    reason='swift is not supported on windows',
)
def test_swift_language(tmp_path):  # pragma: win32 no cover
    package_swift = '''\
// swift-tools-version:5.0
import PackageDescription

let package = Package(
    name: "swift_hooks_repo",
    targets: [.target(name: "swift_hooks_repo")]
)
'''
    tmp_path.joinpath('Package.swift').write_text(package_swift)
    src_dir = tmp_path.joinpath('Sources/swift_hooks_repo')
    src_dir.mkdir(parents=True)
    src_dir.joinpath('main.swift').write_text('print("Hello, world!")\n')

    expected = (0, b'Hello, world!\n')
    assert run_language(tmp_path, swift, 'swift_hooks_repo') == expected