)]}'
{
  "commit": "165293af3ce4535efa72eb51587383144a2b3f01",
  "tree": "b6bc84d741343735b070493cb31fa1009964712f",
  "parents": [
    "bb75be6cb916297f271c846f2f9caa3daaaec718"
  ],
  "author": {
    "name": "SZEDER Gábor",
    "email": "szeder.dev@gmail.com",
    "time": "Mon Nov 19 14:13:26 2018 +0100"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Tue Nov 20 12:16:35 2018 +0900"
  },
  "message": "tests: send \"bug in the test script\" errors to the script\u0027s stderr\n\nSome of the functions in our test library check that they were invoked\nproperly with conditions like this:\n\n  test \"$#\" \u003d 2 ||\n  error \"bug in the test script: not 2 parameters to test-expect-success\"\n\nIf this particular condition is triggered, then \u0027error\u0027 will abort the\nwhole test script with a bold red error message [1] right away.\n\nHowever, under certain circumstances the test script will be aborted\ncompletely silently, namely if:\n\n  - a similar condition in a test helper function like\n    \u0027test_line_count\u0027 is triggered,\n  - which is invoked from the test script\u0027s \"main\" shell [2],\n  - and the test script is run manually (i.e. \u0027./t1234-foo.sh\u0027 as\n    opposed to \u0027make t1234-foo.sh\u0027 or \u0027make test\u0027) [3]\n  - and without the \u0027--verbose\u0027 option,\n\nbecause the error message is printed from within \u0027test_eval_\u0027, where\nstandard output is redirected either to /dev/null or to a log file.\nThe only indication that something is wrong is that not all tests in\nthe script are executed and at the end of the test script\u0027s output\nthere is no \"# passed all N tests\" message, which are subtle and can\neasily go unnoticed, as I had to experience myself.\n\nSend these \"bug in the test script\" error messages directly to the\ntest scripts standard error and thus to the terminal, so those bugs\nwill be much harder to overlook.  Instead of updating all ~20 such\n\u0027error\u0027 calls with a redirection, let\u0027s add a BUG() function to\n\u0027test-lib.sh\u0027, wrapping an \u0027error\u0027 call with the proper redirection\nand also including the common prefix of those error messages, and\nconvert all those call sites [4] to use this new BUG() function\ninstead.\n\n[1] That particular error message from \u0027test_expect_success\u0027 is\n    printed in color only when running with or without \u0027--verbose\u0027;\n    with \u0027--tee\u0027 or \u0027--verbose-log\u0027 the error is printed without\n    color, but it is printed to the terminal nonetheless.\n\n[2] If such a condition is triggered in a subshell of a test, then\n    \u0027error\u0027 won\u0027t be able to abort the whole test script, but only the\n    subshell, which in turn causes the test to fail in the usual way,\n    indicating loudly and clearly that something is wrong.\n\n[3] Well, \u0027error\u0027 aborts the test script the same way when run\n    manually or by \u0027make\u0027 or \u0027prove\u0027, but both \u0027make\u0027 and \u0027prove\u0027 pay\n    attention to the test script\u0027s exit status, and even a silently\n    aborted test script would then trigger those tools\u0027 usual\n    noticable error messages.\n\n[4] Strictly speaking, not all those \u0027error\u0027 calls need that\n    redirection to send their output to the terminal, see e.g.\n    \u0027test_expect_success\u0027 in the opening example, but I think it\u0027s\n    better to be consistent.\n\nSigned-off-by: SZEDER Gábor \u003cszeder.dev@gmail.com\u003e\nSigned-off-by: Junio C Hamano \u003cgitster@pobox.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "11d1922cf58edb78b8e311e3fa041ae54b625e74",
      "old_mode": 33188,
      "old_path": "t/perf/perf-lib.sh",
      "new_id": "2e33ab3ec3ef9838962c7a8b1a997faeed11f071",
      "new_mode": 33188,
      "new_path": "t/perf/perf-lib.sh"
    },
    {
      "type": "modify",
      "old_id": "182da069f1743b8a06b65396599f94530080e67f",
      "old_mode": 33261,
      "old_path": "t/t0001-init.sh",
      "new_id": "42a263cadafe55803bacf5e8bc071b9999618fc4",
      "new_mode": 33261,
      "new_path": "t/t0001-init.sh"
    },
    {
      "type": "modify",
      "old_id": "73f7038253d6429f9d05c38f36c226107b5251ff",
      "old_mode": 33261,
      "old_path": "t/t4013-diff-various.sh",
      "new_id": "7d985ff6b1bff3c73e4309cde675f67c813d93da",
      "new_mode": 33261,
      "new_path": "t/t4013-diff-various.sh"
    },
    {
      "type": "modify",
      "old_id": "7316365a24679edbb9d79db74a4ba6e9aa4ad9be",
      "old_mode": 33261,
      "old_path": "t/t5516-fetch-push.sh",
      "new_id": "37e8e80893dad130c5c00882796047417aae115b",
      "new_mode": 33261,
      "new_path": "t/t5516-fetch-push.sh"
    },
    {
      "type": "modify",
      "old_id": "3c6b185b60891c164f56a638071873051420fdac",
      "old_mode": 33261,
      "old_path": "t/t9902-completion.sh",
      "new_id": "d01ad8eb2587ba32637d7ec8161811696a0aec34",
      "new_mode": 33261,
      "new_path": "t/t9902-completion.sh"
    },
    {
      "type": "modify",
      "old_id": "b4e391526a2957fe2e578d226ef756321e51aef7",
      "old_mode": 33188,
      "old_path": "t/test-lib-functions.sh",
      "new_id": "3c6bf8d8556ec0f6b512dd2550ec520b119f975a",
      "new_mode": 33188,
      "new_path": "t/test-lib-functions.sh"
    },
    {
      "type": "modify",
      "old_id": "6c6c0af7a128ea7f35fb1753ed39c073208976ea",
      "old_mode": 33188,
      "old_path": "t/test-lib.sh",
      "new_id": "0f1faa24b27b90f4d246d33da9950325f8736633",
      "new_mode": 33188,
      "new_path": "t/test-lib.sh"
    }
  ]
}
