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

Suppress warnings in unit test output #3828

Merged
merged 1 commit into from
Feb 25, 2019

Conversation

jerryaldrichiii
Copy link
Contributor

This does the following:

  • Captures warning for lack of --sudo with --sudo-password
  • Captures warnings for transformation of URL target in url fetcher
  • Changes deprecated supports: syntax to use new syntax

This does the following:
  - Captures warning for lack of `--sudo` with `--sudo-password`
  - Captures warnings for transformation of URL target in url fetcher
  - Changes deprecated `supports:` syntax to use new syntax

Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
Copy link
Contributor

@clintoncwolfe clintoncwolfe left a comment

Choose a reason for hiding this comment

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

I'm not seeing any warnings when run under m. Could you include how you are running the tests, and what output you are seeing?

@@ -255,8 +255,13 @@
end

it 'assumes `--sudo` if `--sudo-password` is used without it' do
cfg = Inspec::Config.new('sudo_password' => 'somepass')
cfg.key?('sudo').must_equal true
@mock_logger = Minitest::Mock.new
Copy link
Contributor

Choose a reason for hiding this comment

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

What warning is being suppressed here? I don't see a warning when run on master@

[cwolfe@lodi inspec-review]$ git log --oneline -n1
8c37a614 (HEAD -> master, tag: v3.6.12, origin/master, origin/HEAD) Bump version to 3.6.12 by Chef Expeditor

[cwolfe@lodi inspec-review]$ be m test/unit/config_test.rb
Run options: -n "/^(test_0001_should\\ initialize\\ properly|test_0001_should\\ initialize\\ properly|test_0001_should\\ read\\ the\\ file\\ successfully|test_0001_should\\ read\\ the\\ file\\ successfully|test_0001_should\\ read\\ the\\ file\\ successfully|test_0001_should\\ throw\\ an\\ exception|test_0001_should\\ throw\\ an\\ exception|test_0001_should\\ throw\\ an\\ exception|test_0001_should\\ have\\ the\\ correct\\ defaults|test_0001_should\\ have\\ the\\ correct\\ defaults|test_0001_should\\ transparently\\ round\\-trip\\ the\\ options|test_0001_should\\ read\\ the\\ options|test_0001_should\\ read\\ the\\ options|test_0001_parse\\ cli\\ reporters|test_0001_parses\\ cli\\ report\\ and\\ attaches\\ target_id|test_0001_valid\\ reporter|test_0002_invalid\\ reporter\\ type|test_0003_two\\ reporters\\ outputting\\ to\\ stdout|test_0003_calls\\ `Compliance::API\\.login`\\ if\\ `opts\\[:compliance\\]\\ is\\ passed`|test_0001_raises\\ if\\ `\\-\\-password/\\-\\-sudo\\-password`\\ are\\ used\\ without\\ value|test_0002_assumes\\ `\\-\\-sudo`\\ if\\ `\\-\\-sudo\\-password`\\ is\\ used\\ without\\ it|test_0001_should\\ pass\\ the\\ credentials\\ as\\-is|test_0001_should\\ read\\ the\\ backend\\ and\\ strip\\ prefixes|test_0001_should\\ unpack\\ the\\ options\\ using\\ the\\ URI\\ parser|test_0001_should\\ assign\\ the\\ options\\ correctly|test_0001_the\\ config\\ file\\ setting\\ should\\ prevail|test_0001_the\\ CLI\\ option\\ should\\ prevail|test_0001_the\\ CLI\\ option\\ should\\ prevail|test_0001_the\\ config\\ file\\ setting\\ should\\ prevail)$/" --seed 17558

# Running:

.............................

Finished in 0.131891s, 219.8785 runs/s, 712.7097 assertions/s.

29 runs, 94 assertions, 0 failures, 0 errors, 0 skips
[cwolfe@lodi inspec-review]$

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, get this. I couldn't get them to output via m any more. If you run bundle exec rake test though you'll see:

https://github.com/inspec/inspec/blob/master/lib/inspec/config.rb#L367

@@ -20,6 +20,17 @@
m
}

def expect_url_transform
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, when run under m I don't see any warnings

@jerryaldrichiii
Copy link
Contributor Author

Yup, can do. @clintoncwolfe. I also couldn't get the output to show up in m (though it used too)

@jerryaldrichiii
Copy link
Contributor Author

Here is the output of bundle exec rake test where I was seeing the WARN lines. The URL transforms also seem to be intermittent. 😕

Run options: --seed 49574

# Running:

