File: test_cached_source_file.py

package info (click to toggle)
pygccxml 3.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,444 kB
  • sloc: xml: 29,841; python: 13,914; cpp: 2,671; makefile: 163; ansic: 59
file content (39 lines) | stat: -rw-r--r-- 1,175 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Copyright 2014-2017 Insight Software Consortium.
# Copyright 2004-2009 Roman Yakovenko.
# Distributed under the Boost Software License, Version 1.0.
# See http://www.boost.org/LICENSE_1_0.txt

import os
import stat

from . import autoconfig

from pygccxml import utils
from pygccxml import parser

TEST_FILES = [
    "core_types.hpp",
]


def test_cached_source_file():

    config = autoconfig.cxx_parsers_cfg.config.clone()

    fconfig = parser.file_configuration_t(
        data=TEST_FILES[0],
        content_type=parser.CONTENT_TYPE.CACHED_SOURCE_FILE)
    try:
        prj_reader = parser.project_reader_t(config)
        prj_reader.read_files(
            [fconfig],
            compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE)
        assert os.path.exists(fconfig.cached_source_file)
        mtime1 = os.stat(fconfig.cached_source_file)[stat.ST_MTIME]
        prj_reader.read_files(
            [fconfig],
            compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE)
        mtime2 = os.stat(fconfig.cached_source_file)[stat.ST_MTIME]
        assert mtime1 == mtime2
    finally:
        utils.remove_file_no_raise(fconfig.cached_source_file, config)