wokwi / wokwi-cli

Wokwi Command Line Interface (for CI use cases)
MIT License
14 stars 5 forks source link

Allow specifying diagram.json path #16

Closed P-R-O-C-H-Y closed 1 month ago

P-R-O-C-H-Y commented 1 month ago

Hi @urish,

as we discussed I am opening a feature request.

The goal is to add a command to specify diagram.json path for the wokwi-cli the same way we can specify the scenario path. Reason is to be able to use custom diagram.json name, as we have multiple of them for each SoC in the CI tests (example esp32.diagram.json, esp32s2.diagram.json, ..).

urish commented 1 month ago

Thanks! Was just implemented yesterday - see the new --diagram-file option.

P-R-O-C-H-Y commented 1 month ago

This is how we check in pytest the scenario path and how I am implementing the now the diagram path.

        wokwi_cli = wokwi_cli_path or self.wokwi_cli_executable
        cmd = [wokwi_cli, '--interactive', app.app_path]
        if (wokwi_timeout is not None) and (wokwi_timeout > 0):
            cmd.extend(['--timeout', str(wokwi_timeout)])
        if (wokwi_scenario is not None) and os.path.exists(wokwi_scenario):
            cmd.extend(['--scenario', wokwi_scenario])
        if (wokwi_diagram is not None) and os.path.exists(wokwi_diagram):
            cmd.extend(['--diagram-file', wokwi_diagram])

So we need to be able to pass absolute path. But when absolute path provided, the wokwi-cli fails: command:

wokwi-cli --interactive /Users/prochy/Documents/Arduino/hardware/espressif/esp32/tests/validation/gpio 
--timeout 30000 
--scenario /Users/prochy/Documents/Arduino/hardware/espressif/esp32/tests/validation/gpio/scenario.yaml 
--diagram-file /Users/prochy/Documents/Arduino/hardware/espressif/esp32/tests/validation/gpio/esp32.diagram.json

error:

2024-05-29 14:02:43 Wokwi CLI v0.10.0 (b8d57c17cdf1)
2024-05-29 14:02:43 Error: diagram.json not found in /Users/prochy/Documents/Arduino/hardware/espressif/esp32/tests/validation/gpio

@urish Can you please take a look?

P-R-O-C-H-Y commented 1 month ago

When relative path was used and also removed the check in pytest it worked. Can we make it work with absolute path too? :)

wokwi-cli --interactive /Users/prochy/Documents/Arduino/hardware/espressif/esp32/tests/validation/gpio --timeout 30000 --scenario /Users/prochy/Documents/Arduino/hardware/espressif/esp32/tests/validation/gpio/scenario.yaml --diagram-file esp32.diagram.json
PASSED                                                    
urish commented 1 month ago

Thanks for checking! Added support for absolute paths in v0.10.1 (just released)

P-R-O-C-H-Y commented 1 month ago

Passing now with absolute path. Thank you Uri 👍