## START: Set by rpmautospec
## (rpmautospec version 0.3.0)
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 1;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

# Generated by rust2rpm 22
%bcond_without check

%global crate tree-sitter-cli

Name:           rust-tree-sitter-cli
Version:        0.20.7
Release:        %autorelease
Summary:        CLI tool for developing, testing, and using Tree-sitter parsers

# Upstream license specification: MIT
License:        MIT
URL:            https://crates.io/crates/tree-sitter-cli
Source:         %{crates_source}
# Upstream license file - tree-sitter/tree-sitter#1520
Source1:        https://github.com/tree-sitter/tree-sitter/raw/v%{version}/LICENSE#/LICENSE.upstream
# The data required for running tests (multiple sources, MIT with license files)
# Generated with get-test-fixtures.sh
Source2:        tree-sitter-fixtures-%{version}.tar.xz
Source3:        get-test-fixtures.sh

ExclusiveArch:  %{rust_arches}

BuildRequires:  rust-packaging >= 21
%if %{with check}
%ifarch %{nodejs_arches}
# Required by tests::corpus_test::test_feature_corpus_files
BuildRequires:  /usr/bin/node
%endif
%endif

%global _description %{expand:
CLI tool for developing, testing, and using Tree-sitter parsers.}

%description %{_description}

%package     -n %{crate}
Summary:        %{summary}
# ASL 2.0
# ASL 2.0 or Boost
# ASL 2.0 or MIT
# BSD
# ISC
# MIT
# MIT and Unicode
# MIT or ASL 2.0 or zlib
# Unlicense or MIT
# See LICENSE.dependencies for a full list of buildroot crates and licenses
License:        MIT and ASL 2.0 and BSD and ISC and Unicode

%description -n %{crate} %{_description}

%files       -n %{crate}
%license LICENSE
%doc README.md
%{_bindir}/tree-sitter

%package        devel
Summary:        %{summary}
BuildArch:      noarch

%description    devel %{_description}

This package contains library source intended for building other packages which
use the "%{crate}" crate.

%files          devel
%license LICENSE
%doc %{crate_instdir}/README.md
%{crate_instdir}/

%package     -n %{name}+default-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+default-devel %{_description}

This package contains library source intended for building other packages which
use the "default" feature of the "%{crate}" crate.

%files       -n %{name}+default-devel
%ghost %{crate_instdir}/Cargo.toml

%prep
%autosetup -n %{crate}-%{version_no_tilde} -p2 %{?with_check:-b2}
%cargo_prep
cp %{SOURCE1} LICENSE
# Provide symlink for the C library headers. Test suite requires that
# to compile parsers without libtree-sitter-devel.
# See cli/src/tests/helpers/{dirs,fixtures}.rs
ln -sf %{cargo_registry}/tree-sitter-0.* ../lib
# Delete unwanted files
rm -rf npm

%generate_buildrequires
%cargo_generate_buildrequires

%build
%cargo_build

%install
%cargo_install

%if %{with check}
%check
TEST_ARGS=(
    --
    # forbid parallel execution; tests may attempt to compile and load the same parser library
    --test-threads=1
%ifarch s390x
    # https://github.com/tree-sitter/tree-sitter/issues/1693
    --skip tests::query_test::test_query_is_pattern_guaranteed_at_step
%endif
%ifnarch %{nodejs_arches}
    # requres /usr/bin/node
    --skip tests::corpus_test::test_feature_corpus_files
%endif
    )
%cargo_test -- "${TEST_ARGS[@]}"
%endif

%changelog
* Mon Sep 05 2022 Aleksei Bavshin <alebastr@fedoraproject.org> 0.20.7-1
- Update to 0.20.7 (#2123893)

* Sat Jul 23 2022 Fedora Release Engineering <releng@fedoraproject.org> 0.20.6-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Wed Apr 06 2022 Aleksei Bavshin <alebastr@fedoraproject.org> 0.20.6-1
- Initial import (#2028900)