# SPDX-License-Identifier: MIT # # Copyright The SCons Foundation import os import SCons DefaultEnvironment(tools=[]) env = Environment() drive = os.path.splitdrive(os.getcwd())[0] drive_dir = env.fs.Dir(drive) if not isinstance(drive_dir, SCons.Node.FS.RootDir): raise Exception( f'env.fs.Dir("{drive}") returned a {type(drive_dir)} instead of a RootDir' ) drive_abspath1 = drive_dir._abspath drive_abspath2 = drive_dir.abspath if drive_abspath1 != drive_abspath2: raise Exception( f'Calculated _abspath {drive_abspath1} is not the same as abspath {drive_abspath2}' ) elif not os.path.exists(drive_abspath1): raise Exception(f'Calculated abspath {drive_abspath1} does not exist') elif drive.rstrip(os.path.sep) != drive_abspath1.rstrip(os.path.sep): raise Exception( f'Real drive {drive} and calculated abspath {drive_abspath1} are not the same' ) drive_path1 = drive_dir._path drive_path2 = drive_dir.path if drive_path1 != drive_path2: raise Exception( f'Calculated _path {drive_path1} is not the same as path {drive_path2}' ) elif not os.path.exists(drive_path1): raise Exception(f'Calculated path {drive_path1} does not exist') elif drive.rstrip(os.path.sep) != drive_path1.rstrip(os.path.sep): raise Exception( f'Real drive {drive} and calculated abspath {drive_abs} are not the same' )