From eac0a3ebee8fbe70683c413f809655ae9fdc0885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dandelion=20Man=C3=A9?= Date: Sat, 5 Jan 2019 12:20:07 -0800 Subject: [PATCH] Add helpful message when missing gnu-coreutils (#1034) As described in #1033: Currently, developers in environments without gnu coreutils (notably: macOS) get an extremely confusing error message when they run `yarn test`. This commit ensures that such users instead get a helpful message with a link to the fix. Follows @wchargin's proposed approach for fixing #1033, so that Mac developers get clear guidance on how to get their development environment working properly. Expected behavior is that `yarn test` passes when GNU coreutils are present, and fails with the following message when they are not: Fixes #1033 ``` FAIL check-gnu-coreutils Exit code: 1 Contents of stdout: /home/dandelion/git/sc/sourcecred Contents of stderr: Error: Your environment does not provide GNU coreutils You're likely developing on macOS. Please see the following link for a fix: https://github.com/sourcecred/sourcecred/issues/698#issuecomment-417202213 ``` Test plan: Verify that on a machine with gnu coreutils present, the command passes and does not print irrelevant output. Verify that on a machine without gnu coreutils available, the command fails, and prints exactly the error message expected, without any extra output related to the test's implementation. Paired-with: @anthrocypher --- config/test.js | 7 ++++++- scripts/check-gnu-coreutils.sh | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 scripts/check-gnu-coreutils.sh diff --git a/config/test.js b/config/test.js index 62c6591..79f5a7a 100644 --- a/config/test.js +++ b/config/test.js @@ -80,6 +80,11 @@ function makeTasks(mode /*: "BASIC" | "FULL" */) { cmd: ["npm", "run", "--silent", "unit", "--", "--ci", "--maxWorkers=4"], deps: [], }, + { + id: "check-gnu-coreutils", + cmd: ["./scripts/check-gnu-coreutils.sh"], + deps: [], + }, { id: "backend", cmd: [ @@ -101,7 +106,7 @@ function makeTasks(mode /*: "BASIC" | "FULL" */) { "--silent", {BASIC: "sharness", FULL: "sharness-full"}[mode], ]), - deps: ["backend"], + deps: ["backend", "check-gnu-coreutils"], }, ]; const extraTasks = [ diff --git a/scripts/check-gnu-coreutils.sh b/scripts/check-gnu-coreutils.sh new file mode 100755 index 0000000..f6ceb75 --- /dev/null +++ b/scripts/check-gnu-coreutils.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -eu + +if ! 2>/dev/null >/dev/null readlink -f . ; then + >&2 echo "Error: Your environment does not provide GNU coreutils" + >&2 echo "You're likely developing on macOS." + >&2 echo "Please see the following link for a fix:" + >&2 echo "https://github.com/sourcecred/sourcecred/issues/698#issuecomment-417202213" + exit 1 +fi