1#!/usr/bin/python 2# Copyright 2017 The TensorFlow Authors. All Rights Reserved. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# ============================================================================== 16# 17# Test that checks if we have any issues with case insensitive filesystems. 18 19from __future__ import absolute_import 20from __future__ import division 21from __future__ import print_function 22 23import os 24 25BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')) 26ERROR_MESSAGE = """ 27Files with same name but different case detected in directory: {} 28""" 29 30 31def main(): 32 # Make sure BASE_DIR ends with tensorflow. If it doesn't, we probably 33 # computed the wrong directory. 34 if os.path.split(BASE_DIR)[-1] != 'tensorflow': 35 raise AssertionError( 36 "BASE_DIR = '%s' doesn't end with tensorflow" % BASE_DIR) 37 38 for dirpath, dirnames, filenames in os.walk(BASE_DIR, followlinks=True): 39 lowercase_directories = [x.lower() for x in dirnames] 40 lowercase_files = [x.lower() for x in filenames] 41 42 lowercase_dir_contents = lowercase_directories + lowercase_files 43 if len(lowercase_dir_contents) != len(set(lowercase_dir_contents)): 44 raise AssertionError(ERROR_MESSAGE.format(dirpath)) 45 46 47if __name__ == '__main__': 48 main() 49