Skip to content

re-enable customer center tests in main#4170

Closed
aboedo wants to merge 2 commits into
mainfrom
andy/add_tests_for_customer_center_to_main
Closed

re-enable customer center tests in main#4170
aboedo wants to merge 2 commits into
mainfrom
andy/add_tests_for_customer_center_to_main

Conversation

@aboedo

@aboedo aboedo commented Aug 12, 2024

Copy link
Copy Markdown
Member

We weren't running tests for Customer Center in PRs, since the CUSTOMER_CENTER_ENABLED flag is disabled.

This could be dangerous, so this PR enables the flag in the absolutely dumbest way I could think of: just replace the instances where the flag is used with true, before running tests, i.e.:

// before
#if CUSTOMER_CENTER_ENABLED

// after
#if true

It's easy to extend to other test suites. It could also have been its own test suite but I felt like it wouldn't have added much, we would have ended up most tests twice for no real gain.

@aboedo aboedo added the test label Aug 12, 2024
@aboedo aboedo requested a review from a team August 12, 2024 15:15
@aboedo aboedo self-assigned this Aug 12, 2024
Comment thread fastlane/Fastfile
Comment on lines +490 to +499
Find.find(project_root) do |path|
# process only Swift files
next unless File.file?(path) && File.extname(path) == ".swift"

content = File.read(path)

updated_content = content.gsub('CUSTOMER_CENTER_ENABLED', 'true')

File.write(path, updated_content) if content != updated_content
end

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

would have been shorter as a find + sed, but this is much easier to read IMO

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm I guess the fastlane commands to run tests are only run through CI normally, so this is probably ok... We could also make a sort of "block" so we restore it once tests finish, but I don't think it's worth it 👍

@aboedo

aboedo commented Aug 12, 2024

Copy link
Copy Markdown
Member Author
image confirmed that tests are in fact running for Customer Center

@JayShortway JayShortway left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

😚👌

@tonidero tonidero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!

Comment thread fastlane/Fastfile
Comment on lines +490 to +499
Find.find(project_root) do |path|
# process only Swift files
next unless File.file?(path) && File.extname(path) == ".swift"

content = File.read(path)

updated_content = content.gsub('CUSTOMER_CENTER_ENABLED', 'true')

File.write(path, updated_content) if content != updated_content
end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm I guess the fastlane commands to run tests are only run through CI normally, so this is probably ok... We could also make a sort of "block" so we restore it once tests finish, but I don't think it's worth it 👍

Comment thread fastlane/Fastfile
end

desc "Enable Customer Center"
lane :enable_customer_center do

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nitpick but should we make this a private lane?

Suggested change
lane :enable_customer_center do
private_lane :enable_customer_center do

@aboedo

aboedo commented Aug 12, 2024

Copy link
Copy Markdown
Member Author

closing in favor of #4171

@aboedo aboedo closed this Aug 12, 2024
jamesrb1 added a commit that referenced this pull request Aug 12, 2024
Customer Center is currently `#ifdef`ed out via
`CUSTOMER_CENTER_ENABLED` while it is under development, but we want to
run its tests during development. This defines `CUSTOMER_CENTER_ENABLED`
for `OTHER_SWIFT_FLAGS` via the command line build arguments for test
lanes, which will override the project settings, so the tests are run.

This PR can be reverted when the customer centre is released.

‼️This PR is not needed if we go for the [source-processing
method](#4170) instead.
@aboedo aboedo deleted the andy/add_tests_for_customer_center_to_main branch August 14, 2024 14:23
nyeu pushed a commit that referenced this pull request Oct 2, 2024
Customer Center is currently `#ifdef`ed out via
`CUSTOMER_CENTER_ENABLED` while it is under development, but we want to
run its tests during development. This defines `CUSTOMER_CENTER_ENABLED`
for `OTHER_SWIFT_FLAGS` via the command line build arguments for test
lanes, which will override the project settings, so the tests are run.

This PR can be reverted when the customer centre is released.

‼️This PR is not needed if we go for the [source-processing
method](#4170) instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants