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

[sed] Bats tests for sed #2401

Conversation

james-stocks
Copy link

@james-stocks james-stocks commented Mar 29, 2019

Context

Supersedes #2368

Based on @predominant's work in https://github.com/habitat-sh/core-plans/pull/2377/files but I changed the tests slightly to add assurance that the version of sed that is being executed is the last built sed and not a different package's sed or even the system sed.

Signed-off-by: James Stocks jstocks@chef.io

Copy link
Contributor

@echohack echohack left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you for the tests to sed. There's one issue to resolve with this PR. Once that's solved I think it's mergable.

cat_computer

sed/tests/test.bats Outdated Show resolved Hide resolved
sed/tests/test.bats Outdated Show resolved Hide resolved
@gavindidrichsen gavindidrichsen self-assigned this May 2, 2019
Copy link
Contributor

@gavindidrichsen gavindidrichsen left a comment

Choose a reason for hiding this comment

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

Excellent work @james-stocks. 👍

@james-stocks
Copy link
Author

While these changes are approved, we don't yet have a process for merging commits to base plans outside of a base plan refresh - so we can't immediately merge this.

Signed-off-by: Scott Macfarlane <smacfarlane@chef.io>
@smacfarlane
Copy link
Contributor

@james-stocks Would you mind giving this a quick touch-up to meet the testing guidelines? I know you started this before those were in place, so if you don't have the cycles, I'm good with merging this to the refresh branch and adjusting the tests down the road.

smacfarlane and others added 7 commits June 24, 2019 12:26
[gradle4][gradle5]Fix builds of gradle4 and gradle5
Signed-off-by: Graham Weldon <graham@grahamweldon.com>
…form-0.12.3

[terraform] Update terraform to 0.12.3
* for windows and linux
* with amendments according to according to comments in issue habitat-sh#2678

Signed-off-by: Gavin Didrichsen <gavin.didrichsen@gmail.com>
…en/7zip_use_core_pester

[7zip] Update windows tests to use new core/pester core plan
* bringing structure inline with [test design document](habitat-sh#2539)
* using core/pester

Signed-off-by: Gavin Didrichsen <gavin.didrichsen@gmail.com>
…en/fix_dotnet_471_pkg_source_v2

[dotnet-471-dev-pack] VERSION 2: Add Pester tests to habitat installation of dotnet-471-dev-pack
sed/plan.sh Outdated
@@ -1,4 +1,4 @@
pkg_name=sed
pkg_name="sed"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need quotes here.

Copy link
Author

Choose a reason for hiding this comment

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

This fails shellcheck in CI when I remove the quotes

https://buildkite.com/chef-oss/habitat-sh-core-plans-master-verify/builds/1157#03063088-884b-497b-ba89-c8a3dfa9cddb

In sed/plan.sh line 1:
--
  | pkg_name=sed
  | ^-- SC2209: Use var=$(command) to assign output (or quote to assign string).

Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this is because sed is commonly identified as a command that someone is attempting to run. We should add a shellcheck exception for this plan, on this line.

Copy link
Author

Choose a reason for hiding this comment

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

What's the issue with having the quotes?

git grep pkg_name=\" | wc -l tells me there are ~95 core plans with quoted pkg_name values; and I'm wondering if I need to address them all at some point - I can file an issue for that and get them updated, but I'd like to track the reason why it's needed.

Copy link
Author

Choose a reason for hiding this comment

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

I changed to a shellcheck disable comment, but I'm still curious why we don't use quotes to avoid the concern than shellcheck highlights.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Its a false negative in this case. shellcheck thinks you're calling the sed command. There shouldn't be any need to quote a plan name.

sed/tests/test.bats Outdated Show resolved Hide resolved
@@ -0,0 +1,19 @@
#!/bin/sh
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test.sh is out of date. We should update this to be more in line with the new testing approach/standard that we have adopted. See examples in plans such as: hugo, terraform, nginx, hapropxy etc. The same applies for the sourceing in test.bats, which is no longer needed when using the new approach.

Copy link
Author

Choose a reason for hiding this comment

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

This test.sh seems to meet the current testing standard and I don't see any sourcing in test.bats

Does this comment refer an older revision of this PR (it did previously have an initial attempt that predated the standard being decided), or am I missing something?

Copy link
Author

Choose a reason for hiding this comment

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

Ah yes I did change the tests a day after this comment was left. I think the line that @predominant commented on remained unchanged, so Github doesn't consider this comment outdated.

@james-stocks james-stocks force-pushed the james-stocks/sed_tests_bats branch 3 times, most recently from 22931a8 to 9c70c0c Compare June 26, 2019 08:41
Signed-off-by: James Stocks <jstocks@chef.io>
@gavindidrichsen gavindidrichsen removed their assignment Jun 26, 2019
When pkg_name is unquoted like `pkg_name=sed` this causes a shellcheck warning in CI:

```
In sed/plan.sh line 1:
pkg_name=sed
^-- SC2209: Use var=$(command) to assign output (or quote to assign string).
```

We don't want quotes here, so instead disable the shellcheck.

Signed-off-by: James Stocks <jstocks@chef.io>
@james-stocks
Copy link
Author

@smacfarlane do you want these changes pointed at refresh/2019q3 instead of master ?

@smacfarlane
Copy link
Contributor

@smacfarlane do you want these changes pointed at refresh/2019q3 instead of master ?

@james-stocks Yes, please. Let's incorporate this into the refresh.

@james-stocks james-stocks changed the base branch from master to refresh/2019q3 July 1, 2019 15:49
@james-stocks
Copy link
Author

james-stocks commented Jul 1, 2019

Closing - opened new PR #2755 that points at the refresh branch.

@james-stocks james-stocks mentioned this pull request Jul 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants