T-Mose / AutomatedGrading

For TA:s during the course INDA!
1 stars 0 forks source link

Cross-Platform Compatibility #1

Closed T-Mose closed 1 month ago

T-Mose commented 1 month ago

File Path Separators: You use os.path.join to construct file paths, which is good practice. However, in some places, you manually replace backslashes with forward slashes:

file_relative_path = file_relative_path.replace('\', '/') This can cause issues on Windows systems. Instead, use os.path.normpath or handle paths consistently with os.path functions.

Classpath Separators: When specifying the classpath in Java commands, you use semicolons (;):

compile_test_command = ['javac', '-cp', f'{repo_path};{junit_jar};{hamcrest_jar}', unit_test_path, '-d', repo_path] Semicolons are used as classpath separators on Windows, but on Unix-based systems (Linux, macOS), you should use colons (:). To make your script cross-platform, you can use os.pathsep:

classpath = os.pathsep.join([repo_path, junit_jar, hamcrest_jar])

T-Mose commented 1 month ago

Another optemisation is also to merge the with or without junit test file