123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- use std::process::Command;
- #[test]
- fn test_help() {
- let output = Command::new("target/debug/image-tiler")
- .args(&["--help"])
- .output()
- .expect("image-tiler should be executable");
- let stdout = String::from_utf8(output.stdout).expect("output of image-tiler should be UTF-8");
- assert!(output.status.success());
- let expected_stdout = "\
- Program to generate a larger image made up of different image tiles of the same size
- Usage: image-tiler [OPTIONS] <ROWS> <COLS>
- Arguments:
- <ROWS>
- Number of rows
- <COLS>
- Number of columns
- Options:
- -b, --border <CONNECTOR_NAME>
- Optional connector name that tiles must exhibit towards the border of the image; if this
- option is omitted, bordering tiles may have any connection towards the border
- -c, --config <PATH>
- Optional path to a tile configuration file; overrides any configuration file in the tile
- directory
- -d, --tile-directory <PATH>
- Optional path to a tile directory; if omitted, assume the current working directory.
-
- The directory may contain a tile configuration file named “config.yaml”.
- -m, --missing-tile-policy <MISSING_TILE_POLICY>
- Optional policy name that specifies how to behave in case there is no
- tile with a required connectors list.
-
- MISSING_TILE_POLICY may have one of the following values:
- - avoid: Try to avoid leaving empty positions in the tile grid. This may
- take a considerable amount of time and memory to finish due to
- backtracking. The run may terminate unsuccessfully in case
- there is no solution.
- - exit: (default) Exit immediately if there is no fitting tile; this
- may be useful for debugging tile configurations.
-
- [default: exit]
- [possible values: avoid, exit]
- -n, --no-config
- Do not use any user defined tile configuration; Instead, assume all tiles have the
- connectors { north: “c”, south: “c”, east: “c”, west: “c” } and a weight of 1
- -o, --output <PATH>
- Path to the output file (default: output/tiled)
-
- [default: output/tiled]
- -t, --tile-type <TILE_TYPE>
- Optional type of tiles; if omitted, the type is guessed by inspecting
- the tile configuration (see option “--config”).
-
- TILE_TYPE may have one of the following values:
- - raster: raster graphics tiles, e.g. PNG, JPEG or GIF
- - svg: SVG (Scalable Vector Graphics) tiles
- - text: text based tiles, e.g. for ASCII art
-
- [possible values: raster, svg, text]
- -v, --vacancy-policy <VACANCY_POLICY>
- Optional policy name that specifies how to handle vacant areas.
-
- VACANCY_POLICY may have one of the following values:
- - avoid: Try to avoid leaving vacant areas in the tile grid. This may
- take a considerable amount of time and memory to finish due
- to backtracking. The run may terminate unsuccessfully in
- case there is no solution.
- - avoid-strict: Same as avoid, but searches the entire problem space for
- a valid solution, if necessary, which might be slow.
- - ignore: (default) Ignore and vacant areas in the tile grid untouched.
-
- [default: ignore]
- [possible values: avoid, avoid-strict, ignore]
- -h, --help
- Print help (see a summary with '-h')
- -V, --version
- Print version
- ";
- assert_eq!(stdout, expected_stdout);
- assert_eq!(output.stderr.len(), 0);
- }
- #[test]
- fn check_that_parameters_config_and_no_config_are_not_passed_together() {
- let output = Command::new("target/debug/image-tiler")
- .args(&["-c", "file.yaml", "-n"])
- .output()
- .expect("failed to execute command");
- let stderr = String::from_utf8(output.stderr).expect("output of image-tiler should be UTF-8");
- assert_eq!(output.status.code(), Some(2));
- assert_eq!(output.stdout.len(), 0);
- let expected_stderr = "\
- error: the argument '--config <PATH>' cannot be used with '--no-config'
- Usage: image-tiler --config <PATH> <ROWS> <COLS>
- For more information, try '--help'.
- ";
- assert_eq!(stderr, expected_stderr);
- }
|