Skip to content

Commit

Permalink
Move IS_ROOT definition to framework
Browse files Browse the repository at this point in the history
Signed-off-by: Mats Wichmann <mats@linux.com>
  • Loading branch information
mwichmann committed Oct 19, 2024
1 parent c25c7b1 commit fb8932b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 29 deletions.
8 changes: 1 addition & 7 deletions SCons/CacheDirTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,12 @@
import tempfile
import stat

from TestCmd import TestCmd, IS_WINDOWS
from TestCmd import TestCmd, IS_WINDOWS, IS_ROOT

import SCons.CacheDir

built_it = None

try:
IS_ROOT = os.geteuid() == 0
except AttributeError:
IS_ROOT = False


class Action:
def __call__(self, targets, sources, env, **kw) -> int:
global built_it
Expand Down
8 changes: 1 addition & 7 deletions SCons/Node/FSTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import stat
from typing import Optional

from TestCmd import TestCmd, IS_WINDOWS
from TestCmd import TestCmd, IS_WINDOWS, IS_ROOT

import SCons.Errors
import SCons.Node.FS
Expand All @@ -44,12 +44,6 @@

scanner_count = 0

try:
IS_ROOT = os.geteuid() == 0
except AttributeError:
IS_ROOT = False


class Scanner:
def __init__(self, node=None) -> None:
global scanner_count
Expand Down
8 changes: 1 addition & 7 deletions SCons/Variables/PathVariableTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@
import SCons.Variables

import TestCmd
from TestCmd import IS_WINDOWS

try:
IS_ROOT = os.geteuid() == 0
except AttributeError:
IS_ROOT = False

from TestCmd import IS_WINDOWS, IS_ROOT

class PathVariableTestCase(unittest.TestCase):
def test_PathVariable(self) -> None:
Expand Down
5 changes: 1 addition & 4 deletions test/Install/Install.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import time

import TestSCons
from TestCmd import IS_ROOT

test = TestSCons.TestSCons()

Expand Down Expand Up @@ -132,10 +133,6 @@ def my_install(dest, source, env):
test.write(['work', 'f1.in'], "f1.in again again\n")

# This test is not designed to work if running as root
try:
IS_ROOT = os.geteuid() == 0
except AttributeError:
IS_ROOT = False
if not IS_ROOT:
os.chmod(test.workpath('work', 'export'), 0o555)
with open(f1_out, 'rb'):
Expand Down
5 changes: 1 addition & 4 deletions test/VariantDir/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@
import stat
import sys
import TestSCons
from TestCmd import IS_ROOT

test = TestSCons.TestSCons()

try:
IS_ROOT = os.geteuid() == 0
except AttributeError:
IS_ROOT = False
if IS_ROOT:
test.skip_test('SConscript permissions meaningless when running as root; skipping test.\n')

Expand Down
4 changes: 4 additions & 0 deletions testing/framework/TestCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@
IS_MACOS = sys.platform == 'darwin'
IS_64_BIT = sys.maxsize > 2**32
IS_PYPY = hasattr(sys, 'pypy_translation_info')
try:
IS_ROOT = os.geteuid() == 0
except AttributeError:
IS_ROOT = False
NEED_HELPER = os.environ.get('SCONS_NO_DIRECT_SCRIPT')

# sentinel for cases where None won't do
Expand Down

0 comments on commit fb8932b

Please sign in to comment.