se2p / ps-wise-2021-program-description

Public repository hosting the description of the prorgam for the assignments
2 stars 8 forks source link

Inconsistency in argument processing #14

Closed fatadel closed 3 years ago

fatadel commented 4 years ago

In the minesweeper.js file, the arguments are passed to the main method as main(process.argv), which is an array of strings (first item is a path to node executable, second item path to the entry point script, third item is the first argument and so on). However, when running the tests they pass an argument as just a string (or nothing at all), like minesweeper.main("simple.cfg") (or minesweeper.main()). This leads to inconsistency between the program logic and the test logic.

alessiogambi commented 4 years ago

I see. Do you have a solution for this that can be posted on the forum? Maybe slicing out command-line arguments before passing them to the main function?

fatadel commented 4 years ago

@alessiogambi I think you can change main(process.argv) to main(process.argv.pop()) in the main script. The only inconsistency that remains then will be in case of no config. The tests will pass nothing while direct invocation will pass the path to the entry point script as the argument. But this is just a small inconsistency and both cases can be easily checked against in the program.

alessiogambi commented 3 years ago

I close this issue, since it does not apply to the program description, but I link this to the forum on StudIP for future reference.