[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace disableSandbox with useSandbox in UtSettings #857

Merged
merged 1 commit into from
Sep 6, 2022

Conversation

dtim
Copy link
Collaborator
@dtim dtim commented Sep 5, 2022

Description

PR #797 introduced a new UtSettings option, disableSandbox (see #785 for motivation). Although disableSandbox is a descriptive name, the inverted logic makes it harder to use and does not match the naming of other settings.

This PR removes the disableSandbox setting and replaces it with useSandbox option (true by default).

Type of Change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Existing UtSettings option is removed. This change may require users to update their .utbot/settings.properties to keep the old behavior.

How Has This Been Tested?

Automated Testing

All existing unit tests should pass. Informative are tests that use withoutSandbox construct:

  • org.utbot.examples.unsafe.UnsafeOperationsTest
  • org.utbot.examples.exceptions.JvmCrashExamplesTest#testCrash

Manual Scenario

Generate a test suite for any Java code that accesses files or environment. An example:

package unsafe;

public class EnvironmentExample {
    public String getJavaVersion() {
        return System.getProperty("java.version");
    }
}

Concrete execution should be enabled.

if UtSettings.useSandbox is set to false, a test case corresponding to a successful execution should be generated:

package unsafe;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class EnvironmentExampleTest {
    ///region Test suites for executable unsafe.EnvironmentExample.getJavaVersion

    ///region

    @Test
    public void testGetJavaVersion() {
        EnvironmentExample environmentExample = new EnvironmentExample();

        String actual = environmentExample.getJavaVersion();

        String expected = "1.8.0_332";
        assertEquals(expected, actual);
    }
    ///endregion

    ///endregion
}

If UtSettings.useSandbox is true (including the case when it is not specified in .utbot/settings.properties at all, so the default value is used), a disabled test should be generated:

package unsafe;

import org.junit.Ignore;
import org.junit.Test;

public class EnvironmentExampleTest {
    ///region Test suites for executable unsafe.EnvironmentExample.getJavaVersion

    ///region

    @Test
    @Ignore(value = "Disabled due to sandbox")
    public void testGetJavaVersion() {
        EnvironmentExample environmentExample = new EnvironmentExample();
        
        /* This test fails because method [unsafe.EnvironmentExample.getJavaVersion] produces [java.security.AccessControlException: access denied ("java.util.PropertyPermission" "java.version" "read")]
            java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
            java.security.AccessController.checkPermission(AccessController.java:886)
            java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
            java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1294)
            java.lang.System.getProperty(System.java:719)
            unsafe.EnvironmentExample.getJavaVersion(EnvironmentExample.java:5) */
    }
    ///endregion

    ///endregion
}

Checklist (remove irrelevant options):

This is the author self-check list

  • The change followed the style guidelines of the UTBot project
  • Self-review of the code is passed
  • The change contains enough commentaries, particularly in hard-to-understand areas
  • New documentation is provided or existed one is altered
  • No new warnings
  • New tests have been added
  • All tests pass locally with my changes

@dtim dtim force-pushed the dtim/rename_disable_sandbox branch from a763216 to 851ce6e Compare September 5, 2022 12:53
@dtim dtim changed the title Replace disableSandbox with enableSandbox in UtSettings Replace disableSandbox with useSandbox in UtSettings Sep 5, 2022
@dtim dtim force-pushed the dtim/rename_disable_sandbox branch from 851ce6e to 6438c44 Compare September 5, 2022 13:21
Although `disableSandbox` is a descriptive name, the inverted logic
makes it harder to use and does not match the naming of other settings.

This commit replaces `disableSandbox` with `useSandbox` and
correspondingly modifies necessary checks.
@dtim dtim force-pushed the dtim/rename_disable_sandbox branch from 6438c44 to 4459671 Compare September 5, 2022 15:29
@dtim dtim marked this pull request as ready for review September 5, 2022 15:29
@dtim dtim requested a review from Damtev September 5, 2022 15:29
@dtim dtim merged commit 861b9aa into main Sep 6, 2022
@dtim dtim deleted the dtim/rename_disable_sandbox branch September 6, 2022 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants