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

This commit is contained in:
Felix Bargfeldt
2025-11-06 12:42:36 +00:00
committed by GitHub
3 changed files with 1400 additions and 23 deletions
+64 -23
View File
@@ -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,32 +47,58 @@ 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
)
''
installShellCompletion --cmd taplo \
--bash <($out/bin/taplo completions bash) \
--fish <($out/bin/taplo completions fish) \
--zsh <($out/bin/taplo completions zsh)
'';
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
installShellCompletion --cmd taplo \
--bash <($out/bin/taplo completions bash) \
--fish <($out/bin/taplo completions fish) \
--zsh <($out/bin/taplo completions zsh)
'';
nativeInstallCheckInputs = [ versionCheckHook ];
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";
};
})
File diff suppressed because it is too large Load Diff
+45
View File
@@ -0,0 +1,45 @@
{
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";
};
})