Unverified Commit 72e46fd5 authored by Felix Bargfeldt's avatar Felix Bargfeldt Committed by GitHub
Browse files

toml-test: init at 1.6.0; taplo: add test (#458692)

parents 08d5fffb 74cfe461
Loading
Loading
Loading
Loading
+64 −23
Original line number Diff line number Diff line
@@ -2,26 +2,41 @@
  stdenv,
  lib,
  rustPlatform,
  fetchCrate,
  fetchFromGitHub,
  pkg-config,
  openssl,
  withLsp ? true,
  installShellFiles,
  versionCheckHook,

  # passthru dependencies
  nix-update-script,
  runCommand,
  toml-test,

  # Optional feature
  withLsp ? true,
}:

rustPlatform.buildRustPackage (finalAttrs: {
  pname = "taplo";
  version = "0.10.0";

  src = fetchCrate {
    inherit (finalAttrs) version;
    pname = "taplo-cli";
    hash = "sha256-iKc4Nu7AZE1LSuqXffi3XERbOqZMOkI3PV+6HaJzh4c=";
  src = fetchFromGitHub {
    owner = "tamasfe";
    repo = "taplo";
    tag = "release-taplo-cli-${finalAttrs.version}";
    hash = "sha256-FW8OQ5TRUuQK8M2NDmp4c6p22jsHodxKqzOMrcdiqXU=";
  };

  cargoHash = "sha256-tvijtB5fwOzQnnK/ClIvTbjCcMeqZpXcRdWWKZPIulM=";
  cargoPatches = [
    # Update reqwest to fix darwin sandboxing issues
    # See also: https://github.com/tamasfe/taplo/pull/669
    ./update-reqwest.patch
  ];

  cargoHash = "sha256-FMpGo+kRcNgDj4qwYvdQKGwGazUKKMIVq0HCYMrTql0=";

  buildAndTestSubdir = "crates/taplo-cli";

  nativeBuildInputs = [
    installShellFiles
@@ -32,15 +47,7 @@ rustPlatform.buildRustPackage (finalAttrs: {

  buildFeatures = lib.optional withLsp "lsp";

  postInstall =
    lib.optionalString
      (
        stdenv.buildPlatform.canExecute stdenv.hostPlatform
        &&
          # Creation of the completions fails on Darwin platforms.
          !stdenv.hostPlatform.isDarwin
      )
      ''
  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
    installShellCompletion --cmd taplo \
      --bash <($out/bin/taplo completions bash) \
      --fish <($out/bin/taplo completions fish) \
@@ -51,13 +58,47 @@ rustPlatform.buildRustPackage (finalAttrs: {
  versionCheckProgramArg = "--version";
  doInstallCheck = true;

  passthru.updateScript = nix-update-script { };
  passthru = {
    updateScript = nix-update-script { };

    tests = {
      toml-test =
        let
          # Unfortunately, taplo does not yet pass all toml-test v1.6.0 tests.
          # Some of the failures are reported issues, others may not be.
          # https://github.com/tamasfe/taplo/issues/486
          skips = [
            "valid/comment/nonascii"
            "valid/datetime/edge"
            "valid/key/quoted-unicode"
            "valid/string/quoted-unicode"
            "invalid/control/multi-cr"
            "invalid/control/rawmulti-cr"
            "invalid/table/super-twice"
          ];
        in
        runCommand "taplo-toml-test"
          {
            nativeBuildInputs = [
              finalAttrs.finalPackage
              toml-test
            ];
          }
          ''
            toml-test taplo ${lib.concatMapStringsSep " " (a: "-skip ${a}") skips} -- toml-test
            touch "$out"
          '';
    };
  };

  meta = {
    description = "TOML toolkit written in Rust";
    homepage = "https://taplo.tamasfe.dev";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ defelo ];
    maintainers = with lib.maintainers; [
      defelo
      yzx9
    ];
    mainProgram = "taplo";
  };
})
+1291 −0

File added.

Preview size limit exceeded, changes collapsed.

+45 −0
Original line number Diff line number Diff line
{
  lib,
  buildGoModule,
  fetchFromGitHub,
  versionCheckHook,
  nix-update-script,
}:

buildGoModule (finalAttrs: {
  pname = "toml-test";
  version = "1.6.0";

  src = fetchFromGitHub {
    owner = "toml-lang";
    repo = "toml-test";
    tag = "v${finalAttrs.version}";
    hash = "sha256-jOFkSEDNvvx8svgyYYpAbveQsclMsQRKJ2ocA6ty1Kw=";
  };

  vendorHash = "sha256-yt5rwpYzO38wEUhcyG4G367Byek20Uz3u+buAazq/5A=";

  ldflags = [
    "-s"
    "-w"
    "-X zgo.at/zli.version=${finalAttrs.version}"
  ];

  nativeInstallCheckInputs = [ versionCheckHook ];
  versionCheckProgramArg = "--version";
  doInstallCheck = true;

  passthru.updateScript = nix-update-script { };

  meta = {
    description = "Language agnostic test suite for TOML parsers";
    homepage = "https://github.com/toml-lang/toml-test";
    changelog = "https://github.com/toml-lang/toml-test/releases/tag/v${finalAttrs.version}";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [
      yzx9
      defelo
    ];
    mainProgram = "toml-test";
  };
})