Skip to content

Commit

Permalink
[FIX] issue 1637 (#1720)
Browse files Browse the repository at this point in the history
Fix dry-run and rename it no-config
  • Loading branch information
t-h2o authored Dec 26, 2024
1 parent fda96ea commit 7a649d4
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A clear and concise description of what the bug is, a screenshot helps a lot.

**To Reproduce**
Steps to reproduce the behavior:
1. Open the file using `f3d --dry-run example.glb`
1. Open the file using `f3d --no-config example.glb`
2. step 2
3. step 3

Expand Down
4 changes: 2 additions & 2 deletions application/F3DOptionsTools.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ static inline const std::array<CLIGroup, 8> CLIOptions = {{
{ "readers-list", "", "Print the list of readers", "", "" },
{ "bindings-list", "", "Print the list of interaction bindings and exits, ignored with `--no-render`, only considers the first file group.", "", "" },
{ "config", "", "Specify the configuration file to use. absolute/relative path or filename/filestem to search in configuration file locations", "<filePath/filename/fileStem>", "" },
{ "dry-run", "", "Do not read the configuration file", "<bool>", "1" },
{ "no-render", "", "Do not read the configuration file", "<bool>", "1" },
{ "no-config", "", "Do not read the configuration file", "<bool>", "1" },
{ "no-render", "", "Do not render anything and quit right after loading the first file, use with --verbose to recover information about a file.", "<bool>", "1" },
{ "rendering-backend", "", "Backend to use when rendering (auto|glx|wgl|egl|osmesa)", "<string>", "" },
{ "max-size", "", "Maximum size in Mib of a file to load, leave empty for unlimited", "<size in Mib>", "" },
#if F3D_MODULE_DMON
Expand Down
2 changes: 1 addition & 1 deletion application/F3DOptionsTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static inline const OptionsDict DefaultAppOptions = {
{ "bindings-list", "false" },
{ "no-background", "false" },
{ "config", "" },
{ "dry-run", "false" },
{ "no-config", "false" },
{ "no-render", "false" },
{ "rendering-backend", "auto" },
{ "max-size", "" },
Expand Down
12 changes: 6 additions & 6 deletions application/F3DStarter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -812,17 +812,17 @@ int F3DStarter::Start(int argc, char** argv)
// Store in a option entries for easier processing
this->Internals->CLIOptionsEntries.emplace_back(cliOptionsDict, fs::path(), "CLI options");

// Check dry-run, config CLI, output and verbose options first
// Check no-config, config CLI, output and verbose options first
// XXX: the local variable are initialized manually for simplicity
// but this duplicate the initialization value as it is present in
// F3DOptionTools::DefaultAppOptions too
bool dryRun = false;
if (cliOptionsDict.find("no-render") != cliOptionsDict.end())
bool noConfig = false;
if (cliOptionsDict.find("no-config") != cliOptionsDict.end())
{
dryRun = f3d::options::parse<bool>(cliOptionsDict["no-render"]);
noConfig = f3d::options::parse<bool>(cliOptionsDict["no-config"]);
}
std::string config;
if (cliOptionsDict.find("config") != cliOptionsDict.end())
if (!noConfig && cliOptionsDict.find("config") != cliOptionsDict.end())
{
config = f3d::options::parse<std::string>(cliOptionsDict["config"]);
}
Expand All @@ -844,7 +844,7 @@ int F3DStarter::Start(int argc, char** argv)
f3d::log::debug("========== Initializing Options ==========");

// Read config files
if (!dryRun)
if (!noConfig)
{
std::tie(this->Internals->ConfigOptionsEntries, this->Internals->ConfigBindingsEntries) =
F3DConfigFileTools::ReadConfigFiles(config);
Expand Down
15 changes: 9 additions & 6 deletions application/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function(f3d_test)
if(F3D_TEST_CONFIG)
list(APPEND F3D_TEST_ARGS "--config=${F3D_TEST_CONFIG}")
else()
list(APPEND F3D_TEST_ARGS "--dry-run")
list(APPEND F3D_TEST_ARGS "--no-config")
endif()

if (F3D_TEST_DATA)
Expand Down Expand Up @@ -261,17 +261,17 @@ endif()
function(f3d_ss_test)
cmake_parse_arguments(F3D_SS_TEST "MINIMAL" "NAME;TEMPLATE;EXPECTED;DEPENDS" "ARGS" ${ARGN})
if(NOT F3D_SS_TEST_MINIMAL)
f3d_test(NAME TestScreenshot${F3D_SS_TEST_NAME} DATA suzanne.ply ARGS --screenshot-filename=${F3D_SS_TEST_TEMPLATE} --dry-run --interaction-test-play=${F3D_SOURCE_DIR}/testing/recordings/TestScreenshot.log NO_BASELINE DEPENDS TestSetupScreenshots)
f3d_test(NAME TestScreenshot${F3D_SS_TEST_NAME} DATA suzanne.ply ARGS --screenshot-filename=${F3D_SS_TEST_TEMPLATE} --no-config --interaction-test-play=${F3D_SOURCE_DIR}/testing/recordings/TestScreenshot.log NO_BASELINE DEPENDS TestSetupScreenshots)
f3d_test(NAME TestScreenshot${F3D_SS_TEST_NAME}File DATA suzanne.ply ARGS --reference=${F3D_SS_TEST_EXPECTED} DEPENDS TestScreenshot${F3D_SS_TEST_NAME} ${F3D_SS_TEST_DEPENDS} NO_BASELINE)
else()
# show filename, axes, fps before the "minimal screenshot" interaction; compare with --no-background only
f3d_test(NAME TestScreenshot${F3D_SS_TEST_NAME} DATA suzanne.ply ARGS --screenshot-filename=${F3D_SS_TEST_TEMPLATE} --dry-run -nxz --interaction-test-play=${F3D_SOURCE_DIR}/testing/recordings/TestScreenshotMinimal.log NO_BASELINE DEPENDS TestSetupScreenshots)
f3d_test(NAME TestScreenshot${F3D_SS_TEST_NAME} DATA suzanne.ply ARGS --screenshot-filename=${F3D_SS_TEST_TEMPLATE} --no-config -nxz --interaction-test-play=${F3D_SOURCE_DIR}/testing/recordings/TestScreenshotMinimal.log NO_BASELINE DEPENDS TestSetupScreenshots)
f3d_test(NAME TestScreenshot${F3D_SS_TEST_NAME}File DATA suzanne.ply ARGS --no-background --reference=${F3D_SS_TEST_EXPECTED} DEPENDS TestScreenshot${F3D_SS_TEST_NAME} ${F3D_SS_TEST_DEPENDS} NO_BASELINE)
endif()
endfunction()
function(f3d_ss_template_test)
cmake_parse_arguments(F3D_SS_TEMPLATE_TEST "" "NAME;TEMPLATE;EXPECTED_REGEX" "ARGS" ${ARGN})
f3d_test(NAME TestScreenshot${F3D_SS_TEMPLATE_TEST_NAME} DATA suzanne.ply ARGS --screenshot-filename=${F3D_SS_TEMPLATE_TEST_TEMPLATE} --dry-run --interaction-test-play=${F3D_SOURCE_DIR}/testing/recordings/TestScreenshot.log
f3d_test(NAME TestScreenshot${F3D_SS_TEMPLATE_TEST_NAME} DATA suzanne.ply ARGS --screenshot-filename=${F3D_SS_TEMPLATE_TEST_TEMPLATE} --no-config --interaction-test-play=${F3D_SOURCE_DIR}/testing/recordings/TestScreenshot.log
REGEXP "saving screenshot to .+[/\\]${F3D_SS_TEMPLATE_TEST_EXPECTED_REGEX}" NO_BASELINE DEPENDS TestSetupScreenshots)
endfunction()

Expand Down Expand Up @@ -1058,6 +1058,9 @@ f3d_test(NAME TestConfigFileQuiet DATA nonExistentFile.vtp CONFIG ${F3D_SOURCE_D
# Test no file with config file
f3d_test(NAME TestNoFileConfigFile CONFIG ${F3D_SOURCE_DIR}/testing/configs/verbose.json ARGS --verbose REGEXP "No files to load provided" NO_BASELINE)

# Test that --no-config overrides --config
f3d_test(NAME TestNoConfigWithConfig DATA f3d.glb ARGS --no-config --config ${F3D_SOURCE_DIR}/testing/configs/complex.json)

# Test help display
f3d_test(NAME TestHelp ARGS --help REGEXP "Usage:")
f3d_test(NAME TestHelpPositional ARGS --help REGEXP "file1 file2 \.\.\.")
Expand Down Expand Up @@ -1113,8 +1116,8 @@ endif()
f3d_test(NAME TestRenderingBackendInvalid DATA cow.vtp RENDERING_BACKEND invalid ARGS --verbose REGEXP "rendering-backend value is invalid, falling back to" NO_BASELINE)

# Test that f3d can try to read a system config file
add_test(NAME f3d::TestNoDryRun COMMAND $<TARGET_FILE:f3d> --no-render)
set_tests_properties(f3d::TestNoDryRun PROPERTIES TIMEOUT 4)
add_test(NAME f3d::TestNoNoConfig COMMAND $<TARGET_FILE:f3d> --no-render)
set_tests_properties(f3d::TestNoNoConfig PROPERTIES TIMEOUT 4)

# Test invalid CLI args
add_test(NAME f3d::TestInvalidCLIArgs COMMAND $<TARGET_FILE:f3d> --up)
Expand Down
2 changes: 1 addition & 1 deletion doc/user/CONFIGURATION_FILE.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ The third block specifies raytracing usage for .gltf and .glb files.
The last block specifies that volume rendering should be used with .mhd files.

The following options <b> cannot </b> be set via config file:
`help`, `version`, `readers-list`, `config`, `dry-run` and `input`.
`help`, `version`, `readers-list`, `config`, `no-config` and `input`.

The following options <b>are only taken on the first load</b>:
`no-render`, `output`, `position`, `resolution`, `frame-rate` and all testing options.
Expand Down
2 changes: 1 addition & 1 deletion doc/user/OPTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Options|Type<br>Default|Description
\-\-version||Show *version* information and exit. Ignore `--verbose`.
\-\-readers-list||List available *readers* and exit. Ignore `--verbose`.
\-\-config=\<config file path/name/stem\>|string<br>config|Specify the [configuration file](CONFIGURATION_FILE.md) to use. Supports absolute/relative path but also filename/filestem to search for in standard configuration file locations.
\-\-dry-run|bool<br>false|Do not read any configuration file and consider only the command line options.
\-\-no-config|bool<br>false|Do not read any configuration file and consider only the command line options.
\-\-no-render|bool<br>false|Do not render anything and quit just after loading the first file, use with \-\-verbose to recover information about a file.
\-\-max-size=\<size in MiB\>|int<br>-1|Prevent F3D to load a file bigger than the provided size in Mib, leave empty for unlimited, useful for thumbnails.
\-\-watch|bool<br>false|Watch current file and automatically reload it whenever it is modified on disk.
Expand Down
2 changes: 1 addition & 1 deletion examples/plugins/example-plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if(BUILD_TESTING)
find_package(f3d REQUIRED COMPONENTS application)
add_test(NAME TestPluginExample
COMMAND "$<TARGET_FILE:f3d::f3d>"
"--dry-run"
"--no-config"
"--no-render"
"--verbose"
"--load-plugins=$<TARGET_FILE:f3d-plugin-example>"
Expand Down
4 changes: 2 additions & 2 deletions testing/baselines/TestInteractionConsoleInvalidCommand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions testing/baselines/TestInteractionConsoleInvalidOption.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions testing/baselines/TestInteractionConsoleOpen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions testing/baselines/TestInteractionConsoleOpenWarningClick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions testing/baselines/TestInteractionConsoleTypingSceneInfo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions testing/baselines/TestNoConfigWithConfig.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7a649d4

Please sign in to comment.