From 27bcfe5f6ec6d424bfe1ef5bf818fd85c438fc54 Mon Sep 17 00:00:00 2001 From: 06kellyjac Date: Tue, 17 Jan 2023 11:34:02 +0000 Subject: [PATCH 1/2] deno: 1.29.3 -> 1.29.4 --- pkgs/development/web/deno/default.nix | 6 +++--- pkgs/development/web/deno/librusty_v8.nix | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/development/web/deno/default.nix b/pkgs/development/web/deno/default.nix index 659af1aec62e..540309f13fda 100644 --- a/pkgs/development/web/deno/default.nix +++ b/pkgs/development/web/deno/default.nix @@ -17,15 +17,15 @@ rustPlatform.buildRustPackage rec { pname = "deno"; - version = "1.29.3"; + version = "1.29.4"; src = fetchFromGitHub { owner = "denoland"; repo = pname; rev = "v${version}"; - sha256 = "sha256-CH0uri8mnpcojuE8Pil/gsvEfDu/txjCevvGjqhiK1k="; + sha256 = "sha256-oCBtqOm/d5dpIv70/Ht0M6izxdvm59LCiDHgcMcwLek="; }; - cargoSha256 = "sha256-I7MIcZeMQzgplza8YAqmuWaX4Gw3ZoDXHyzq/5opO4M="; + cargoSha256 = "sha256-Y/1yfCeWleNrk5MgkIoAtkH8e6YSZWa+GF5RgLaZXQA="; postPatch = '' # upstream uses lld on aarch64-darwin for faster builds diff --git a/pkgs/development/web/deno/librusty_v8.nix b/pkgs/development/web/deno/librusty_v8.nix index ec13f634ea5c..52b3e12f0286 100644 --- a/pkgs/development/web/deno/librusty_v8.nix +++ b/pkgs/development/web/deno/librusty_v8.nix @@ -11,11 +11,11 @@ let }; in fetch_librusty_v8 { - version = "0.60.0"; + version = "0.60.1"; shas = { - x86_64-linux = "sha256-2cq9fpKhx3ctZ5Lo2RofXD5bXfVUUN6bRtG453MQMW4="; - aarch64-linux = "sha256-hjVUzCYdGkc3kMC/cSXDFOaqJmMBi83dqqASS5R2158="; - x86_64-darwin = "sha256-EyYWfDU0eVFVzSVAHBFUbsppzpHtwe+Fd+z2ZmIub2c="; - aarch64-darwin = "sha256-2VyEFqWsPZlkEDvNxkmrMCIKfsO7LAO+VvsjSMcyFUo="; + x86_64-linux = "sha256-P8H+XJqrt9jdKM885L1epMldp+stwmEw+0Gtd2x3r4g="; + aarch64-linux = "sha256-frHpBP2pL3o4efFLHP2r3zsWJrNT93yYu2Qkxv+7m8Y="; + x86_64-darwin = "sha256-taewoYBkyikqWueLSD9dW1EDjzkV68Xplid1UaLZgRM="; + aarch64-darwin = "sha256-s2YEVbuYpiT/qrmE37aXk13MetrnJo6l+s1Q2y6b5kU="; }; } From 159f042d3829df0c026bef6c28f1962b0a42b37d Mon Sep 17 00:00:00 2001 From: 06kellyjac Date: Tue, 17 Jan 2023 13:09:19 +0000 Subject: [PATCH 2/2] deno: add some simple tests --- pkgs/development/web/deno/default.nix | 1 + pkgs/development/web/deno/tests/basic.ts | 1 + pkgs/development/web/deno/tests/default.nix | 68 +++++++++++++++++++ .../web/deno/tests/import-json/data.json | 1 + .../web/deno/tests/import-json/index.ts | 2 + .../web/deno/tests/import-ts/index.ts | 3 + .../web/deno/tests/import-ts/lib.ts | 3 + .../web/deno/tests/read-file/data.txt | 1 + .../web/deno/tests/read-file/index.ts | 5 ++ 9 files changed, 85 insertions(+) create mode 100644 pkgs/development/web/deno/tests/basic.ts create mode 100644 pkgs/development/web/deno/tests/default.nix create mode 100644 pkgs/development/web/deno/tests/import-json/data.json create mode 100644 pkgs/development/web/deno/tests/import-json/index.ts create mode 100644 pkgs/development/web/deno/tests/import-ts/index.ts create mode 100644 pkgs/development/web/deno/tests/import-ts/lib.ts create mode 100644 pkgs/development/web/deno/tests/read-file/data.txt create mode 100644 pkgs/development/web/deno/tests/read-file/index.ts diff --git a/pkgs/development/web/deno/default.nix b/pkgs/development/web/deno/default.nix index 540309f13fda..e3e7481dff1f 100644 --- a/pkgs/development/web/deno/default.nix +++ b/pkgs/development/web/deno/default.nix @@ -85,6 +85,7 @@ rustPlatform.buildRustPackage rec { ''; passthru.updateScript = ./update/update.ts; + passthru.tests = callPackage ./tests { }; meta = with lib; { homepage = "https://deno.land/"; diff --git a/pkgs/development/web/deno/tests/basic.ts b/pkgs/development/web/deno/tests/basic.ts new file mode 100644 index 000000000000..5959aa217b3c --- /dev/null +++ b/pkgs/development/web/deno/tests/basic.ts @@ -0,0 +1 @@ +console.log(1 + 1) diff --git a/pkgs/development/web/deno/tests/default.nix b/pkgs/development/web/deno/tests/default.nix new file mode 100644 index 000000000000..b6787c913b12 --- /dev/null +++ b/pkgs/development/web/deno/tests/default.nix @@ -0,0 +1,68 @@ +{ deno, runCommand, lib, testers }: +let + testDenoRun = + name: + { args ? "" + , dir ? ./. + "/${name}" + , file ? "index.ts" + , expected ? "" + , expectFailure ? false + }: + let + command = "deno run ${args} ${dir}/${file}"; + in + runCommand "deno-test-${name}" { nativeBuildInputs = [ deno ]; meta.timeout = 60; } '' + HOME=$(mktemp -d) + if output=$(${command} 2>&1); then + if [[ $output =~ '${expected}' ]]; then + echo "Test '${name}' passed" + touch $out + else + echo -n ${lib.escapeShellArg command} >&2 + echo " output did not match what was expected." >&2 + echo "The expected was:" >&2 + echo '${expected}' >&2 + echo "The output was:" >&2 + echo "$output" >&2 + exit 1 + fi + else + if [[ "${toString expectFailure}" == "1" ]]; then + echo "Test '${name}' failed as expected" + touch $out + exit 0 + fi + echo -n ${lib.escapeShellArg command} >&2 + echo " returned a non-zero exit code." >&2 + echo "$output" >&2 + exit 1 + fi + ''; +in +(lib.mapAttrs testDenoRun { + basic = { + dir = ./.; + file = "basic.ts"; + expected = "2"; + }; + import-json = { + expected = "hello from JSON"; + }; + import-ts = { + expected = "hello from ts"; + }; + read-file = { + args = "--allow-read"; + expected = "hello from a file"; + }; + fail-read-file = { + expectFailure = true; + dir = ./read-file; + }; +}) // +{ + version = testers.testVersion { + package = deno; + command = "deno --version"; + }; +} diff --git a/pkgs/development/web/deno/tests/import-json/data.json b/pkgs/development/web/deno/tests/import-json/data.json new file mode 100644 index 000000000000..7f0de9ebe0b9 --- /dev/null +++ b/pkgs/development/web/deno/tests/import-json/data.json @@ -0,0 +1 @@ +{ "msg": "hello from JSON" } diff --git a/pkgs/development/web/deno/tests/import-json/index.ts b/pkgs/development/web/deno/tests/import-json/index.ts new file mode 100644 index 000000000000..525f25f74da2 --- /dev/null +++ b/pkgs/development/web/deno/tests/import-json/index.ts @@ -0,0 +1,2 @@ +import file from "./data.json" assert { type: "json" }; +console.log(file.msg); diff --git a/pkgs/development/web/deno/tests/import-ts/index.ts b/pkgs/development/web/deno/tests/import-ts/index.ts new file mode 100644 index 000000000000..34fec283a169 --- /dev/null +++ b/pkgs/development/web/deno/tests/import-ts/index.ts @@ -0,0 +1,3 @@ +import { sayHello } from "./lib.ts" + +sayHello("ts") diff --git a/pkgs/development/web/deno/tests/import-ts/lib.ts b/pkgs/development/web/deno/tests/import-ts/lib.ts new file mode 100644 index 000000000000..3b5e05aaaaf3 --- /dev/null +++ b/pkgs/development/web/deno/tests/import-ts/lib.ts @@ -0,0 +1,3 @@ +export function sayHello(thing: string) { + console.log(`hello from ${thing}`); +} diff --git a/pkgs/development/web/deno/tests/read-file/data.txt b/pkgs/development/web/deno/tests/read-file/data.txt new file mode 100644 index 000000000000..7eee1b0c107c --- /dev/null +++ b/pkgs/development/web/deno/tests/read-file/data.txt @@ -0,0 +1 @@ +hello from a file diff --git a/pkgs/development/web/deno/tests/read-file/index.ts b/pkgs/development/web/deno/tests/read-file/index.ts new file mode 100644 index 000000000000..be792a3d6628 --- /dev/null +++ b/pkgs/development/web/deno/tests/read-file/index.ts @@ -0,0 +1,5 @@ +// trim 'file://' prefix +const thisDir = Deno.mainModule.substring(7, Deno.mainModule.length); +const getParent = (path: string) => path.substring(0, path.lastIndexOf("/")) +const text = await Deno.readTextFile(getParent(thisDir) + "/data.txt"); +console.log(text);