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

CC-753 upgrade tester utils #45

Merged
merged 14 commits into from
Sep 26, 2023
Merged

CC-753 upgrade tester utils #45

merged 14 commits into from
Sep 26, 2023

Conversation

libmartinito
Copy link
Contributor

No description provided.

@linear
Copy link

linear bot commented Sep 26, 2023

CC-753 Upgrade tester_utils everywhere

To support extensions, we've had to make a breaking change to tester_utils. The PR is here: codecrafters-io/tester-utils#10.

We need to migrate over all course testers (and the "tester-template") to use this new structure.

Here's an example PR that does the migration for Redis: codecrafters-io/redis-tester#37. The description in that PR contains a rough list of steps that need to be taken:

  • Run make update_tester_utils
  • Resolve all the go errors, get the program to compile
  • Run CODECRAFTERS_RECORD_FIXTURES=true make test
    • The only changes to fixtures should be the stage name (which the tester doesn't have access to anymore)
  • Remove all usages of CODECRAFTERS_CURRENT_STAGE_SLUG
    • If you want a value for CODECRAFTERS_TEST_CASES_JSON that covers all stages, load a backup and run this command in core: puts Submission.where(course_stage: C("<course_slug>").last_stage).first.test_runs.first.test_cases_for_tester.to_json
  • Upgrade to Go 1.20.x

The list of repositories that use tester-utils can be found here: https://github.com/codecrafters-io/tester-utils/network/dependents. interpreter-tester and dns-server-tester don't have any changes yet, so you can just copy over contents from tester-template once that's updated.

tester_utils_testing.TestTesterOutput(t, testerDefinition, testCases)
}

func normalizeTesterOutput(testerOutput []byte) []byte {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

it seems that the CompareOutputWithFixture function in tester utils requires a NormalizeOutputFunc. is it better that this is always required? not sure how to normalize output for git, so i just returned the output

Copy link
Member

Choose a reason for hiding this comment

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

Yep, it's okay to just return the output if that works - some challenges will have randomness involved (like with TCP port numbers), that's where the normalization function is useful.

@libmartinito
Copy link
Contributor Author

there aren't tests for some of the stages. should i make a linear test for that for each tester or no

@libmartinito
Copy link
Contributor Author

appreciate if you could take a look at one instance before doing the other testers

@rohitpaulk
Copy link
Member

there aren't tests for some of the stages. should i make a linear test for that for each tester or no

Nope, it's fine - we'd want to retain whatever tests we have, don't need to add new ones as part of this migration.

appreciate if you could take a look at one instance before doing the other testers

@libmartinito you've got failing tests - other than that looks good. Does make test_with_git work locally?

Copy link
Member

@rohitpaulk rohitpaulk left a comment

Choose a reason for hiding this comment

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

(comment added)

@libmartinito
Copy link
Contributor Author

yep it works locally. the problem was the randomness in the file names, contents, hashed values. updated to be more deterministic.

@rohitpaulk
Copy link
Member

@libmartinito the randomness in tests is intentional. We do this to prevent users from accidentally passing the stage by hardcoding values. Let's find another way around it - check what other challenges do

@libmartinito libmartinito merged commit 8f8aaaf into main Sep 26, 2023
1 check passed
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