# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.


import json

from watchman.integration.lib import WatchmanTestCase


@WatchmanTestCase.expand_matrix
class TestCommand(WatchmanTestCase.WatchmanTestCase):
    def test_unknown_commands_print_json_error(self) -> None:
        stdout, stderr = self.watchmanInstance().commandViaCLI(
            ["--pretty", "unknown-command"]
        )
        self.assertEqual(b"", stderr)
        self.assertNotEqual(b"", stdout)
        error = json.loads(stdout)
        self.assertEqual(
            "watchman::CommandValidationError: failed to validate command: unknown command unknown-command",
            error["error"],
        )

@@ -642,21 +642,21 @@
 f.assert
-Equal
+Regex
 (%0A      
@@ -661,17 +661,47 @@
         
-%22
+error%5B%22error%22%5D,%0A            %22.*
 watchman
@@ -792,36 +792,8 @@
 d%22,%0A
-            error%5B%22error%22%5D,%0A
     

fix test_command on Windows