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

add setting --tmp arg as process.env.APPIUM_TMP_DIR #12585

Merged

Conversation

KazuCocoa
Copy link
Member

@KazuCocoa KazuCocoa commented May 3, 2019

Proposed changes

related to appium/appium-support#112 and #12527

process.env.APPIUM_TMP_DIR should be set once in Appium process.
In BaseDriver, this.opts.tmpDir refers process.env.APPIUM_TMP_DIR, and the assignment should happen before calling super here.
https://github.com/appium/appium-base-driver/blob/d214a0d1f2aa3aecd8fd4033460ce37176ca4c87/lib/basedriver/driver.js#L49


After this and appium/appium-support#112, --tmp flag will be respected in all of Appium modules which call tempDir module.

I've tested below patterns in ruby_lib_core test suite adding logs in tempDir module:

  • Run a single device test
    • Android
      • UIA2
      • Espresso
    • iOS
      • XCUITest
  • Run tests in parallel in single Appium server instance
    • Android x 3 emulators
      • UIA2
      • Espresso
    • iOS x 2 simulators
      • XCUITest
    • Android x 3, iOS x 2

The ruby_lib_core include screen recording, pull/push apks like appium/appium-android-driver#538

Then, I ensured Appium log had no /var/folders/xxxx. They called --tmp arg.

Types of changes

What types of changes does your code introduce to Appium?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@coveralls
Copy link

coveralls commented May 3, 2019

Coverage Status

Coverage decreased (-0.07%) to 90.211% when pulling 53747aa on KazuCocoa:km/add-setting-tmpdir-into-process-env into 277ed72 on appium:master.

Copy link
Contributor

@imurchie imurchie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the value of tmpDir ever checked for validity?

@KazuCocoa
Copy link
Member Author

Yes, https://github.com/appium/appium/blob/master/lib/config.js#L217-L224 creates the path before the new AppiumDriver(args).
Or is it better to make it safer to call fs.statSync()? (Is this method proper?)

@imurchie
Copy link
Contributor

imurchie commented May 3, 2019

mkdirp is good.

lib/appium.js Outdated
@@ -158,6 +158,13 @@ const pendingDriversGuard = new AsyncLock();

class AppiumDriver extends BaseDriver {
constructor (args) {
// It is necessary to set `--tmp` here since it should set to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since it should be set

lib/appium.js Outdated
@@ -158,6 +158,13 @@ const pendingDriversGuard = new AsyncLock();

class AppiumDriver extends BaseDriver {
constructor (args) {
// It is necessary to set `--tmp` here since it should set to
// process.env.APPIUM_TMP_DIR once at initial time in Appium lifecycle.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at an initial point in the Appium lifecycle

lib/appium.js Outdated
@@ -158,6 +158,13 @@ const pendingDriversGuard = new AsyncLock();

class AppiumDriver extends BaseDriver {
constructor (args) {
// It is necessary to set `--tmp` here since it should set to
// process.env.APPIUM_TMP_DIR once at initial time in Appium lifecycle.
// The process argument will be referred by BaseDriver.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be referenced by BaseDriver

@KazuCocoa KazuCocoa merged commit e35e4f7 into appium:master May 4, 2019
@KazuCocoa KazuCocoa deleted the km/add-setting-tmpdir-into-process-env branch May 4, 2019 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants