summaryrefslogtreecommitdiffstats
path: root/testing/mozbase/mozdevice/tests/test_escape_command_line.py
blob: 112dd936c5c3cb699a460ca561049aeddfea3b5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python

import mozunit


def test_escape_command_line(mock_adb_object, redirect_stdout_and_assert):
    """Test _escape_command_line."""
    cases = {
        # expected output : test input
        "adb shell ls -l": ["adb", "shell", "ls", "-l"],
        "adb shell 'ls -l'": ["adb", "shell", "ls -l"],
        "-e 'if (true)'": ["-e", "if (true)"],
        "-e 'if (x === \"hello\")'": ["-e", 'if (x === "hello")'],
        "-e 'if (x === '\"'\"'hello'\"'\"')'": ["-e", "if (x === 'hello')"],
    }
    for expected, input in cases.items():
        assert mock_adb_object._escape_command_line(input) == expected


if __name__ == "__main__":
    mozunit.main()