......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................S............................................................................................................................................................................................................................................................................................................................................................................................................S...........................................................................................................................................................................................................................................................................................................................................................................................[2019-02-22T11:14:10-08:00] WARN: Attribute test_attribute created using both :default and :value options - ignoring :default
.........................................................................................................................................................................................................................................................................................................................................................................................................................................[2019-02-22T11:15:20-08:00] WARN: `--sudo-password` used without `--sudo`. Adding `--sudo`.
............................................Successfully uninstalled inspec-test-fixture-0.1.0
.Successfully uninstalled ordinal_array-0.2.0
Successfully uninstalled inspec-test-fixture-0.2.0
....................................................................[2019-02-22T11:15:32-08:00] WARN: URL target https://bitbucket.org/chef/inspec.git transformed to https://bitbucket.org/chef/inspec/get/master.tar.gz. Consider using the git fetcher
.[2019-02-22T11:15:32-08:00] WARN: URL target https://bitbucket.org/chef/inspec/commits/48bd4388ddffde68badd83aefa654e7af3231876 transformed to https://bitbucket.org/chef/inspec/get/48bd4388ddffde68badd83aefa654e7af3231876.tar.gz. Consider using the git fetcher
.[2019-02-22T11:15:32-08:00] WARN: URL target http://github.com/chef/inspec transformed to https://github.com/chef/inspec/archive/master.tar.gz. Consider using the git fetcher
.[2019-02-22T11:15:32-08:00] WARN: URL target https://bitbucket.org/chef/inspec/branch/newbranch transformed to https://bitbucket.org/chef/inspec/get/newbranch.tar.gz. Consider using the git fetcher
.[2019-02-22T11:15:32-08:00] WARN: URL target https://www.bitbucket.org/chef/inspec.git transformed to https://bitbucket.org/chef/inspec/get/master.tar.gz. Consider using the git fetcher
.[2019-02-22T11:15:32-08:00] WARN: URL target http://bitbucket.org/chef/inspec transformed to https://bitbucket.org/chef/inspec/get/master.tar.gz. Consider using the git fetcher
.[2019-02-22T11:15:32-08:00] WARN: URL target https://github.com/hardening-io/tests-os-hardening/tree/2.0 transformed to https://github.com/hardening-io/tests-os-hardening/archive/2.0.tar.gz. Consider using the git fetcher
..[2019-02-22T11:15:32-08:00] WARN: URL target https://github.com/hardening-io/tests-os-hardening/tree/48bd4388ddffde68badd83aefa654e7af3231876 transformed to https://github.com/hardening-io/tests-os-hardening/archive/48bd4388ddffde68badd83aefa654e7af3231876.tar.gz. Consider using the git fetcher
.[2019-02-22T11:15:32-08:00] WARN: URL target http://bitbucket.org/chef/inspec.git transformed to https://bitbucket.org/chef/inspec/get/master.tar.gz. Consider using the git fetcher
..[2019-02-22T11:15:32-08:00] WARN: URL target http://www.github.com/chef/inspec.git transformed to https://github.com/chef/inspec/archive/master.tar.gz. Consider using the git fetcher
.[2019-02-22T11:15:32-08:00] WARN: URL target http://github.com/chef/inspec.git transformed to https://github.com/chef/inspec/archive/master.tar.gz. Consider using the git fetcher
...[2019-02-22T11:15:32-08:00] WARN: URL target https://github.com/chef/inspec transformed to https://github.com/chef/inspec/archive/master.tar.gz. Consider using the git fetcher
.[2019-02-22T11:15:32-08:00] WARN: URL target https://github.com/chef/inspec.git transformed to https://github.com/chef/inspec/archive/master.tar.gz. Consider using the git fetcher
.[2019-02-22T11:15:32-08:00] WARN: URL target https://bitbucket.org/chef/inspec transformed to https://bitbucket.org/chef/inspec/get/master.tar.gz. Consider using the git fetcher
.[2019-02-22T11:15:32-08:00] WARN: URL target http://www.bitbucket.org/chef/inspec.git transformed to https://bitbucket.org/chef/inspec/get/master.tar.gz. Consider using the git fetcher
.[2019-02-22T11:15:32-08:00] WARN: URL target https://www.github.com/chef/inspec.git transformed to https://github.com/chef/inspec/archive/master.tar.gz. Consider using the git fetcher
................................S.........................................................................................................................................................................

Finished in 312.020616s, 6.5829 runs/s, 15.8964 assertions/s.

2054 runs, 4960 assertions, 0 failures, 0 errors, 3 skips

You have skipped tests. Run with --verbose for details.
Coverage report generated for Unit Tests to /home/jerry/Projects/github.com/inspec/inspec/coverage. 11828 / 14924 LOC (79.25%) covered.

Copy link
Contributor

@clintoncwolfe clintoncwolfe left a comment

Choose a reason for hiding this comment

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

OK, while I don't see the same warnings (which is problematic on my end), the changes you have here are healthy - thanks!

@clintoncwolfe
Copy link
Contributor

As this is test code, we generally only need one approver - moving ahead with this one.

@clintoncwolfe clintoncwolfe merged commit ea111e4 into master Feb 25, 2019
@clintoncwolfe clintoncwolfe deleted the ja/suppress-unit-test-warnings branch February 25, 2019 16:57
@jerryaldrichiii
Copy link
Contributor Author

jerryaldrichiii commented Feb 25, 2019

@clintoncwolfe @robbkidd helped me out a bit. It looks like running m with a file path disables warnings https://github.com/qrush/m/blob/master/lib/m/parser.rb#L31

I was certain this used to not do that though.

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.

2 participants