hotforfeature / wct-browserstack

WCT plugin that enables support for testing via Browserstack
1 stars 2 forks source link

[BUGFIX] Prefent browserstack to create local.log #4

Closed daKmoR closed 6 years ago

daKmoR commented 6 years ago

before => there is a local.log file after using wct after => no new files after running wct

daKmoR commented 6 years ago

also could you please create a new npm release including this change :)

thxxxx :)

hotforfeature commented 6 years ago

Is this the proper cross-platform way to prevent tunnel logs? I foresee see this failing on Windows.

I was under the impression that a log file is only created when verbose is set to true. Perhaps a better solution would be to modify your config as such:

wct.conf.js

module.exports = {
  plugins: {
    browserstack: {
      tunnel: {
        logFile: '/dev/null' // Unix only
      }
    }
  }
};

or if you want verbose WCT but not verbose tunnel messages

module.exports = {
  plugins: {
    browserstack: {
      tunnel: {
        verbose: false
      }
    }
  }
};

$ wct --verbose

daKmoR commented 6 years ago

I'm not using verbose and still getting these files :/ but I couldn't find an option on the tunnel to disable the creation of the file... it uses childProcess.exec('echo "" > ' + that.logfile); to create the file? https://github.com/browserstack/browserstack-local-nodejs/blob/master/lib/Local.js#L30

it seems strange :/

yeah

      tunnel: {
        verbose: false
      }

works also...

so having verbose undefined means it get it to true? strange? maybe set it by default to false?

hotforfeature commented 6 years ago

If verbose is undefined, it defaults to the emitter's verbose option, which is wct.options.verbose.

If wct.options.verbose is undefined, I would think that equates to "false" for the browserstack local lib. If browserstack defaults to true, then this plugin should set the verbose option to false when undefined.

daKmoR commented 6 years ago

hmm strangely...

      tunnel: {
        verbose: false
      }

does not seem to work anymore? or maybe it never worked and I just got it wrong :package: and

could you pls try and check if there is a local.log file created for you?

this is my full config

module.exports = {
    plugins: {
        sauce: { disabled: true },
        browserstack: {
            browsers: [{
                browser: 'chrome',
                browser_version: 'latest',
                os: 'windows',
                os_version: '10'
            }],
            defaults: {
                video: false
            },
            tunnel: {
                verbose: false
            }
        }
    }
};

and I just call it with wct so nothing else specified...

hotforfeature commented 6 years ago

Did a little more digging, and tunnel.verbose is being set to false correctly when it is not specified in the wct.conf.js file and when not running wct --verbose.

Neither does browserstack-local-nodejs add the log file command. Instead, it's the browserstack-local binary that will automatically create local.log if it is not provided a different log file location.

So your original solution is correct. You could expand it a bit to be more cross-platform friendly. Try using this as your wct.conf.js

module.exports = {
  plugins: {
    browserstack: {
      tunnel: {
        logFile: process.platform === 'win32' ? 'nul' : '/dev/null'
      }
    }
  }
};

I'm going to go ahead and close this PR though and track adding this documentation in #7. I think the more appropriate thing to do is keep things at a default and let developers choose whether or not to have local.log generated rather than making a decision for all devs not to generate it.